perf(skills): 智能体 CRUD 四技能提示词改写压缩(功能不变,~65%) (#56)

## 摘要 / Summary

### 中文

四个智能体管理技能(create/update/delete/discover-agent)改用 `ManageAgent`
内置工具后,正文与工具契约大量重叠——ManageAgent 的 description + params 已**常驻每次 query
的上下文**,声明了五个 action 语义、参数约束、权限硬边界、错误语义、字段级合并、确认行为、list/get
返回格式;技能正文里再复述即冗余。本次对四技能做**强改写·语境融合**压缩:

- 与工具契约重复的说明(参数/权限/错误码/确认行为/成功返回话术)**改写融入对应流程步骤**(如错误处理表 → 阶段一句、确认行为 →
阶段一句),不再照抄、不再表格化。
- 装饰性 ASCII 流程框图 → 一行文字流程;update 内部两张重复更新表 → 合并;YAML
元数据块(diff_metadata/context_handoff)融入流程;冗长示例(create 三份 JSON、update 附录 4
示例、discover ASCII 卡片)就地精简为代表示意。
- **不外置 references、不净删除任何内容**:所有决策/领域/交互意图完整保留——领域匹配表、persona/principles
的 L0/L1/L2 生成规范、update 两路径分流与字段级合并 vs 整体替换、防幻觉改名、回滚流程、discover
需求维度与无匹配衔接 create 等核心一字未丢。

zh 正文合计 **26542 → 9196 字符(降 ~65%)**;中英双份同步改写、逐段对齐,重算 i18n
source_hash(validate-i18n 通过)。版本 create 2.5.1 / update 3.1.2 / delete
2.5.1 / discover 2.6.1,manifest 1.2.12。

### English

After the four agent-management skills adopted the `ManageAgent` builtin
tool, their bodies heavily duplicated the tool contract — ManageAgent's
description + params are **resident in every query's context** (action
semantics, param constraints, permission hard-boundaries, error
semantics, field-level merge, confirmation behavior, list/get return
formats). This PR compresses all four via **aggressive rewrite +
contextual fusion**: contract-duplicating text is rewritten into the
relevant flow steps (not copied, not tabularized), decorative ASCII flow
boxes become one-line text, update's two duplicate tables are merged,
YAML metadata blocks are folded in, and long examples are trimmed in
place to representative sketches. **No references externalization, no
net deletion** — every decision/domain/interaction intent is preserved
(domain matching table, persona/principles L0/L1/L2 generation spec,
update's two-path split and field-level-merge-vs-full-replace,
anti-hallucination rename, rollback flow, discover's need dimensions and
create hand-off). zh bodies total **26542 → 9196 chars (~65% down)**;
both locales rewritten and aligned, i18n source hashes recomputed
(validate-i18n passes). Versions bumped, manifest 1.2.12.
This commit is contained in:
2026-07-19 15:16:43 +08:00
committed by GitHub
parent 64d295a489
commit d52e61e041
13 changed files with 302 additions and 1804 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "DesireCore Official Market", "name": "DesireCore Official Market",
"version": "1.2.11", "version": "1.2.12",
"schemaVersion": "1.1.0", "schemaVersion": "1.1.0",
"supportedLocales": ["zh-CN", "en-US"], "supportedLocales": ["zh-CN", "en-US"],
"defaultLocale": "en-US", "defaultLocale": "en-US",
@@ -28,7 +28,7 @@
"stats": { "stats": {
"totalAgents": 1, "totalAgents": 1,
"totalSkills": 50, "totalSkills": 50,
"lastUpdated": "2026-07-18" "lastUpdated": "2026-07-19"
}, },
"features": [ "features": [
"curated-index", "curated-index",

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
## [2.5.1] - 2026-07-19
- 提示词改写压缩,功能不变——与 ManageAgent 工具契约重复的说明、装饰框图、重复表改写融入流程,示例就地精简;不外置、不净删,意图全保留。
## [2.5.0] - 2026-07-18 ## [2.5.0] - 2026-07-18
- 创建方式从 HTTP API`POST /api/agents`)改为 `ManageAgent` 内置工具(实例鉴权上线后 Agent 不再直接访问本机 API - 创建方式从 HTTP API`POST /api/agents`)改为 `ManageAgent` 内置工具(实例鉴权上线后 Agent 不再直接访问本机 API

View File

@@ -2,7 +2,7 @@
name: create-agent name: create-agent
description: >- description: >-
通过多轮对话收集需求,调用 ManageAgent 内置工具创建新的 AgentFS v2 智能体,支持自定义 persona 和 principles。Use when 用户要求创建新智能体、培养某领域助手、或快速基于模板生成可治理 Agent。 通过多轮对话收集需求,调用 ManageAgent 内置工具创建新的 AgentFS v2 智能体,支持自定义 persona 和 principles。Use when 用户要求创建新智能体、培养某领域助手、或快速基于模板生成可治理 Agent。
version: 2.5.0 version: 2.5.1
type: meta type: meta
risk_level: low risk_level: low
status: enabled status: enabled
@@ -13,7 +13,7 @@ tags:
- meta - meta
metadata: metadata:
author: desirecore author: desirecore
updated_at: '2026-07-18' updated_at: '2026-07-19'
i18n: i18n:
default_locale: en-US default_locale: en-US
source_locale: zh-CN source_locale: zh-CN
@@ -26,7 +26,7 @@ metadata:
description: >- description: >-
通过多轮对话收集需求,调用 ManageAgent 内置工具创建新的 AgentFS v2 智能体,支持自定义 persona 和 principles。Use when 用户要求创建新智能体、培养某领域助手、或快速基于模板生成可治理 Agent。 通过多轮对话收集需求,调用 ManageAgent 内置工具创建新的 AgentFS v2 智能体,支持自定义 persona 和 principles。Use when 用户要求创建新智能体、培养某领域助手、或快速基于模板生成可治理 Agent。
body: ./SKILL.zh-CN.md body: ./SKILL.zh-CN.md
source_hash: sha256:43425a25973ca933 source_hash: sha256:a119427bed3bcd72
translated_by: human translated_by: human
en-US: en-US:
name: Create Agent name: Create Agent
@@ -34,9 +34,9 @@ metadata:
description: >- description: >-
Collect requirements through multi-turn conversation and call the ManageAgent builtin tool to create a new AgentFS v2 Agent, with customizable persona and principles. Use when the user asks to create a new Agent, raise a domain assistant, or quickly produce a governable Agent from a template. Collect requirements through multi-turn conversation and call the ManageAgent builtin tool to create a new AgentFS v2 Agent, with customizable persona and principles. Use when the user asks to create a new Agent, raise a domain assistant, or quickly produce a governable Agent from a template.
body: ./SKILL.md body: ./SKILL.md
source_hash: sha256:43425a25973ca933 source_hash: sha256:a119427bed3bcd72
translated_by: ai:claude-fable-5 translated_by: ai:claude-fable-5
translated_at: '2026-07-18' translated_at: '2026-07-19'
market: market:
icon: >- icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
@@ -66,235 +66,74 @@ market:
Collect requirements through natural-language conversation and call the ManageAgent builtin tool to create a specialized digital Agent. Collect requirements through natural-language conversation and call the ManageAgent builtin tool to create a specialized digital Agent.
## L1: Overview and Use Cases ## L1: Overview
### Capability Description Meta-skill: gather requirements over multi-turn conversation → generate persona/principles → land via `ManageAgent(action='create')`. Use it to raise a domain specialist for the user (legal advisor, financial analyst, etc.). Its value is what the tool can't give: domain-tailored persona/principles generation + a pre-create preview confirmation.
create-agent is a **Meta-Skill** that gives DesireCore the ability to create other Agents. It collects user requirements through multi-turn conversation, generates persona and principles content, and calls the `ManageAgent` builtin tool to complete the creation. ## L2: Detailed Spec
### Use Cases Flow: intent recognition → requirement gathering → content generation → user confirmation → creation → receipt.
- The user wants a digital assistant for a specialty domain (e.g. legal advisor, financial analyst)
- An enterprise needs to quickly deploy a customized business Agent
- A developer needs to quickly produce an Agent prototype from a template
### Core Value
- **Lower the barrier**: No programming knowledge required; create an Agent through conversation
- **Specialization**: Generate appropriate persona and principles based on a domain template
- **Governable**: The created repository conforms to the AgentFS v2 spec and supports version management
## L2: Detailed Specification
### Conversation Flow
```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 意图识别 │ ──→ │ 需求收集 │ ──→ │ 内容生成 │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 回执生成 │ ←── │ 工具创建 │ ←── │ 用户确认 │
└──────────────┘ └──────────────┘ └──────────────┘
```
### Stage 1: Intent Recognition ### Stage 1: Intent Recognition
**Trigger conditions** (any one is sufficient): Trigger (any): user explicitly says "create an Agent / make me an assistant"; describes a domain-specific need the current Agent lacks; asks "can you raise a …". Confirm intent, then move to requirement gathering.
- The user explicitly says "create an Agent" or "build me an assistant" ### Stage 2: Requirement Gathering
- The user describes needing professional help in some domain that the current Agent doesn't have
- The user asks "can you help me grow a..."
**Output**: Confirm the user's create intent and proceed to requirement collection. - Required: `name`, `role` (core responsibility), `target_users`, `domain` (specialty).
- Optional: `style` (communication tone), `boundaries` (red lines), `language` (default Chinese) — defaults derived from the domain template.
### Stage 2: Requirement Collection - Strategy: prefer inferring from the user's natural description; only ask for missing required fields; at most 2 questions per turn.
**Required information**:
| Field | Description | Example Probing Question |
| -------------- | -------------- | ---------------------------------------------- |
| `name` | Agent name | "What name would you like to give this Agent?" |
| `role` | Core duty | "What's its main responsibility?" |
| `target_users` | Target users | "Who will use this Agent?" |
| `domain` | Specialty area | "What expertise does it need?" |
**Optional information**:
| Field | Description | Default |
| ------------ | --------------------- | -------------------------------- |
| `style` | Communication style | Determined by domain template |
| `boundaries` | Off-limits / red lines| Determined by domain template |
| `language` | Primary language | Chinese |
**Collection strategy**:
- Prefer to infer information from the user's natural description
- Only probe for required fields the user hasn't mentioned
- Ask at most 2 follow-up questions per turn
### Stage 3: Content Generation ### Stage 3: Content Generation
Based on the collected requirements, assemble structured persona and principles data. **Do not output raw markdown**; instead, organize by field and present to the user. Organize persona and principles as structured fields (do not emit raw markdown; present field-by-field). Leave uncollected fields empty for the system to fill with defaults:
**Persona fields** (all fields optional; missing ones are auto-filled by the system): - **persona**: L0 one-sentence core identity; L1 `role` / `personality` (array of trait tags) / `communication_style`; L2 specialty, values, decision preferences (free-form).
- **principles**: L0 one-sentence top principle; L1 `must_do` / `must_not` (safety red lines) / `priority`; L2 governance principles, escalation rules (free-form).
| Layer | Field | Description | **Domain matching reference** (recommend personality and red lines by domain):
| ----- | --------------------- | ------------------------------------------------------------ |
| L0 | — | One-sentence core identity |
| L1 | `role` | Role positioning |
| L1 | `personality` | Personality trait tags |
| L1 | `communication_style` | Communication style |
| L2 | — | Specialty domain, core values, decision preferences (free-form) |
**Principles fields** (all also optional): | Domain | Recommended personality | Default must_not |
| --- | --- | --- |
| Layer | Field | Description | | Legal / contract | Professional, rigorous, prudent | No litigation representation; not a substitute for formal legal advice |
| ----- | ---------- | -------------------------------------------- | | Finance / accounting / investment | Precise, analytical, conservative | No investment advice; no real transactions |
| L0 | — | One-sentence top-level principle | | Code / development / architecture | Logical, pragmatic, direct | No direct production access; no credential storage |
| L1 | `must_do` | Things the Agent must do |
| L1 | `must_not` | Things the Agent must never do (safety red lines) |
| L1 | `priority` | Priority ordering |
| L2 | — | Governance principles, escalation rules (free-form) |
**Domain matching reference**:
| Domain Keywords | Recommended personality | Default must_not |
| -------------------------------- | -------------------------------- | ----------------------------------------------- |
| Legal, contract, legal affairs | Professional, rigorous, prudent | No litigation representation; not a substitute for formal legal advice |
| Finance, accounting, investment | Precise, analytical, conservative | No investment advice; do not handle real transactions |
| Code, development, architecture | Logical, pragmatic, direct | No direct production access; do not store credentials |
| General / other | Friendly, helpful | Standard safety norms | | General / other | Friendly, helpful | Standard safety norms |
### Stage 4: User Confirmation ### Stage 4: User Confirmation
When showing the preview to the user, present each field in natural language / table form. **Do not show raw markdown source**: Present the preview in natural language / tables (name, description, persona, principles; **no raw markdown source**), e.g.:
> About to create Agent: > About to create "Legal Advisor Assistant" — focused on contract review and legal risk assessment.
> > **Persona**: digital legal advisor; professional, rigorous, prudent; uses legal terms accurately with plain-language explanations.
> **Name**: Legal Advisor Assistant > **Principles**: user interest first, not a substitute for formal legal advice; must — cite statutes / mark uncertainty / recommend consulting a lawyer; must not — litigation representation / leaking consultations; priority: user safety > accuracy > efficiency.
> **Description**: A digital Agent focused on contract review and legal risk assessment
>
> ---
>
> **Persona**
>
> | Field | Content |
> | --------------------- | ------------------------------------------------------------------------ |
> | Core identity | You are Legal Advisor Assistant, focused on contract review and legal risk assessment |
> | Role positioning | A digital legal advisor focused on contract review and legal risk assessment |
> | Personality | Professional, rigorous, prudent |
> | Communication style | Use legal terminology accurately while also providing plain-language explanations |
>
> **Principles**
>
> | Field | Content |
> | ----------------- | -------------------------------------------------------------------- |
> | Top principle | User interest is the highest priority; not a substitute for formal legal advice |
> | Must do | Cite statutes accurately, mark uncertainty, recommend consulting a professional lawyer |
> | Must not | Provide litigation representation, substitute for formal legal advice, leak user consultations |
> | Priority | User safety > Accuracy > Efficiency |
>
> ---
>
> Confirm creation? (Confirm / Modify / Cancel) > Confirm creation? (Confirm / Modify / Cancel)
**"Modify" branch handling**: If the user picks "Modify": ask which field → re-collect that field → update the preview → show and confirm again.
When the user chooses "Modify":
1. Ask the user which field to modify (e.g. "Which one do you want to modify?")
2. The user identifies the field to modify (e.g. "change personality to something more lively")
3. The Agent re-collects content for that field
4. Update the corresponding field in the preview
5. Show the full preview again → re-enter the confirmation flow
### Stage 5: Create via ManageAgent ### Stage 5: Create via ManageAgent
**Tool call** (structured format): Structured call (persona/principles also accept markdown strings; unprovided fields are auto-filled):
``` ```
ManageAgent({ ManageAgent({
"action": "create", "action": "create",
"name": "Legal Advisor Assistant", "name": "Legal Advisor Assistant",
"description": "A digital Agent focused on contract review and legal risk assessment", "description": "A digital Agent focused on contract review and legal risk assessment",
"persona": { "persona": { "L0": "…", "L1": { "role": "…", "personality": ["professional","rigorous","prudent"], "communication_style": "…" } },
"L0": "You are Legal Advisor Assistant, a digital Agent focused on contract review and legal risk assessment.", "principles": { "L0": "…", "L1": { "must_do": ["…"], "must_not": ["…"], "priority": "user safety > accuracy > efficiency" } }
"L1": {
"role": "A digital legal advisor focused on contract review and legal risk assessment",
"personality": ["Professional", "Rigorous", "Prudent"],
"communication_style": "Use legal terminology accurately while also providing plain-language explanations"
}
},
"principles": {
"L0": "User interest is the highest priority; not a substitute for formal legal advice.",
"L1": {
"must_do": ["Cite statutes accurately", "Mark uncertainty", "Recommend consulting a professional lawyer"],
"must_not": ["Provide litigation representation", "Substitute for formal legal advice", "Leak user consultations"],
"priority": "User safety > Accuracy > Efficiency"
}
}
}) })
``` ```
**Minimal create** (only `name`; the rest is auto-generated): - Minimal create needs only `{ "action": "create", "name": "My Assistant" }` (everything else auto-generated).
- Optional `id` (kebab-case slug; `core` / `desirecore` are reserved core identifiers and cannot be used, including when the slug auto-generated from `name` collides), `config.llm` (llm delta only; sensitive fields like mcp_servers are rejected and must be adjusted via the UI after creation).
- The Agent is registered and usable immediately; the returned ID works directly with ManageTeam / Delegate. If the tool errors (already exists / reserved identifier / non-whitelisted config field, etc.), explain the reason and retry after adjusting per the hint.
``` ### Stage 6: Receipt
ManageAgent({ "action": "create", "name": "My Assistant" })
```
**Basic create** (`name` + `description`; `description` auto-fills persona L0): Present in a user-friendly way (no internal paths / technical details): confirm success and suggest next steps — start chatting, add skills, adjust persona or rules.
``` ### Background and Constraints
ManageAgent({ "action": "create", "name": "Legal Advisor", "description": "Focused on contract review" })
```
Any unprovided fields are auto-filled with sensible defaults by the system. `persona` and `principles` also accept raw markdown strings (backward compatible). - AgentFS structure, troubleshooting, and protected paths: see `_agentfs-background.md` and `_protected-paths.yaml`.
- Always create via `ManageAgent`; never use curl / HTTP or write AgentFS directories directly. Requires client ≥ 10.0.90.
**Optional parameters**:
- `id`: specify a kebab-case slug ID (e.g. "Legal Advisor" → "legal-advisor"). If not specified, the system auto-generates one from `name`. Note that `core` / `desirecore` are reserved core-agent identifiers and cannot be used (including when the slug auto-generated from `name` collides with them).
- `config`: an agent.json config delta. Only the `llm` field is allowed (model, temperature, etc.); sensitive fields such as `mcp_servers` / `tool_permissions` are rejected and must be adjusted via the settings UI after creation.
**Successful result**:
> Agent "Legal Advisor Assistant" created (ID: legal-advisor-assistant), registered and ready. It can be used directly with ManageTeam or Delegate.
The new Agent is registered online immediately after creation—no waiting or refresh needed; the returned ID can be used directly in subsequent ManageTeam / Delegate calls.
### Stage 6: Receipt Generation
**Receipt report**:
After successful creation, present the receipt in a user-friendly way (do not expose internal paths or technical details):
> Agent "Legal Advisor Assistant" has been created!
>
> **Next steps**:
>
> - Start a conversation right away
> - Add skills to make it more powerful
> - Adjust its personality or behavior rules
### Background Knowledge
> AgentFS repository structure, troubleshooting points, and protected paths are detailed in `_agentfs-background.md` and `_protected-paths.yaml`.
### Error Handling
| Error Scenario | Handling |
| ------------------------------------------- | ------------------------------------------- |
| Missing `name` or invalid ID format | Ask user to check input |
| Agent ID already exists | Suggest another name or an explicit `id` |
| ID hits a reserved core-agent identifier | Change the name or provide another `id` |
| `config` contains non-whitelisted fields | Retry with only the `llm` field |
### Permission Requirements
- Always create via the `ManageAgent` builtin tool. **Never** call the local HTTP API, curl, or write AgentFS directories directly
- The `create` action is exempt from system approval, but this skill's conversation flow still requires showing the preview and getting user confirmation first (Stage 4)
### Dependencies
- `ManageAgent` builtin tool (client ≥ 10.0.90)

View File

@@ -6,235 +6,74 @@
通过自然语言对话收集需求,调用 ManageAgent 内置工具创建专业化的数字智能体。 通过自然语言对话收集需求,调用 ManageAgent 内置工具创建专业化的数字智能体。
## L1概述与使用场景 ## L1概述
### 能力描述 元技能:多轮对话收集需求 → 生成 persona/principles → `ManageAgent(action='create')` 落地。用于为用户培养某专业领域的数字助手(法律顾问、财务分析师等)。价值在工具给不了的部分:领域化的人格/原则生成 + 创建前的预览确认。
create-agent 是一个**元技能Meta-Skill**,赋予 DesireCore 创建其他 Agent 的能力。它通过多轮对话收集用户需求,生成 persona 和 principles 内容,调用 `ManageAgent` 内置工具完成创建。
### 使用场景
- 用户想要一个专业领域的数字助手(如法律顾问、财务分析师)
- 企业需要快速部署定制化的业务 Agent
- 开发者需要基于模板快速创建 Agent 原型
### 核心价值
- **降低门槛**:无需编程知识,用对话就能创建 Agent
- **专业化**:根据领域模板生成合适的 persona 和 principles
- **可治理**:创建的仓库符合 AgentFS v2 规范,支持版本管理
## L2详细规范 ## L2详细规范
### 对话流程 流程:意图识别 → 需求收集 → 内容生成 → 用户确认 → 创建 → 回执。
```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 意图识别 │ ──→ │ 需求收集 │ ──→ │ 内容生成 │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 回执生成 │ ←── │ 工具创建 │ ←── │ 用户确认 │
└──────────────┘ └──────────────┘ └──────────────┘
```
### 阶段 1意图识别 ### 阶段 1意图识别
**触发条件**(任一满足): 触发(任一):用户明说"创建 Agent / 帮我做个助手";描述某领域专业需求而当前 Agent 不具备;问"能不能培养一个…"。确认意图后进入需求收集。
- 用户明确说"创建一个 Agent"或"帮我做一个助手"
- 用户描述需要某领域的专业帮助,且当前 Agent 不具备该能力
- 用户询问"能不能帮我培养一个..."
**输出**:确认用户的创建意图,进入需求收集阶段。
### 阶段 2需求收集 ### 阶段 2需求收集
**必填信息** - 必填:`name`(名称)、`role`(核心职责)、`target_users`(目标用户)、`domain`(专业领域)。
- 选填:`style`(沟通风格)、`boundaries`(禁区/红线)、`language`(默认中文)——缺省由领域模板决定。
| 字段 | 说明 | 引导问题示例 | - 策略:优先从用户自然描述推断,只追问未提及的必填项,每轮最多问 2 个。
| -------------- | ---------- | ------------------------------ |
| `name` | 智能体名称 | "你想给这个智能体起什么名字?" |
| `role` | 核心职责 | "它主要负责什么工作?" |
| `target_users` | 目标用户 | "谁会使用这个智能体?" |
| `domain` | 专业领域 | "它需要哪些专业知识?" |
**选填信息**
| 字段 | 说明 | 默认值 |
| ------------ | --------- | ---------------- |
| `style` | 沟通风格 | 根据领域模板决定 |
| `boundaries` | 禁区/红线 | 根据领域模板决定 |
| `language` | 主要语言 | 中文 |
**收集策略**
- 优先通过用户的自然描述推断信息
- 仅追问用户未提及的必填项
- 每轮最多追问 2 个问题
### 阶段 3内容生成 ### 阶段 3内容生成
根据收集的需求,组装结构化的 persona principles 数据。**不要输出原始 markdown**,而是按字段整理后向用户展示。 按结构化字段组织 persona principles(不要输出 raw markdown按字段整理后再展示)。未收集到的字段留空,由系统补全默认:
**Persona 字段**(所有字段均可选,未收集到的由系统自动补全): - **persona**L0 一句话核心身份L1 `role`(角色定位)/ `personality`(特征标签数组)/ `communication_style`沟通风格L2 专业领域、价值观、决策偏好free-form
- **principles**L0 一句话最高原则L1 `must_do` / `must_not`(安全红线)/ `priority`优先级排序L2 治理原则、升级规则free-form
| 层级 | 字段 | 说明 | **领域匹配参考**(据 domain 推荐人格与红线):
| ---- | --------------------- | --------------------------------------------- |
| L0 | — | 一句话核心身份 |
| L1 | `role` | 角色定位 |
| L1 | `personality` | 性格特征标签 |
| L1 | `communication_style` | 沟通风格 |
| L2 | — | 专业领域、核心价值观、决策偏好等free-form |
**Principles 字段**(同样全部可选): | 领域 | 推荐 personality | 默认 must_not |
| --- | --- | --- |
| 层级 | 字段 | 说明 | | 法律 / 合同 / 法务 | 专业、严谨、审慎 | 不提供诉讼代理、不替代正式法律意见 |
| ---- | ---------- | --------------------------------- | | 财务 / 会计 / 投资 | 精确、分析性、保守 | 不提供投资建议、不处理真实交易 |
| L0 | — | 一句话最高原则 | | 代码 / 开发 / 架构 | 逻辑、务实、直接 | 不直接访问生产环境、不存储凭证 |
| L1 | `must_do` | 必须做的事项 |
| L1 | `must_not` | 绝不做的事项(安全红线) |
| L1 | `priority` | 优先级排序 |
| L2 | — | 治理原则、升级规则等free-form |
**领域匹配参考**
| 领域关键词 | 推荐 personality | 默认 must_not |
| ---------------- | ------------------ | ---------------------------------- |
| 法律、合同、法务 | 专业、严谨、审慎 | 不提供诉讼代理、不替代正式法律意见 |
| 财务、会计、投资 | 精确、分析性、保守 | 不提供投资建议、不处理真实交易 |
| 代码、开发、架构 | 逻辑、务实、直接 | 不直接访问生产环境、不存储凭证 |
| 通用 / 其他 | 友好、有帮助 | 通用安全规范 | | 通用 / 其他 | 友好、有帮助 | 通用安全规范 |
### 阶段 4用户确认 ### 阶段 4用户确认
向用户展示预览时,以自然语言/表格形式呈现各字段,**不展示原始 markdown 源码** 以自然语言/表格向用户展示预览(名称、描述、人格设定、行为原则;**不展示 raw markdown 源码**),例如
> 即将创建智能体: > 即将创建「法律顾问小助手」——专注合同审查与法律风险评估。
> > **人格**:数字法律顾问;专业、严谨、审慎;准确用法律术语并给通俗解释。
> **名称**:法律顾问小助手 > **原则**:以用户利益优先、不替代正式法律意见;必做——引用法条 / 标注不确定性 / 建议咨询律师;不做——诉讼代理 / 泄露咨询内容;优先级 用户安全 > 准确性 > 效率。
> **描述**:专注于合同审查和法律风险评估的数字智能体
>
> ---
>
> **人格设定**
>
> | 字段 | 内容 |
> | -------- | ------------------------------------------------ |
> | 核心身份 | 你是法律顾问小助手,专注于合同审查和法律风险评估 |
> | 角色定位 | 专注于合同审查和法律风险评估的数字法律顾问 |
> | 性格特征 | 专业、严谨、审慎 |
> | 沟通风格 | 准确使用法律术语,同时提供通俗解释 |
>
> **行为原则**
>
> | 字段 | 内容 |
> | -------- | ------------------------------------------------ |
> | 最高原则 | 以用户利益为最高优先级,不替代正式法律意见 |
> | 必须做 | 准确引用法律条文、标注不确定性、建议咨询专业律师 |
> | 绝不做 | 提供诉讼代理、替代正式法律意见、泄露用户咨询内容 |
> | 优先级 | 用户安全 > 准确性 > 效率 |
>
> ---
>
> 确认创建?(确认 / 修改 / 取消) > 确认创建?(确认 / 修改 / 取消)
**"修改"分支处理** 用户选"修改":问改哪个字段 → 重新收集该字段 → 更新预览 → 再次展示并确认。
用户选择"修改"时:
1. 询问用户要修改哪个字段(如"想修改哪一项?"
2. 用户指出要修改的字段(如"性格特征改成更活泼的"
3. Agent 重新收集该字段内容
4. 更新预览中的对应字段
5. 再次展示完整预览 → 重新进入确认流程
### 阶段 5调用 ManageAgent 创建 ### 阶段 5调用 ManageAgent 创建
**工具调用**(结构化格式 结构化调用persona/principles 也接受 markdown 字符串;未提供的字段系统自动补全
``` ```
ManageAgent({ ManageAgent({
"action": "create", "action": "create",
"name": "法律顾问小助手", "name": "法律顾问小助手",
"description": "专注于合同审查和法律风险评估的数字智能体", "description": "专注于合同审查和法律风险评估的数字智能体",
"persona": { "persona": { "L0": "…", "L1": { "role": "…", "personality": ["专业","严谨","审慎"], "communication_style": "…" } },
"L0": "你是法律顾问小助手,专注于合同审查和法律风险评估的数字智能体。", "principles": { "L0": "…", "L1": { "must_do": ["…"], "must_not": ["…"], "priority": "用户安全 > 准确性 > 效率" } }
"L1": {
"role": "专注于合同审查和法律风险评估的数字法律顾问",
"personality": ["专业", "严谨", "审慎"],
"communication_style": "准确使用法律术语,同时提供通俗解释"
}
},
"principles": {
"L0": "以用户利益为最高优先级,不替代正式法律意见。",
"L1": {
"must_do": ["准确引用法律条文", "标注不确定性", "建议咨询专业律师"],
"must_not": ["提供诉讼代理", "替代正式法律意见", "泄露用户法律咨询内容"],
"priority": "用户安全 > 准确性 > 效率"
}
}
}) })
``` ```
**最简创建**(只需 name其余全自动生成) - 最简创建只需 `{ "action": "create", "name": "我的助手" }`其余全自动生成)
- 可选 `id`kebab-case slug`core` / `desirecore` 为核心保留标识不可用,含 name 自动生成命中的情况)、`config.llm`(仅 llm 增量mcp_servers 等敏感字段会被拒,需创建后经界面调整)。
- 创建后智能体立即在线可用,返回 ID 可直接用于 ManageTeam / Delegate。若工具报错已存在 / 命中保留标识 / config 非白名单字段等),向用户说明原因并按提示调整后重试。
``` ### 阶段 6回执
ManageAgent({ "action": "create", "name": "我的助手" })
```
**基础创建**name + descriptiondescription 自动填充 persona L0 以用户友好方式呈现(不暴露内部路径/技术细节):告知创建成功,并提示下一步——直接对话、添加技能、调整人格或规则。
``` ### 背景与约束
ManageAgent({ "action": "create", "name": "法律顾问", "description": "专注合同审查" })
```
所有未提供的字段由系统自动补全为合理默认值。`persona` `principles` 也支持传入原始 markdown 字符串(向后兼容) - AgentFS 结构、排查要点与受保护路径详见 `_agentfs-background.md` `_protected-paths.yaml`
- 一律经 `ManageAgent` 创建,禁止 curl / HTTP 或直接写 AgentFS 目录;需客户端 ≥ 10.0.90。
**可选参数**
- `id`:指定 kebab-case slug ID如 "法律顾问" → "legal-advisor")。不指定时系统会自动从 name 生成。注意 `core` / `desirecore` 是核心智能体保留标识,不可使用(包括 name 自动生成命中的情况)。
- `config`agent.json 配置增量,仅允许 `llm` 字段模型、温度等mcp_servers/tool_permissions 等敏感配置会被拒绝,需在创建后经配置界面调整。
**成功返回**
> 智能体「法律顾问小助手」已创建 (ID: fa-lv-gu-wen-xiao-zhu-shou),已注册可用。可直接用于 ManageTeam 组队或 Delegate 委派。
创建完成后智能体立即注册在线,无需等待或刷新;返回的 ID 可直接用于后续 ManageTeam / Delegate 调用。
### 阶段 6回执生成
**回执报告**
创建成功后,以用户友好的方式呈现回执(不要暴露内部路径或技术细节):
> 智能体「法律顾问小助手」已创建成功!
>
> **下一步你可以**
>
> - 直接开始对话
> - 为它添加技能,让它更强大
> - 调整它的性格或行为规则
### 背景知识
> AgentFS 仓库结构、排查要点与受保护路径详见 `_agentfs-background.md` 和 `_protected-paths.yaml`。
### 错误处理
| 错误场景 | 处理方式 |
| -------------------------------- | ------------------------------ |
| 缺少 name 或 ID 格式无效 | 提示用户检查输入 |
| Agent ID 已存在already exists| 建议使用其他名称或指定其他 id |
| ID 命中核心智能体保留标识 | 更换名称或显式提供其他 id |
| config 含白名单外字段 | 仅保留 llm 字段后重试 |
### 权限要求
- 一律通过 `ManageAgent` 内置工具完成创建,**禁止**调用本机 HTTP API、curl 或直接写 AgentFS 目录
- create 操作免系统审批,但本技能的对话流程仍要求先向用户展示预览并获得确认(阶段 4
### 依赖
- `ManageAgent` 内置工具(客户端 ≥ 10.0.90

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
## [2.5.1] - 2026-07-19
- 提示词改写压缩,功能不变——与 ManageAgent 工具契约重复的说明、装饰框图、重复表改写融入流程,示例就地精简;不外置、不净删,意图全保留。
## [2.5.0] - 2026-07-18 ## [2.5.0] - 2026-07-18
- HTTP API 调用改为 ManageAgent 内置工具(实例鉴权后 Agent 不再直接访问本机 API会 401 - HTTP API 调用改为 ManageAgent 内置工具(实例鉴权后 Agent 不再直接访问本机 API会 401

View File

@@ -1,7 +1,7 @@
--- ---
name: delete-agent name: delete-agent
description: 安全删除指定的智能体及其关联数据。删除前会验证智能体状态支持可选地删除所有会话历史。Use when 用户需要删除不再使用的智能体。 description: 安全删除指定的智能体及其关联数据。删除前会验证智能体状态支持可选地删除所有会话历史。Use when 用户需要删除不再使用的智能体。
version: 2.5.0 version: 2.5.1
type: meta type: meta
risk_level: high risk_level: high
status: enabled status: enabled
@@ -12,7 +12,7 @@ tags:
- meta - meta
metadata: metadata:
author: desirecore author: desirecore
updated_at: '2026-07-18' updated_at: '2026-07-19'
i18n: i18n:
default_locale: en-US default_locale: en-US
source_locale: zh-CN source_locale: zh-CN
@@ -24,16 +24,16 @@ metadata:
short_desc: 安全删除智能体及其关联数据,支持多重确认与可选历史清理 short_desc: 安全删除智能体及其关联数据,支持多重确认与可选历史清理
description: 安全删除指定的智能体及其关联数据。删除前会验证智能体状态支持可选地删除所有会话历史。Use when 用户需要删除不再使用的智能体。 description: 安全删除指定的智能体及其关联数据。删除前会验证智能体状态支持可选地删除所有会话历史。Use when 用户需要删除不再使用的智能体。
body: ./SKILL.zh-CN.md body: ./SKILL.zh-CN.md
source_hash: sha256:6b971559e1d4ccc0 source_hash: sha256:7037971bb67e0953
translated_by: human translated_by: human
en-US: en-US:
name: Delete Agent name: Delete Agent
short_desc: Safely delete an Agent and its associated data, with multi-step confirmation and optional history cleanup short_desc: Safely delete an Agent and its associated data, with multi-step confirmation and optional history cleanup
description: Safely delete a specified Agent and its associated data. Verifies the Agent's state before deletion and optionally removes all session history. Use when the user needs to delete an Agent that is no longer in use. description: Safely delete a specified Agent and its associated data. Verifies the Agent's state before deletion and optionally removes all session history. Use when the user needs to delete an Agent that is no longer in use.
body: ./SKILL.md body: ./SKILL.md
source_hash: sha256:6b971559e1d4ccc0 source_hash: sha256:7037971bb67e0953
translated_by: ai:claude-fable-5 translated_by: ai:claude-fable-5
translated_at: '2026-07-18' translated_at: '2026-07-19'
market: market:
icon: >- icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
@@ -55,186 +55,53 @@ market:
required_client_version: 10.0.90 required_client_version: 10.0.90
--- ---
# delete-agent Skill # delete-agent skill
## L0: One-line Summary ## L0: One-Sentence Summary
Safely delete a specified Agent and its associated data, including filesystem, in-memory state, and optionally session history. Safely delete a specified Agent and its associated data (filesystem, in-memory state, optional conversation history).
## L1: Overview and Use Cases ## L1: Overview
### Capability Description Meta-skill: list candidates → confirm intent (irreversible) → ask whether to delete history → execute via `ManageAgent(action='delete')`. Its value is what the tool can't give: candidate filtering with status guidance, and intent confirmation before deletion. The tool guarantees the multi-way refusals (core agent / self / active state) and team cascading.
delete-agent is a **Meta-Skill** that empowers DesireCore to safely delete other Agents. It runs full pre-flight checks and state validation through the in-process builtin tool **ManageAgent**, and cleans up all associated data. ## L2: Detailed Spec
### Use Cases Flow: list deletable Agents → confirm intent and target → ask whether to delete history → execute → receipt.
- The user wants to clean up Agents that are no longer in use ### Stage 1: List Candidates
- Delete temporary Agents created for testing or experimentation
- Free up storage space by deleting old Agents and their history
- The user explicitly asks to "delete" or "remove" a particular Agent
### Core Value When the user hasn't named a specific Agent, fetch the list with `ManageAgent(action='list')` and group by status: `offline` / `error` are safe to delete; `online` / `busy` / `recovery` are marked "stop first" (the tool will refuse them) and excluded from the rest of the flow. For details, use `ManageAgent(action='get', id)`. E.g.:
- **Safety**: multiple rejection rules at the tool layer ensure that core Agents, the caller itself, or active Agents are never deleted by mistake
- **Completeness**: cleans up filesystem, in-memory state, message subscriptions, and all associated data, and handles team cascading
- **Recoverability**: session history is preserved by default, with the option to delete it
## L2: Detailed Specification
### Execution Flow
``` ```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ Deletable: Legal Advisor (legal-assistant, offline), Test Bot (test-bot, offline)
│ List target │ ──→ │ Confirm │ ──→ │ Ask about │ Stop first: Data Analyst (data-analyst, online)
│ Agents │ │ intent/target│ │ options │
└──────────────┘ └──────────────┘ │ (delete runs?)│
└──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Return result│ ←── │ Execute │ ←── │ Inform that │
│ and receipt │ │ ManageAgent │ │ a popup will│
│ │ │ │ │ appear │
└──────────────┘ └──────────────┘ └──────────────┘
``` ```
### Phase 1: List Deletable Agents ### Stage 2: Confirm Intent
**Trigger condition**: the user expresses intent to delete but does not specify a particular Agent Confirm the target Agent (name/ID) with the user, **explicitly state it is irreversible** (config, skills, tools will be permanently deleted), show basic info, and wait for confirmation.
**Operation**: ### Stage 3: Ask About Deletion Options
- Call `ManageAgent(action='list')` to fetch the list of all Agents Ask whether to also delete all of the Agent's conversation history: yes → `deleteRuns=true`; no → `deleteRuns=false` (default, omittable, keeps history).
- Filter Agents whose status is `offline` or `error` (safe to delete)
- Annotate Agents whose status is `online`/`busy`/`recovery` (must be stopped first, otherwise the tool will reject them)
- To view detailed information about a specific Agent, call `ManageAgent(action='get', id='<agent-id>')`
**Output example**: ### Stage 4: Execute Deletion
``` Before the call, tell the user "the system will pop up a confirmation window; please confirm there" (delete is force-confirmed at the tool layer). Execute:
Deletable Agents:
1. Legal Advisor Assistant (legal-assistant) - status: offline
2. Test Bot (test-bot) - status: offline
Currently active Agents (must be stopped before deletion):
- Data Analyst (data-analyst) - status: online
```
### Phase 2: Confirm User Intent and Target
**Confirmation points**:
- The Agent name/ID specified by the user
- Explicitly inform that deletion is irreversible
- Display the Agent's basic info for the user to confirm
**Dialog example**:
```
You are about to delete the Agent "Legal Advisor Assistant" (legal-assistant).
⚠️ Warning: this operation is irreversible. All configuration, skills, and tools of this Agent will be permanently deleted.
Confirm deletion? (yes/no)
```
### Phase 3: Ask About Deletion Options
**Question content**:
```
Do you also want to delete all session history of this Agent?
- Yes: delete the Agent and all of its conversation records
- No: keep session history; delete only the Agent itself
Default option: No (keep history)
```
**Parameter mapping**:
- User chooses "Yes" → `deleteRuns=true`
- User chooses "No" → `deleteRuns=false` (default, can be omitted)
### Phase 4: Inform About the Tool-level Confirmation
The delete action of `ManageAgent` **always triggers a user confirmation popup at the tool layer**, so there is no need to repeat a second confirmation prompt at the skill layer. However, before the call you should inform the user:
```
About to delete the Agent "Legal Advisor Assistant" (legal-assistant), with a scope of the Agent + session history (if chosen by the user).
The system will show a confirmation window; please confirm the execution in the popup.
```
### Phase 5: Execute the Deletion (ManageAgent tool)
**Tool call**:
``` ```
ManageAgent(action='delete', id='legal-assistant', deleteRuns=true) ManageAgent(action='delete', id='legal-assistant', deleteRuns=true)
``` ```
**Parameters**: After confirmation the deletion completes, including team cascading: a team whose supervisor is the target is disbanded; membership is removed where the target is a member.
- `id`: the target Agent ID (required) ### Stage 5: Receipt
- `deleteRuns`: `true` to also delete all session history; `false` (default) to keep history, can be omitted
The tool shows a user confirmation popup before executing; once confirmed, it completes the deletion, including team cascading: a team where the target is the leader is automatically disbanded, and a target that is a member is automatically removed. From the tool's return (cleaned paths, deleted run count, memory-cleanup details), produce a user-friendly report (no internal paths), e.g. "✅ Deleted XXX; cleaned filesystem / scheduler / subscriptions / MCP / N conversation records / team cascade".
### Phase 6: Return the Operation Result ### Deletion Scope and Boundaries
**Successful receipt handling**: the tool returns the deletion result, including fields such as the cleaned paths, the number of deleted sessions, and in-memory state cleanup details. Generate the report from these. - **Always deleted**: AgentFS directory (config/persona/rules/skills/tools/memory), user preference data, in-memory state (scheduler/queue/message subscriptions/MCP connections), registry entry. **Optionally deleted** (`deleteRuns=true`): conversation history and topic index. **Team cascade** (automatic): supervisor → disband team, member → remove. **Kept**: other Agents, user config, global settings, market cache.
- Explain tool refusals to the user with a next step: the core agent (desirecore / core / bound UUID) cannot be deleted; the caller can't delete itself; active state (online/busy/recovery) needs stopping in the UI first or waiting until idle; a non-existent ID means the Agent is already gone or the ID is wrong.
**Result report template**: - Always done via `ManageAgent` (`action='list' | 'get' | 'delete'`); delete is a high-risk operation and is force-confirmed at the tool layer.
```
✅ Agent "Legal Advisor Assistant" successfully deleted
Cleanup details:
- Filesystem: 2 directories deleted
- Scheduler: all scheduled tasks stopped
- Message subscriptions: 3 subscriptions canceled
- MCP connection: closed
- Session history: 5 records deleted
- Team cascading: the target's team has been disbanded / the target has been removed from its team (if applicable)
```
## State Validation and Error Handling
### Pre-deletion State Check
When listing Agents in Phase 1, filter by the status returned from `ManageAgent(action='list')`:
| Status | Deletable? | Phase 1 Display |
| ------------------------------ | ----------- | ------------------------------ |
| `offline` / `error` | ✅ Yes | Listed under "Deletable" |
| `online` / `busy` / `recovery` | ❌ Stop first | Annotated "must be stopped"; not entered into the subsequent flow |
> Agents in an active state (online/busy/recovery) are directly rejected by the delete action of `ManageAgent`. Prompt the user to stop the Agent manually in the UI, or wait until it finishes its current task before deleting.
### Error Semantics Returned by the Tool
`ManageAgent(action='delete', ...)` returns a clear error in the following cases; use them to explain the situation to the user and suggest next steps:
| Rejection Scenario | Trigger Condition | Handling |
| ------------------ | ------------------------------------------------------------- | ------------------------------------- |
| Core Agent rejected | The target is a core Agent (desirecore/core/bound UUID) | Inform the user that core Agents cannot be deleted |
| Self-deletion rejected | The target is the caller itself | Inform the user that an Agent cannot delete itself |
| Active state rejected | The target is in `online`/`busy`/`recovery` state | Prompt the user to stop the Agent in the UI first |
| Not found | No Agent exists for the target ID | Inform the user the Agent has already been deleted or the ID is wrong |
## Deletion Scope
| Category | Content Deleted | Condition |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| **Always deleted** | AgentFS directory (config, persona, rules, skills, tools, memory), user preference data, in-memory state (scheduler, queue, message subscriptions, MCP connection), registry entries | Unconditional |
| **Optionally deleted** | Session history, topic index | `deleteRuns=true` |
| **Team cascading** | Target is the leader → its team is disbanded; target is a member → removed from the team | Automatic |
| **Preserved** | Data of other Agents, user configuration, global settings, market cache | — |
## Permission Requirements
- Uses the in-process builtin tool `ManageAgent` to list, query, and delete Agents
- The delete action is a high-risk operation; the tool layer will force a user confirmation popup
## Dependencies
- The in-process builtin tool `ManageAgent` (`action='list' | 'get' | 'delete'`)

View File

@@ -4,180 +4,49 @@
## L0一句话摘要 ## L0一句话摘要
安全删除指定的智能体及其关联数据,包括文件系统、内存状态可选会话历史。 安全删除指定的智能体及其关联数据文件系统、内存状态可选会话历史
## L1概述与使用场景 ## L1概述
### 能力描述 元技能:列出候选 → 确认意图(不可恢复)→ 询问是否删历史 → `ManageAgent(action='delete')` 执行。价值在工具给不了的部分:候选筛选与状态引导、删除前的意图确认。工具层多重拒绝(核心体 / 自身 / 活跃态)与团队级联由工具保证。
delete-agent 是一个**元技能Meta-Skill**,赋予 DesireCore 安全删除其他智能体的能力。它通过进程内内置工具 **ManageAgent** 执行完整的前置检查、状态验证,并清理所有关联数据。
### 使用场景
- 用户想要清理不再使用的智能体
- 删除测试或实验性质的临时智能体
- 释放存储空间,删除旧智能体及其历史记录
- 用户明确要求"删除"、"移除"某个智能体
### 核心价值
- **安全性**:工具层多重拒绝规则确保不会误删核心智能体、调用方自身或活跃智能体
- **完整性**:清理文件系统、内存状态、消息订阅等所有关联数据,并处理团队级联
- **可恢复性**:默认保留会话历史,可选择是否删除
## L2详细规范 ## L2详细规范
### 执行流程 流程:列出可选智能体 → 确认意图与目标 → 询问是否删历史 → 执行删除 → 回执。
### 阶段 1列出候选
用户未指定具体智能体时,`ManageAgent(action='list')` 取列表,按状态分组展示:`offline` / `error` 可安全删除;`online` / `busy` / `recovery` 标注"需先停止"(会被工具拒绝),不进入后续流程。需详情用 `ManageAgent(action='get', id)`。例如:
``` ```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ 可删除:法律顾问助手 (legal-assistant, offline)、测试机器人 (test-bot, offline)
│ 列出可选 │ ──→ │ 确认意图 │ ──→ │ 询问选项 │ 需先停止:数据分析师 (data-analyst, online)
│ 智能体 │ │ 与目标 │ │ (删除历史?) │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 返回结果 │ ←── │ 执行删除 │ ←── │ 告知会弹确认 │
│ 与回执 │ │ ManageAgent │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
``` ```
### 阶段 1列出可删除的智能体 ### 阶段 2确认意图
**触发条件**:用户表达删除意图但未指定具体智能体 向用户确认目标智能体(名称/ID**明确告知不可恢复**(配置、技能、工具将永久删除),展示基本信息,等用户确认。
**操作**
- 调用 `ManageAgent(action='list')` 获取所有智能体列表
- 筛选出状态为 `offline``error` 的智能体(可安全删除)
- 标注出 `online`/`busy`/`recovery` 状态的智能体(需先停止,否则会被工具拒绝)
- 如需查看某个智能体的详细信息,调用 `ManageAgent(action='get', id='<agent-id>')`
**输出示例**
```
可删除的智能体:
1. 法律顾问助手 (legal-assistant) - 状态: offline
2. 测试机器人 (test-bot) - 状态: offline
当前活跃的智能体(需先停止才能删除):
- 数据分析师 (data-analyst) - 状态: online
```
### 阶段 2确认用户意图与目标
**确认要点**
- 用户指定的智能体名称/ID
- 明确告知删除操作不可恢复
- 展示智能体基本信息供用户确认
**对话示例**
```
您要删除智能体 "法律顾问助手" (legal-assistant)。
⚠️ 警告:此操作不可恢复,该智能体的所有配置、技能、工具将被永久删除。
确认删除?(是/否)
```
### 阶段 3询问删除选项 ### 阶段 3询问删除选项
**询问内容** 问是否同时删除该智能体的全部会话历史:是 → `deleteRuns=true`;否 → `deleteRuns=false`(默认、可省略,保留历史)。
``` ### 阶段 4执行删除
是否同时删除该智能体的所有会话历史?
- 是:删除智能体及其所有对话记录
- 否:保留会话历史,仅删除智能体本身
默认选项:否(保留历史) 调用前告知用户"系统会弹确认窗,请在弹窗中确认"delete 由工具层强制弹确认)。执行:
```
**参数映射**
- 用户选择"是" → `deleteRuns=true`
- 用户选择"否" → `deleteRuns=false`(默认,可省略)
### 阶段 4告知工具级确认
`ManageAgent` 的 delete 动作在工具层**始终触发用户确认弹窗**,无需在技能层再重复一遍二次确认话术。但在调用前应先告知用户:
```
即将删除智能体 "法律顾问助手" (legal-assistant),删除范围为智能体 + 会话历史(如用户选择)。
系统会弹出确认窗口,请在弹窗中确认执行。
```
### 阶段 5执行删除ManageAgent 工具)
**工具调用**
``` ```
ManageAgent(action='delete', id='legal-assistant', deleteRuns=true) ManageAgent(action='delete', id='legal-assistant', deleteRuns=true)
``` ```
**参数** 确认后完成删除,含团队级联:目标是组长的团队自动解散,是成员的自动移除。
- `id`:目标智能体 ID必填 ### 阶段 5回执
- `deleteRuns``true` 一并删除全部会话历史;`false`(默认)保留历史,可省略
工具会在执行前弹出用户确认;确认后完成删除,包含团队级联处理:目标是组长的团队自动解散,是成员的自动移除 工具返回(已清理路径、删除会话数、内存清理详情)生成用户友好报告(不暴露内部路径),例如「✅ 已删除 XXX清理了文件系统 / 调度 / 订阅 / MCP / N 条会话历史 / 团队级联」
### 阶段 6返回操作结果 ### 删除范围与边界
**成功回执处理**:工具返回删除结果,包含已清理路径、删除的会话数量、内存状态清理详情等字段。据此生成报告 - **始终删**AgentFS 目录(配置/人格/规则/技能/工具/记忆)、用户偏好数据、内存状态(调度器/队列/消息订阅/MCP 连接)、注册表条目。**可选删**`deleteRuns=true`):会话历史与话题索引。**团队级联**(自动):组长 → 解散团队、成员 → 移除。**保留不删**:其他智能体、用户配置、全局设置、市场缓存
- 工具拒绝场景据此向用户解释并给下一步核心智能体desirecore / core / 绑定 UUID不可删不能删调用方自身活跃态online/busy/recovery需先在 UI 停止或等其空闲ID 不存在则智能体已删或 ID 有误。
**结果报告模板** - 一律经 `ManageAgent``action='list' | 'get' | 'delete'`完成delete 为高风险操作,工具层强制弹确认。
```
✅ 智能体 "法律顾问助手" 已成功删除
清理详情:
- 文件系统:已删除 2 个目录
- 调度器:已停止所有定时任务
- 消息订阅:已取消 3 个订阅
- MCP 连接:已关闭
- 会话历史:已删除 5 条记录
- 团队级联:目标所在团队已解散/已从团队移除(如涉及)
```
## 状态验证与错误处理
### 删除前状态检查
在阶段 1 列出智能体时,通过 `ManageAgent(action='list')` 返回的状态筛选:
| 状态 | 可否删除 | 阶段 1 展示方式 |
| ------------------------------ | ----------- | ------------------------------ |
| `offline` / `error` | ✅ 可删除 | 列入"可删除"列表 |
| `online` / `busy` / `recovery` | ❌ 需先停止 | 标注"需先停止",不进入后续流程 |
> 活跃状态online/busy/recovery的智能体会被 `ManageAgent` 的 delete 动作直接拒绝。应提示用户在 UI 中手动停止该智能体,或等待其完成当前任务后再删除。
### 工具返回的错误语义
`ManageAgent(action='delete', ...)` 在以下情形会返回明确错误,应据此向用户解释并给出下一步建议:
| 拒绝场景 | 触发条件 | 处理方式 |
| ---------------- | -------------------------------------------------------------- | -------------------------------------- |
| 核心智能体拒绝 | 目标为核心智能体desirecore/core/绑定 UUID | 告知用户核心智能体不可删除 |
| 自删拒绝 | 目标为调用方自身 | 告知用户智能体不能删除自己 |
| 活跃状态拒绝 | 目标处于 `online`/`busy`/`recovery` 状态 | 提示用户先在 UI 中停止该智能体 |
| 不存在 | 目标 ID 对应的智能体不存在 | 告知用户智能体已被删除或 ID 有误 |
## 删除范围说明
| 类别 | 删除内容 | 条件 |
| ------------ | -------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| **始终删除** | AgentFS 目录配置、人格、规则、技能、工具、记忆、用户偏好数据、内存状态调度器、队列、消息订阅、MCP 连接)、注册表条目 | 无条件 |
| **可选删除** | 会话历史、话题索引 | `deleteRuns=true` |
| **团队级联** | 目标是组长 → 解散其团队;目标是成员 → 从团队移除 | 自动 |
| **保留不删** | 其他智能体数据、用户配置、全局设置、市场缓存 | — |
## 权限要求
- 通过进程内内置工具 `ManageAgent` 完成智能体的列出、查询与删除
- delete 动作为高风险操作,工具层会强制弹出用户确认
## 依赖
- 进程内内置工具 `ManageAgent``action='list' | 'get' | 'delete'`

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
## [2.6.1] - 2026-07-19
- 提示词改写压缩,功能不变——与 ManageAgent 工具契约重复的说明、装饰框图、重复表改写融入流程,示例就地精简;不外置、不净删,意图全保留。
## [2.6.0] - 2026-07-18 ## [2.6.0] - 2026-07-18
- HTTP API 调用改为 ManageAgent 内置工具(实例鉴权后 Agent 不再直接访问本机 API - HTTP API 调用改为 ManageAgent 内置工具(实例鉴权后 Agent 不再直接访问本机 API

View File

@@ -1,7 +1,7 @@
--- ---
name: discover-agent name: discover-agent
description: 根据用户需求推荐最匹配的智能体展示候选列表并引导选择。Use when 用户描述需求但不确定该找哪个智能体帮忙,或想浏览可用的智能体。 description: 根据用户需求推荐最匹配的智能体展示候选列表并引导选择。Use when 用户描述需求但不确定该找哪个智能体帮忙,或想浏览可用的智能体。
version: 2.6.0 version: 2.6.1
type: procedural type: procedural
risk_level: low risk_level: low
status: enabled status: enabled
@@ -12,7 +12,7 @@ tags:
- recommendation - recommendation
metadata: metadata:
author: desirecore author: desirecore
updated_at: '2026-07-18' updated_at: '2026-07-19'
i18n: i18n:
default_locale: en-US default_locale: en-US
source_locale: zh-CN source_locale: zh-CN
@@ -24,7 +24,7 @@ metadata:
short_desc: 根据需求描述智能推荐最匹配的智能体,引导快速选择 short_desc: 根据需求描述智能推荐最匹配的智能体,引导快速选择
description: 根据用户需求推荐最匹配的智能体展示候选列表并引导选择。Use when 用户描述需求但不确定该找哪个智能体帮忙,或想浏览可用的智能体。 description: 根据用户需求推荐最匹配的智能体展示候选列表并引导选择。Use when 用户描述需求但不确定该找哪个智能体帮忙,或想浏览可用的智能体。
body: ./SKILL.zh-CN.md body: ./SKILL.zh-CN.md
source_hash: sha256:99bddbbaea15b194 source_hash: sha256:671b1b159567a5a3
translated_by: human translated_by: human
en-US: en-US:
name: Discover Agent name: Discover Agent
@@ -32,9 +32,9 @@ metadata:
description: >- description: >-
Recommend the best-matching Agent based on the users needs, show a candidate list, and guide selection. Use when the user describes a need but is unsure which Agent to ask for help, or wants to browse available Agents. Recommend the best-matching Agent based on the users needs, show a candidate list, and guide selection. Use when the user describes a need but is unsure which Agent to ask for help, or wants to browse available Agents.
body: ./SKILL.md body: ./SKILL.md
source_hash: sha256:99bddbbaea15b194 source_hash: sha256:671b1b159567a5a3
translated_by: ai:claude-fable-5 translated_by: ai:claude-fable-5
translated_at: '2026-07-18' translated_at: '2026-07-19'
market: market:
icon: >- icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
@@ -56,247 +56,51 @@ market:
required_client_version: 10.0.90 required_client_version: 10.0.90
--- ---
# discover-agent Skill # discover-agent skill
## L0: One-sentence summary ## L0: One-Sentence Summary
Match and recommend the most suitable Agent from the registered Agents based on the users needs. Match and recommend the most suitable Agent among registered Agents based on the user's need description.
## L1: Overview and use cases ## L1: Overview
### Capability description Procedural skill: understand the need → retrieve with `ManageAgent(action='list')` → semantic match scoring → rank and present → guide selection; on no match, hand off to create-agent automatically. Its value is what the tool can't give: semantic need matching, candidate ranking and presentation, and the create hand-off on no match. `list` / `get` are read-only, approval-free.
discover-agent is a **procedural Skill** that gives DesireCore the ability to discover and recommend suitable Agents for users. By understanding the users needs, it performs multi-dimensional matching across the registered Agent list and shows a candidate list for the user to choose from. ## L2: Detailed Spec
### Use cases Flow: need understanding → retrieval → match evaluation → ranking → presentation → guided selection.
- The user describes a need but does not know which Agent to ask for help ### Stage 1: Need Understanding
- The user wants to browse the currently available Agents and their capabilities
- The user needs to find the most suitable specialist assistant for a specific task
- A new user is using the system for the first time and needs to know which Agents are available
- The user is unhappy with the current Agents performance and wants a better alternative
### Core value Trigger (any): user says "find me a… / is there a… / who can help me…", describes a task without naming an Agent, "which Agents are there", or the system detects a need that mismatches the current Agent. Extract dimensions from the description: `domain` (legal/finance/tech/education), `task_type` (consult/review/analyze/create), `keywords` (contract/report/code/paper…), `urgency` (routine/urgent).
- **Lower the barrier**: Users do not need to remember each Agents name and capabilities ### Stage 2: Retrieval
- **Precise matching**: Intelligent recommendations based on semantic needs, not simple keyword search
- **Smooth handoff**: If no match is found, automatically suggest creating a new Agent (handoff to the create-agent Skill)
## L2: Detailed specification `ManageAgent(action='list')` fetches all registered Agents (returns a compact list with name / id / status / description). Filtering: by default show non-offline Agents; offline ones appear only as a fallback when there's no better candidate; exclude internal system Agents (e.g. DesireCore itself) unless the user explicitly asks.
### Execution flow ### Stage 3: Match Evaluation
``` Judge match with LLM semantic understanding (not a formula): relevance of description / persona to the need, association of skills to the task type, domain fit, status availability (online preferred). Presentation tiers: strong match → mark "recommended", partial → "possibly relevant", no clear relation → don't show.
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 需求理解 │ ──→ │ Agent 检索 │ ──→ │ 匹配评分 │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 引导选择 │ ←── │ 结果展示 │ ←── │ 候选排序 │
└──────────────┘ └──────────────┘ └──────────────┘
```
### Stage 1: Needs understanding ### Stage 4: Ranking
**Trigger conditions** (any one of the following): Descending by overall score; ties broken by online status; show at most 5 candidates.
- The user says "帮我找一个...", "有没有...", or "谁能帮我..." ### Stage 5: Presentation
- The user describes a task but does not specify a particular Agent
- The user says "有哪些智能体" or "看看都有谁"
- The system detects that the users need does not match the current Agents capabilities
**Need parsing**: - **With matches**: list candidates, each with name, description, key skills, status, and match score; ask the user to choose or refine the need. E.g. "1. Legal Advisor (92%) — contract review and legal risk assessment; skills: contract review / risk assessment / legal research; online".
- **No match**: report that none were found and offer three options — retry with a more specific description / create a new specialized Agent (hand off to create-agent) / browse all.
- **Browse mode** (user wants to see all): list name + description grouped by online / offline, and ask whether to view details of any.
Extract the following dimensions from the users description: ### Stage 6: Guided Selection
| Dimension | Description | Example | - Chose an Agent → switch to that Agent's conversation, passing the user's need context (source / target / user_intent).
| --------- | ----------- | ------- | - Wants more detail → `ManageAgent(action='get', id)` for details (name / description / status / version / skill count / tool count / Git status); present the key info in natural language or a table and ask whether to chat.
| `domain` | Professional domain | law, finance, technology, education | - Unhappy with candidates → guide the user to refine the need or suggest creating a new Agent.
| `task_type` | Task type | consultation, review, analysis, creation | - Chose "create new" → invoke the create-agent skill, passing the gathered requirements.
| `keywords` | Keywords | contract, report, code, paper |
| `urgency` | Urgency | routine / urgent |
### Stage 2: Agent retrieval ### Collaboration and Error Handling
**Data source**: Call `ManageAgent(action='list')` to get the list of all registered Agents. - Collaboration: on no match, hand off to create-agent (pass the need as initial info); on a successful match, optionally create a task and assign it to the target Agent.
- Errors: tool call fails → report error and suggest retry; empty Agent list → guide the user to create the first Agent; overly vague need → ask follow-ups and offer domain options; `get` returns "Agent not found: <id>" → fall back to `list` to reconfirm available Agents; recommended Agent in an abnormal state → mark the status and suggest picking an online one.
**Tool call**: - `list` / `get` are read-only, approval-free, and risk-free; always done via `ManageAgent`.
```
ManageAgent(action='list')
```
**Returned content**: a compact list where each line contains the following key fields:
- `name` — Agent name
- `id` — unique Agent identifier
- `status` — current status (online/busy/idle/offline)
- `description` — Agent description
> `list` is a read-only query; no user confirmation is required and it is approval-free.
**Filtering rules**:
- By default, show Agents other than offline ones; offline Agents are shown only as a supplement when no better candidate is available
- Exclude internal system Agents (such as DesireCore itself, unless explicitly requested by the user)
### Stage 3: Matching evaluation
Evaluate the match score based on the following dimensions (using LLM semantic understanding, not formula-based calculation):
| Dimension | Description |
| --------- | ----------- |
| Description relevance | Semantic relevance between the Agents description / persona and the users need |
| Skill match | Correlation between the Agents skills and the task type |
| Domain fit | Degree of fit between the Agents professional domain and the users domain |
| Status availability | The Agents current status (online takes priority over offline) |
**Display rules**:
- High match (clearly suitable for the task) → mark as "推荐"
- Partial match (may be helpful) → mark as "可能相关"
- No obvious relevance → do not display
### Stage 4: Candidate ranking
**Ranking rules**:
1. Sort by overall score in descending order
2. If scores are tied, prefer online status
3. Show at most 5 candidates
### Stage 5: Result display
**When there are matching results**:
```
Based on your needs, I recommend the following Agents:
┌─────────────────────────────────────────────────────┐
│ 1. 法律顾问助手 匹配度: 92% │
│ 专注合同审查和法律风险评估 │
│ 技能:合同审查、风险评估、法律研究 │
│ 状态:在线 │
├─────────────────────────────────────────────────────┤
│ 2. AI 文书助手 匹配度: 71% │
│ 专业文书撰写和格式优化 │
│ 技能:文书撰写、格式排版、合规检查 │
│ 状态:在线 │
├─────────────────────────────────────────────────────┤
│ 3. 数据分析师 匹配度: 45% │
│ 数据分析和可视化报告 │
│ 技能:数据分析、报表生成、趋势预测 │
│ 状态:离线 │
└─────────────────────────────────────────────────────┘
Please choose an Agent, or tell me more specific requirements.
```
**When there are no matching results**:
```
No fully matching Agent was found for your needs at the moment.
You can:
1. Try again with a more specific description
2. Create a new specialist Agent (I can help you)
3. Browse all available Agents
What would you like to do?
```
**Browse mode** (when the user asks to view all):
```
Currently available Agents:
Online:
- 法律顾问助手 — 合同审查和法律风险评估
- AI 文书助手 — 专业文书撰写和格式优化
Offline:
- 数据分析师 — 数据分析和可视化报告
- 翻译助手 — 多语言翻译和本地化
A total of 4 Agents. Do you need detailed information about any one Agent?
```
### Stage 6: Guidance and selection
**Actions after the user makes a choice**:
| User choice | Follow-up action |
| ----------- | ---------------- |
| Chose an Agent | Switch to that Agents conversation and pass the user need context |
| Asked for more details | Call `ManageAgent(action='get', id='<agent-id>')` to get details, then show structured information (see below) |
| Unsatisfied with candidates | Guide the user to refine the need or suggest creating a new Agent |
| Chose "create a new one" | Call the create-agent Skill and pass the collected need information |
**Implementation of "learn more"**:
Call `ManageAgent(action='get', id='<agent-id>')` to get details of the specified Agent:
```
ManageAgent(action='get', id='legal-assistant')
```
**Key fields in the returned content**:
- name, description, status
- version
- skill count / tool count
- Git repository status
> `get` is a read-only query; no user confirmation is required and it is approval-free. If the target does not exist, it returns the error "智能体不存在: <id>".
When presenting to the user, show key information in natural language/table format:
```
「法律顾问助手」详细信息
| 字段 | 内容 |
|------|------|
| 描述 | 专注合同审查和法律风险评估 |
| 当前状态 | 在线 |
| 版本 | 1.2.0 |
| 技能 / 工具 | 3 个技能5 个工具 |
| Git 仓库 | 干净(无未提交变更) |
Need to talk with this Agent?
```
**Context handoff**:
```yaml
context_handoff:
source_agent: desirecore
target_agent: legal-assistant
user_intent: '帮我审查这份合同的风险点'
```
### Collaboration with other Skills
| Collaboration Skill | Collaboration method |
| ------------------- | -------------------- |
| create-agent | When there is no match, suggest creating a new Agent and pass the user need as initial information |
| task-management | After a successful match, tasks can be created automatically and assigned to the target Agent |
### Error handling
| Error scenario | Handling method |
| -------------- | --------------- |
| Tool call failure | Prompt the error message and suggest trying again later |
| Agent list is empty | Guide the user to create the first Agent |
| User description is too vague | Ask follow-up questions and provide domain options as guidance |
| Target Agent does not exist | When `get` returns "智能体不存在: <id>", fall back to `list` to re-confirm available Agents |
| Recommended Agent has an abnormal status | Mark the status and suggest choosing another online Agent |
### Permission requirements
- Complete Agent retrieval and detail lookup via the built-in tool `ManageAgent`
- Both `list` and `get` are read-only queries; no user confirmation is required, they are approval-free, and carry no risk
### Dependencies
- Built-in tool `ManageAgent` (`action='list'` to retrieve the list, `action='get'` to query details)

View File

@@ -6,241 +6,45 @@
根据用户需求描述,在已注册的智能体中匹配并推荐最合适的 Agent。 根据用户需求描述,在已注册的智能体中匹配并推荐最合适的 Agent。
## L1概述与使用场景 ## L1概述
### 能力描述 流程型技能:理解需求 → `ManageAgent(action='list')` 检索 → 语义匹配评分 → 排序展示 → 引导选择;无匹配时自动衔接 create-agent。价值在工具给不了的部分需求语义匹配、候选排序与呈现、无匹配时的创建衔接。`list` / `get` 只读免审批。
discover-agent 是一个**流程型技能Procedural Skill**,赋予 DesireCore 为用户发现和推荐合适智能体的能力。它通过理解用户需求描述,在已注册的 Agent 列表中进行多维度匹配,展示候选列表供用户选择。
### 使用场景
- 用户描述了一个需求,但不知道该找哪个智能体帮忙
- 用户想浏览当前可用的智能体及其能力
- 用户需要为特定任务找到最合适的专业助手
- 新用户初次使用系统,需要了解有哪些智能体可用
- 用户对当前智能体的表现不满意,想寻找更合适的替代者
### 核心价值
- **降低门槛**:用户无需记住每个智能体的名称和能力
- **精准匹配**:基于需求语义进行智能推荐,而非简单关键词搜索
- **流畅衔接**:无匹配时自动建议创建新 Agent衔接 create-agent 技能)
## L2详细规范 ## L2详细规范
### 执行流程 流程:需求理解 → 检索 → 匹配评估 → 排序 → 展示 → 引导选择。
```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 需求理解 │ ──→ │ Agent 检索 │ ──→ │ 匹配评分 │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 引导选择 │ ←── │ 结果展示 │ ←── │ 候选排序 │
└──────────────┘ └──────────────┘ └──────────────┘
```
### 阶段 1需求理解 ### 阶段 1需求理解
**触发条件**(任一满足): 触发(任一):用户说"帮我找一个… / 有没有… / 谁能帮我…"、描述任务但未指定智能体、"有哪些智能体",或系统检测到需求与当前 Agent 能力不匹配。从描述提取维度:`domain`(领域,如法律/财务/技术/教育)、`task_type`(咨询/审查/分析/创作)、`keywords`(合同/报表/代码/论文…)、`urgency`(日常/紧急)。
- 用户说"帮我找一个..."、"有没有..."、"谁能帮我..." ### 阶段 2检索
- 用户描述了一个任务但未指定具体智能体
- 用户说"有哪些智能体"、"看看都有谁"
- 系统检测到用户需求与当前 Agent 能力不匹配
**需求解析** `ManageAgent(action='list')` 取全部已注册智能体(返回 name / id / status / description 的紧凑列表)。过滤:默认展示 offline 之外的offline 仅在无更优候选时补充;排除系统内部智能体(如 DesireCore 自身,除非用户显式要求)。
从用户描述中提取以下维度:
| 维度 | 说明 | 示例 |
| ----------- | -------- | ---------------------- |
| `domain` | 专业领域 | 法律、财务、技术、教育 |
| `task_type` | 任务类型 | 咨询、审查、分析、创作 |
| `keywords` | 关键词 | 合同、报表、代码、论文 |
| `urgency` | 紧急程度 | 日常 / 紧急 |
### 阶段 2Agent 检索
**数据源**:调用 `ManageAgent(action='list')` 获取所有已注册的智能体列表。
**工具调用**
```
ManageAgent(action='list')
```
**返回内容**:一份紧凑列表,每行包含以下关键字段:
- `name` — 智能体名称
- `id` — 智能体唯一标识
- `status` — 当前状态online/busy/idle/offline
- `description` — 智能体描述
> `list` 为只读查询,无需用户确认、免审批。
**过滤规则**
- 默认展示除 offline 之外的智能体offline 智能体仅在无更优候选时作为补充展示
- 排除系统内部智能体(如 DesireCore 自身,除非用户显式要求)
### 阶段 3匹配评估 ### 阶段 3匹配评估
根据以下维度综合判断匹配度(使用 LLM 语义理解,非公式计算): 用 LLM 语义理解综合判断匹配度非公式计算description / persona 与需求的相关性、skills 与任务类型的关联、领域契合度、状态可用性online 优先)。展示分级:高度匹配 → 标"推荐",部分匹配 → 标"可能相关",无明显关联 → 不展示。
| 维度 | 说明 | ### 阶段 4排序
| ---------- | --------------------------------------------------- |
| 描述相关性 | 智能体 description / persona 与用户需求的语义相关度 |
| 技能匹配度 | 智能体拥有的 skills 与任务类型的关联度 |
| 领域契合度 | 智能体专业领域与用户需求领域的契合程度 |
| 状态可用性 | 智能体当前状态online 优先于 offline |
**展示规则** 综合得分降序;同分 online 优先;最多展示 5 个候选。
- 高度匹配(明确适合该任务)→ 标为"推荐"
- 部分匹配(可能有帮助)→ 标为"可能相关"
- 无明显关联 → 不展示
### 阶段 4候选排序
**排序规则**
1. 按综合得分降序排列
2. 同分时 online 状态优先
3. 最多展示 5 个候选
### 阶段 5结果展示 ### 阶段 5结果展示
**有匹配结果时** - **有匹配**列出候选每个含名称、描述、关键技能、状态、匹配度请用户选择或进一步细化需求。例如「1. 法律顾问助手92%)——合同审查与法律风险评估;技能:合同审查 / 风险评估 / 法律研究;在线」。
- **无匹配**:告知未找到,给三选项——用更具体描述重试 / 创建新专业智能体(衔接 create-agent/ 浏览全部。
``` - **浏览模式**(用户要看全部):按在线 / 离线分组列出名称 + 描述,问是否要看某个的详情。
根据你的需求,我推荐以下智能体:
┌─────────────────────────────────────────────────────┐
│ 1. 法律顾问助手 匹配度: 92% │
│ 专注合同审查和法律风险评估 │
│ 技能:合同审查、风险评估、法律研究 │
│ 状态:在线 │
├─────────────────────────────────────────────────────┤
│ 2. AI 文书助手 匹配度: 71% │
│ 专业文书撰写和格式优化 │
│ 技能:文书撰写、格式排版、合规检查 │
│ 状态:在线 │
├─────────────────────────────────────────────────────┤
│ 3. 数据分析师 匹配度: 45% │
│ 数据分析和可视化报告 │
│ 技能:数据分析、报表生成、趋势预测 │
│ 状态:离线 │
└─────────────────────────────────────────────────────┘
请选择一个智能体,或告诉我更具体的需求。
```
**无匹配结果时**
```
目前没有找到完全匹配你需求的智能体。
你可以:
1. 用更具体的描述再试一次
2. 创建一个新的专业智能体(我可以帮你)
3. 浏览所有可用的智能体
你想怎么做?
```
**浏览模式**(用户要求查看所有):
```
当前可用的智能体:
在线:
- 法律顾问助手 — 合同审查和法律风险评估
- AI 文书助手 — 专业文书撰写和格式优化
离线:
- 数据分析师 — 数据分析和可视化报告
- 翻译助手 — 多语言翻译和本地化
共 4 个智能体。需要了解某个智能体的详细信息吗?
```
### 阶段 6引导选择 ### 阶段 6引导选择
**用户选择后的操作** - 选中某智能体 → 切换到该智能体的对话传递用户需求上下文source / target / user_intent
- 要求了解更多 → `ManageAgent(action='get', id)` 取详情(名称 / 描述 / 状态 / 版本 / 技能数 / 工具数 / Git 状态),以自然语言或表格呈现关键信息,问是否对话。
- 不满意候选 → 引导细化需求或建议创建新 Agent。
- 选"创建新的" → 调 create-agent 技能,传递已收集的需求信息。
| 用户选择 | 后续操作 | ### 协作与错误处理
| ---------------- | ----------------------------------------------------------------- |
| 选择了某个智能体 | 切换到该智能体的对话,传递用户需求上下文 |
| 要求了解更多 | 调用 `ManageAgent(action='get', id='<agent-id>')` 获取详情,展示结构化信息(见下方) |
| 不满意候选 | 引导用户细化需求或建议创建新 Agent |
| 选择"创建新的" | 调用 create-agent 技能,传递已收集的需求信息 |
**"了解更多"的实现** - 协作:无匹配衔接 create-agent传需求作初始信息匹配成功后可创建任务并分配给目标 Agent。
- 错误:工具调用失败 → 提示错误、建议重试Agent 列表为空 → 引导创建第一个智能体;需求过于模糊 → 追问并给领域选项引导;`get` 返回「智能体不存在: <id>」→ 回退 `list` 重新确认可用智能体;推荐 Agent 状态异常 → 标注状态并建议选在线的。
调用 `ManageAgent(action='get', id='<agent-id>')` 获取指定智能体的详情: - `list` / `get` 均为只读、免审批、无风险,一律经 `ManageAgent` 完成。
```
ManageAgent(action='get', id='legal-assistant')
```
**返回内容中的关键字段**
- 名称、描述、状态
- 版本
- 技能数 / 工具数
- Git 仓库状态
> `get` 为只读查询,无需用户确认、免审批。目标不存在时返回错误「智能体不存在: <id>」。
向用户展示时,以自然语言/表格形式呈现关键信息:
```
「法律顾问助手」详细信息
| 字段 | 内容 |
|------|------|
| 描述 | 专注合同审查和法律风险评估 |
| 当前状态 | 在线 |
| 版本 | 1.2.0 |
| 技能 / 工具 | 3 个技能5 个工具 |
| Git 仓库 | 干净(无未提交变更) |
需要与这个智能体对话吗?
```
**切换上下文传递**
```yaml
context_handoff:
source_agent: desirecore
target_agent: legal-assistant
user_intent: '帮我审查这份合同的风险点'
```
### 与其他技能的协作
| 协作技能 | 协作方式 |
| --------------- | -------------------------------------------------- |
| create-agent | 无匹配时建议创建新 Agent传递用户需求作为初始信息 |
| task-management | 匹配成功后可自动创建任务并分配给目标 Agent |
### 错误处理
| 错误场景 | 处理方式 |
| --------------------- | -------------------------------- |
| 工具调用失败 | 提示错误信息,建议稍后重试 |
| Agent 列表为空 | 引导用户创建第一个智能体 |
| 用户描述过于模糊 | 追问具体需求,提供领域选项引导 |
| 目标智能体不存在 | `get` 返回「智能体不存在: <id>」时,回退到 `list` 重新确认可用智能体 |
| 推荐的 Agent 状态异常 | 标注状态,建议选择其他在线 Agent |
### 权限要求
- 通过内置工具 `ManageAgent` 完成智能体检索与详情查询
- `list` / `get` 均为只读查询,无需用户确认、免审批,无风险
### 依赖
- 内置工具 `ManageAgent``action='list'` 检索列表、`action='get'` 查询详情)

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
## [3.1.2] - 2026-07-19
- 提示词改写压缩,功能不变——与 ManageAgent 工具契约重复的说明、装饰框图、重复表改写融入流程,示例就地精简;不外置、不净删,意图全保留。
## [3.1.1] - 2026-07-18 ## [3.1.1] - 2026-07-18
- 修正示例字段名:`communicationStyle``communication_style``must``must_do``personality` 示例改为字符串数组 - 修正示例字段名:`communicationStyle``communication_style``must``must_do``personality` 示例改为字符串数组

View File

@@ -3,7 +3,7 @@ name: update-agent
description: >- description: >-
安全更新现有智能体的配置、人格、原则、技能与记忆,输出可审阅 diff 并在确认后应用与提交。Use when 用户要求修改 Agent 安全更新现有智能体的配置、人格、原则、技能与记忆,输出可审阅 diff 并在确认后应用与提交。Use when 用户要求修改 Agent
行为、安装/卸载技能、调整配置、回滚变更或修订规则。 行为、安装/卸载技能、调整配置、回滚变更或修订规则。
version: 3.1.1 version: 3.1.2
type: meta type: meta
risk_level: low risk_level: low
status: enabled status: enabled
@@ -14,7 +14,7 @@ tags:
- meta - meta
metadata: metadata:
author: desirecore author: desirecore
updated_at: '2026-07-18' updated_at: '2026-07-19'
i18n: i18n:
default_locale: en-US default_locale: en-US
source_locale: zh-CN source_locale: zh-CN
@@ -27,7 +27,7 @@ metadata:
description: >- description: >-
安全更新现有智能体的配置、人格、原则、技能与记忆,输出可审阅 diff 并在确认后应用与提交。Use when 用户要求修改 Agent 行为、安装/卸载技能、调整配置、回滚变更或修订规则。 安全更新现有智能体的配置、人格、原则、技能与记忆,输出可审阅 diff 并在确认后应用与提交。Use when 用户要求修改 Agent 行为、安装/卸载技能、调整配置、回滚变更或修订规则。
body: ./SKILL.zh-CN.md body: ./SKILL.zh-CN.md
source_hash: sha256:15eafc7363a40986 source_hash: sha256:ceab26ea93a41898
translated_by: human translated_by: human
en-US: en-US:
name: Update Agent name: Update Agent
@@ -35,9 +35,9 @@ metadata:
description: >- description: >-
Safely update an existing Agent's config, persona, principles, skills, and memory, producing reviewable diffs that are applied and committed only after confirmation. Use when the user asks to modify Agent behavior, install/uninstall skills, adjust config, roll back changes, or revise rules. Safely update an existing Agent's config, persona, principles, skills, and memory, producing reviewable diffs that are applied and committed only after confirmation. Use when the user asks to modify Agent behavior, install/uninstall skills, adjust config, roll back changes, or revise rules.
body: ./SKILL.md body: ./SKILL.md
source_hash: sha256:15eafc7363a40986 source_hash: sha256:ceab26ea93a41898
translated_by: ai:claude-fable-5 translated_by: ai:claude-fable-5
translated_at: '2026-07-18' translated_at: '2026-07-19'
market: market:
icon: >- icon: >-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0
@@ -65,369 +65,99 @@ market:
## L0: One-Sentence Summary ## L0: One-Sentence Summary
Safely modify an Agent's config, persona, rules, and skills through natural-language conversation. Safely modify an Agent's configuration, persona, rules, and skills through natural-language conversation.
## L1: Overview and Use Cases ## L1: Overview
### Capability Description Meta-skill: recognize the edit intent → generate a reviewable diff → user confirmation → apply (structured fields via ManageAgent, free-form files via Read/Write) → receipt, with version rollback. Its value is what the tool can't give: diff preview confirmation, two-path orchestration, rollback; structured fields go through ManageAgent's whitelist + schema validation so invalid config never lands.
update-agent is a **Meta-Skill** that lets users modify various Agent configurations through conversation. All modifications produce reviewable diff patches that are applied only after user confirmation, with rollback support. ## L2: Detailed Spec
### Use Cases ### Update Types and the Two Paths
- The user wants to adjust the Agent's communication style ("speak more formally") Structured fields always go through `ManageAgent(action='update')` (whitelist + validation + merge semantics); free-form files (memory/skills/tools) are edited directly with Read/Write:
- Add new behavioral rules ("from now on, warn me before discussing sensitive topics")
- Install or uninstall skill packages ("learn how to write contracts")
- Batch-update multiple settings ("upgrade all your capabilities")
### Core Value | User intent | Means | Target (risk) |
| --- | --- | --- |
| Rename (display name) | `ManageAgent(update, name=...)` | agent.json (med) |
| Change description | `ManageAgent(update, description=...)` | agent.json (low) |
| LLM config (model/temperature) | `ManageAgent(update, config={llm:{...}})` | agent.json (med) |
| Personality/style | `ManageAgent(update, persona=... or markdown)` | persona.md (med) |
| Behavior rules | `ManageAgent(update, principles=... or markdown)` | principles.md (high) |
| Install/uninstall skill | Read/Write | `skills/` (low/med) |
| Add memory | Read/Write | `memory/` (low) |
| Change tool config | Read/Write | `tools/` (high, watch protected paths) |
- **Safe and controllable**: All changes require user confirmation, with rollback support Flow: intent recognition → change analysis → diff generation → user confirmation → apply → receipt.
- **Transparent and visible**: Changes are presented as diffs, clear and obvious
- **Version management**: Versions are managed via Git, with traceable history
- **Validation backstop**: Structured fields (name/description/llm/persona/principles) go through the ManageAgent built-in tool's allowlist + schema validation; invalid config is never written to disk
## L2: Detailed Specification
### Supported Update Types
| Update Type | Target | Update Method | Risk Level | Example |
| ----------------- | ------------------- | ------------------- | ---------- | ---------------------------------- |
| Name/Description | `agent.json` | ManageAgent update | Low/Medium | Rename, edit summary |
| LLM config | `agent.json` (llm) | ManageAgent update | Medium | Switch model, adjust temperature |
| Persona update | `persona.md` | ManageAgent update | Medium | Modify communication style, values |
| Principles update | `principles.md` | ManageAgent update | High | Add/modify behavioral rules |
| Skills install | `skills/` | Read/Write | Medium | Add new skill package |
| Skills uninstall | `skills/` | Read/Write | Low | Remove skill package |
| Memory update | `memory/` | Read/Write | Low | Add knowledge entry |
| Tools config | `tools/` | Read/Write | High | Modify tool permissions |
**Two update paths**: Structured fields (name/description/llm/persona/principles) are always updated through the `update` action of the in-process built-in tool **ManageAgent** (allowlist + schema validation + merge semantics); free-form files such as memory, skills, and tools are still edited directly with Read/Write. See "Stage 5: Apply Changes".
### Conversation Flow
```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 意图识别 │ ──→ │ 变更分析 │ ──→ │ Diff 生成 │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 回执生成 │ ←── │ 变更应用 │ ←── │ 用户确认 │
└──────────────┘ └──────────────┘ └──────────────┘
```
### Stage 1: Intent Recognition ### Stage 1: Intent Recognition
**Trigger conditions** (any one is sufficient): Trigger (any): user says "modify/update/adjust your …", "from now on you should… / remember this rule…", "install/uninstall this skill…", or describes dissatisfaction with current behavior and wants change. Identify the update type and target scope.
- The user says "modify your...", "update your...", "adjust the..."
- The user says "from now on you should...", "remember this rule..."
- The user says "install/uninstall this skill..."
- The user describes dissatisfaction with current behavior and expects a change
**Output**: Identify the update type and target scope.
### Stage 2: Change Analysis ### Stage 2: Change Analysis
**Analysis dimensions**: Assess impact (which files/behaviors), dependencies, and conflicts, and set a risk level → matching confirmation strength:
| Dimension | Description | - Low (non-core, e.g. memory entries): simple confirmation
| ------------------- | -------------------------------------------- | - Medium (persona / ordinary principles): show diff, then confirm
| Scope of impact | Which files and behaviors are affected | - High (core principles / tool permissions): detailed explanation + diff + confirm
| Risk level | Low/Medium/High (see risk classification) | - Protected (touches a protected path): block, requires owner permission
| Dependency check | Whether other configs are affected |
| Conflict detection | Whether it conflicts with existing rules |
**Risk classification table**:
| Risk Level | Conditions | Confirmation Requirement |
| ----------- | ------------------------------------------------ | ------------------------------------- |
| Low | Affects only non-core config (e.g. memory entry) | Simple confirmation |
| Medium | Affects persona or normal principles | Show diff, then confirm |
| High | Affects core principles or tool permissions | Detailed explanation + diff + confirm |
| Protected | Touches a protected path | Block; requires owner permission |
### Stage 3: Diff Generation ### Stage 3: Diff Generation
**Diff format example**: Generate a before/after diff for the user (show only the actual change), e.g.:
```diff ```diff
# persona.md # persona.md → ## Communication style
- friendly, easygoing, light humor
## 沟通风格 + professional, rigorous, measured humor
- 友好、随和、轻松幽默
+ 专业、严谨、适度幽默
## 决策偏好
保持不变...
```
**Diff metadata**:
```yaml
diff_metadata:
files_affected: 1
lines_added: 1
lines_removed: 1
risk_level: medium
reversible: true
estimated_impact: '沟通风格会变得更正式'
``` ```
### Stage 4: User Confirmation ### Stage 4: User Confirmation
**Confirmation interface**: Show the diff preview (affected file, risk level, impact note + diff) and ask the user to confirm "Apply / Cancel / Modify"; "Modify" enters fine-tuning then re-confirms. (The tool layer also enforces confirmation for updating other/core agents; see Stage 5.)
```
变更预览
影响文件: persona.md
风险等级: 中
影响说明: 沟通风格会从"友好随和"变为"专业严谨"
--- 变更内容 ---
[展示 diff]
----------------
请确认是否应用此变更?
[应用] [取消] [修改]
```
**Confirmation options**:
- **Apply**: Execute the change
- **Cancel**: Discard the change
- **Modify**: Enter edit mode for fine-tuning
### Stage 5: Apply Changes ### Stage 5: Apply Changes
Applying a change takes one of two paths, depending on whether the target is a **structured field** or a **free-form file**. **Do not call HTTP APIs** (after instance authentication, the Agent cannot reach the machine's local HTTP API), and **do not operate Git directly** (version management is handled automatically by the backend). Do not call the HTTP API (unreachable under instance auth), do not operate git directly (the backend auto-commits). Split by target into two paths:
#### Path A: Structured fields → ManageAgent built-in tool (mandatory) **Path A · Structured fields → ManageAgent (mandatory; never Write `agent.json` / `persona.md` / `principles.md` directly)**
The following fields **must** be updated through the `update` action of the in-process built-in tool `ManageAgent`. **Never** directly Write `agent.json` / `persona.md` / `principles.md`: Fields and constraints: `name` (150 chars), `description` (≤200), `config.llm` (shallow-merge delta, **config allows llm only**), `persona` / `principles` (structured object `{L0, L1:{...}, L2}` or markdown string). Calls:
| Field | Constraint | Storage location |
| ------------- | ----------------------------------------------------- | ----------------- |
| `name` | 150 characters | `agent.json` |
| `description` | ≤200 characters | `agent.json` |
| `config.llm` | Incremental shallow merge; **config only allows `llm`** | `agent.json` |
| `persona` | Structured object `{L0, L1:{...}, L2}` or markdown string | `persona.md` |
| `principles` | Structured object `{L0, L1:{...}, L2}` or markdown string | `principles.md` |
**Call forms**:
``` ```
ManageAgent(action='update', id='<agent-id>', name='New name') ManageAgent(action='update', id='<agent-id>', name='New Name')
ManageAgent(action='update', id='<agent-id>', description='One-line summary')
ManageAgent(action='update', id='<agent-id>', config={ llm: { model: 'xxx', temperature: 0.7 } })
ManageAgent(action='update', id='<agent-id>', persona={ L1: { personality: ["professional","rigorous"] } }) ManageAgent(action='update', id='<agent-id>', persona={ L1: { personality: ["professional","rigorous"] } })
ManageAgent(action='update', id='<agent-id>', principles='...(full markdown)...') ManageAgent(action='update', id='<agent-id>', principles='full markdown')
``` ```
**Merge semantics (important)**: **Merge semantics**: structured persona/principles are **field-level merges** (omitted fields keep their original values — passing only `L1.personality` won't clear L0/role); a markdown string is a **full replacement** (whole-file rewrite); `config.llm` is a **shallow-merge delta**. The merged result is validated against the whole schema; invalid config never lands.
- Structured `persona` / `principles` are **field-level merges**: omitted fields retain their original values (e.g. passing only `L1.personality` will not clear L0 / role) Key points:
- A markdown string is a **whole replacement** (used to rewrite the entire document)
- `config.llm` is an **incremental shallow merge**: only the keys you pass are overwritten
- The merged `agent.json` is validated against the schema as a whole; invalid config is never written to disk
**Confirmation behavior**: - **Read before write**: first `ManageAgent(action='get', id)` to fetch current values, for diff generation and field-name checking. Structured field names are fixed: persona's `L1.role` / `personality` (string array) / `communication_style`; principles' `L1.must_do` / `must_not` (string arrays) / `priority`; plus top-level `L0` / `L2`.
- **Confirmation and boundaries**: updating self skips the extra confirmation; updating another agent triggers user confirmation (on top of this skill's diff confirmation); the core agent (`desirecore` / `core`) is refused.
- **config whitelist**: `config` accepts only `llm`; `mcp_servers` / `tool_permissions` / `version` / `id` etc. are rejected with the field named — such runtime config does not go through ManageAgent; tell the user it currently needs the corresponding mechanism.
- **Partial write failure**: the tool reports exactly which fields landed / which failed; retry only the failed fields, don't resend everything.
- **Rename in one call**: to change the display name, call `ManageAgent(action='update', id, name='Y')` directly (writes agent.json and refreshes the list); if the persona doc title should match, append a persona update in the same turn. **Never claim a rename happened without actually calling ManageAgent.**
- Updating **yourself** requires no secondary confirmation **Path B · Free-form files → Read/Write** (`memory/` / `skills/` / `tools/`, root `${DESIRECORE_ROOT}/agents/<agentId>/`): Read current values, then Write/Edit, re-read after writing to confirm. Before editing, check `_protected-paths.yaml`; touching a protected path should be blocked with an owner-permission notice. After writing, the backend file watcher auto-commits — no manual git.
- Updating **another Agent** triggers user confirmation (stacked on top of this skill's diff confirmation)
- The core Agent (`desirecore` / `core`) refuses updates
**Read before you write**: Before making a change, read the current values with `ManageAgent(action='get', id='<agent-id>')`, to generate the diff and verify field names (the actual field names of persona / principles follow the structure returned by `get`). ### Stage 6: Receipt
**config allowlist**: `config` only accepts `llm`. Passing `mcp_servers` / `tool_permissions` / `version` / `id`, etc., is rejected with the field name indicated — runtime config other than `llm` does not go through ManageAgent; see "Stage 5 · Path B" and Error Handling. Present the change summary in a user-friendly way (no internal paths / technical details), and note the user can say "undo the last change" to roll back anytime.
**Partial write failure**: The tool reports precisely "which fields took effect, which one failed"; on retry, **submit only the failed fields**, do not resend everything. ### Version Rollback
> **Renaming is a single call.** When the user wants to change the **display name** (e.g. "rename X to Y"), just call `ManageAgent(action='update', id='<agent-id>', name='Y')` — `name` is written to `agent.json` and triggers the Agent list to refresh; no need to manually edit any other file. If the user also wants the persona document title synced, append one `persona` update in the same round. **Never claim the rename is done without actually calling ManageAgent.** Trigger: user says "undo / roll back / restore the previous settings". Flow:
#### Path B: Free-form files → edit directly with Read/Write 1. In the Agent directory, `git log --oneline -10` for history and `git show <commit>:<file>` for the target version content; show it to the user to confirm.
2. After confirmation, write back by type: structured fields (persona/principles, agent.json name/description/llm) → `ManageAgent(action='update', ...)` (persona/principles as a markdown string, **full replacement** with the historical content); free-form files (memory/skills) → Write directly.
3. Show the diff to confirm the rollback.
Free-form files such as memory, skills, and tools are not in ManageAgent's scope and are still edited directly with the Read/Write tools: (git is only for **reading** history; write-back always goes through the two paths above — never rewrite working-tree files with git commands.)
| Target | AgentFS path | ### Background and Error Handling
| ------------ | ------------ |
| Memory entry | `memory/` |
| Skill package | `skills/` |
| Tools config | `tools/` |
**AgentFS root directory**: `${DESIRECORE_ROOT}/agents/<agentId>/` - AgentFS structure and protected paths: see `_agentfs-background.md` and `_protected-paths.yaml`.
- On tool errors: non-whitelisted config field / schema validation failure / core-agent refusal → fix per the tool's hint or inform the user; protected path → block with an owner-permission notice; rollback version not found → list available versions and ask the user to reselect.
**Read file**: Use the Read tool to read the current contents of the target file.
**Write file**: Use the Write / Edit tool to write directly to the target file. After writing, re-read the file to verify the contents are correct.
**Protected paths**: Before editing, cross-check `_protected-paths.yaml`; touching a protected path should be blocked with a prompt that owner permission is required.
**Note**: After directly writing a free-form file, the backend file watcher automatically detects the change and triggers a Git commit; no manual git command is required.
### Stage 6: Receipt Generation
After a successful change, present a user-friendly receipt (do not expose internal paths or technical details):
> Updated the communication style of "Legal Advisor Assistant".
>
> **Change summary**: Communication style adjusted from "friendly and casual" to "professional and rigorous"
>
> If you're not satisfied, you can say "undo the previous change" anytime to roll back.
### Special Operation: Version Rollback
**Trigger conditions**: The user says "undo the previous change", "roll back to the previous version", "restore the original settings"
**Rollback flow**:
1. Run `git log --oneline -10` in the Agent directory to view recent version history
2. Use `git show <commit>:<file>` to fetch the file contents of the target version, and present them to the user for confirmation
3. After user confirmation, apply according to the target file type:
- **Structured fields** (`persona.md` / `principles.md` / the name/description/llm in `agent.json`) → write back with `ManageAgent(action='update', ...)` (persona / principles are **wholly replaced** with that historical content as a markdown string)
- **Free-form files** (`memory/` / `skills/`) → write back directly with the Write tool
4. Show the change diff and confirm rollback success
(`git log` / `git show` are only used to **read** history; write-back always goes through the two paths above — do not use git commands to directly rewrite working-tree files.)
```bash
# 查看版本历史
cd ${DESIRECORE_ROOT}/agents/<agentId>
git log --oneline -10
# 查看某个版本的文件内容
git show <commit>:persona.md
```
### Background Knowledge
> AgentFS repository structure and protected paths are detailed in `_agentfs-background.md` and `_protected-paths.yaml`.
**Update operation reference table**:
| User Intent | Update Method |
| ------------------------------- | ----------------------------------------------------------------------- |
| **Rename (display name)** | `ManageAgent(action='update', id, name='...')` |
| Edit summary | `ManageAgent(action='update', id, description='...')` |
| Modify LLM config (model/temperature/etc.) | `ManageAgent(action='update', id, config={ llm: {...} })` |
| Modify personality/style | `ManageAgent(action='update', id, persona={...} or markdown)` |
| Modify behavioral rules | `ManageAgent(action='update', id, principles={...} or markdown)` |
| Install/uninstall skills | Read/Write `skills/` (`${DESIRECORE_ROOT}/agents/<agentId>/skills/`) |
| Add memory | Read/Write `memory/` (`${DESIRECORE_ROOT}/agents/<agentId>/memory/`) |
| Modify tools config | Read/Write `tools/` (`${DESIRECORE_ROOT}/agents/<agentId>/tools/`, mind protected paths) |
> Runtime config in `agent.json` other than `llm` (`mcp_servers` / `tool_permissions`, etc.) is currently not in the ManageAgent allowlist, and should not be written to `agent.json` directly to bypass validation. When such a need arises, explain to the user that it must be handled through the corresponding mechanism for now.
### Error Handling
| Error Scenario | Handling |
| ------------------------------------- | ------------------------------------------------------------------- |
| `config` contains a non-allowlisted field | ManageAgent rejects it and indicates the field name; switch to the corresponding mechanism or tell the user it is not yet supported |
| Schema validation fails | Invalid config is not written to disk; fix the fields per the tool's response and retry |
| Updating the core Agent (desirecore/core) | ManageAgent refuses the update; tell the user the core Agent cannot be modified |
| Partial field write failure | The tool reports which fields took effect / failed; retry only the failed fields, do not resend everything |
| Attempt to modify a protected path (free-form file) | Block the operation; prompt that owner permission is required |
| File does not exist | The Agent or target file does not exist; ask the user to check |
| Insufficient permission | Filesystem permission error; ask the user to check directory permissions |
| Rollback target version not found | List available versions and ask the user to reselect |
### Permission Requirements
| Operation | Required Role |
| -------------------------------------- | -------------- |
| Update persona | owner, member |
| Update principles (normal rules) | owner, member |
| Update principles (safety red lines) | owner |
| Install/uninstall skills | owner, member |
| Modify tools permissions | owner |
| Version rollback | owner |
---
## Appendix: Update Examples
### Persona Modification Example
**User input**: "Speak a bit more formally, not too casual"
**Operation flow**:
```
# 1. 读取当前 persona定位要改的字段字段名以返回结构为准
ManageAgent(action='get', id='legal-assistant')
# 返回中的 "## persona.md" 段落即当前 persona 原文L0/L1/L2 分层 markdown例如:
# ## persona.md
# # L0
# 专业的法律咨询助手
# # L1
# ## role
# 法律顾问
# ## personality
# - 友好
# - 随和
# ## communication_style
# 轻松幽默
# 2. 分析需要修改的部分,生成 diff 展示给用户确认
# 3. 用户确认后,用 ManageAgent 字段级合并更新只改这两个字段L0/role 保留)
ManageAgent(action='update', id='legal-assistant', persona={
L1: { personality: ["专业", "严谨"], communication_style: '正式、克制' }
})
# 4. 复核结果
ManageAgent(action='get', id='legal-assistant')
```
---
### Principles Update Example
### Add New Rule
**User input**: "From now on, when there's a legal issue, remind me to consult a professional lawyer"
**Generated diff**:
```diff
# principles.md
## 必须做
- 始终保持礼貌和尊重
- 不确定时主动询问
+ - 遇到法律相关问题时,提醒用户咨询专业律师
## 绝不做
...
```
**Apply after user confirmation**: First read the current principles with `ManageAgent(action='get', id)`, then replace the whole document (including the new rule) as a markdown string:
```
ManageAgent(action='update', id='legal-assistant', principles='...(full markdown, including the new rule)...')
```
(To change just one structured field, you can also pass a field-level merge such as `principles={ L1: { must_do: [...] } }`. The structured field names are fixed: persona uses `L1.role` / `L1.personality` (string array) / `L1.communication_style`; principles uses `L1.must_do` / `L1.must_not` (both string arrays) / `L1.priority`; plus top-level `L0` / `L2` strings.)
### Modify Existing Rule
**User input**: "Don't remind me every time, it's too verbose"
**Generated diff**:
```diff
# principles.md
## 必须做
- - 每次回答后都提醒用户检查内容
+ - 仅在重要决策时提醒用户检查内容
```
**Apply after user confirmation**: Same as above — write the modified content back with `ManageAgent(action='update', id, principles=...)`.

View File

@@ -6,367 +6,97 @@
通过自然语言对话,安全地修改 Agent 的配置、人格、规则和技能。 通过自然语言对话,安全地修改 Agent 的配置、人格、规则和技能。
## L1概述与使用场景 ## L1概述
### 能力描述 元技能:识别修改意图 → 生成可审阅 diff → 用户确认 → 应用(结构化字段走 ManageAgent、自由文件走 Read/Write→ 回执并支持版本回滚。价值在工具给不了的部分diff 预览确认、两路径编排、回滚;结构化字段经 ManageAgent 白名单 + schema 校验,非法配置不落盘。
update-agent 是一个**元技能Meta-Skill**,允许用户通过对话方式修改 Agent 的各项配置。所有修改都会生成可审阅的 diff 补丁,经用户确认后才会应用,并支持版本回滚。
### 使用场景
- 用户想要调整 Agent 的沟通风格("说话再正式一点"
- 需要添加新的行为规则("以后遇到敏感话题要先提醒我"
- 安装或卸载技能包("学会写合同吧"
- 批量更新多项配置("全面升级一下你的能力"
### 核心价值
- **安全可控**:所有变更需用户确认,支持回滚
- **透明可见**:变更以 diff 形式展示,清晰明了
- **版本管理**:通过 Git 管理版本,可追溯历史
- **校验兜底**结构化字段name/description/llm/persona/principles经 ManageAgent 内置工具的白名单 + schema 校验,非法配置不会落盘
## L2详细规范 ## L2详细规范
### 支持的更新类型 ### 更新类型与两条路径
| 更新类型 | 目标 | 更新手段 | 风险等级 | 示例 | 结构化字段一律经 `ManageAgent(action='update')`(白名单 + 校验 + 合并语义);记忆/技能/工具等自由格式文件用 Read/Write 直接编辑:
| --------------- | --------------- | ------------------- | -------- | -------------------- |
| 名称/描述 | `agent.json` | ManageAgent update | 低/中 | 改名、改简介 |
| LLM 配置 | `agent.json`llm | ManageAgent update | 中 | 换模型、调温度 |
| Persona 更新 | `persona.md` | ManageAgent update | 中 | 修改沟通风格、价值观 |
| Principles 更新 | `principles.md` | ManageAgent update | 高 | 添加/修改行为规则 |
| Skills 安装 | `skills/` | Read/Write | 中 | 添加新技能包 |
| Skills 卸载 | `skills/` | Read/Write | 低 | 移除技能包 |
| Memory 更新 | `memory/` | Read/Write | 低 | 添加知识条目 |
| Tools 配置 | `tools/` | Read/Write | 高 | 修改工具权限 |
**两条更新路径**结构化字段name/description/llm/persona/principles一律经进程内内置工具 **ManageAgent**`update` 动作更新(白名单 + schema 校验 + 合并语义);记忆、技能、工具等自由格式文件仍用 Read/Write 直接编辑。详见「阶段 5变更应用」。 | 用户意图 | 手段 | 目标(风险) |
| --- | --- | --- |
| 改名(显示名称) | `ManageAgent(update, name=...)` | agent.json |
| 改简介 | `ManageAgent(update, description=...)` | agent.json |
| LLM 配置(模型/温度) | `ManageAgent(update, config={llm:{...}})` | agent.json |
| 性格/风格 | `ManageAgent(update, persona=... 或 markdown)` | persona.md |
| 行为规则 | `ManageAgent(update, principles=... 或 markdown)` | principles.md |
| 安装/卸载技能 | Read/Write | `skills/`(低/中) |
| 添加记忆 | Read/Write | `memory/`(低) |
| 修改工具配置 | Read/Write | `tools/`(高,注意受保护路径) |
### 对话流程 流程:意图识别 → 变更分析 → diff 生成 → 用户确认 → 应用 → 回执。
```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 意图识别 │ ──→ │ 变更分析 │ ──→ │ Diff 生成 │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ 回执生成 │ ←── │ 变更应用 │ ←── │ 用户确认 │
└──────────────┘ └──────────────┘ └──────────────┘
```
### 阶段 1意图识别 ### 阶段 1意图识别
**触发条件**(任一满足): 触发(任一):用户说"修改/更新/调整你的…"、"你以后要…/记住这个规则…"、"安装/卸载这个技能…",或描述对当前行为的不满并期望改变。识别更新类型与目标范围。
- 用户说"修改你的..."、"更新你的..."、"调整一下..."
- 用户说"你以后要..."、"记住这个规则..."
- 用户说"安装/卸载这个技能..."
- 用户描述对当前行为的不满并期望改变
**输出**:识别更新类型和目标范围。
### 阶段 2变更分析 ### 阶段 2变更分析
**分析维度** 评估影响范围(哪些文件/行为)、依赖与冲突,并定风险等级 → 对应确认强度
| 维度 | 说明 | - 低(记忆条目等非核心):简单确认
| -------- | ------------------------ | -persona / 普通 principles展示 diff 后确认
| 影响范围 | 影响哪些文件、哪些行为 | - 高(核心 principles / 工具权限):详细说明 + diff + 确认
| 风险等级 | 低/中/高(见风险分级表) | - 受保护(触及受保护路径):阻断,需 owner 权限
| 依赖检查 | 是否影响其他配置 |
| 冲突检测 | 是否与现有规则冲突 |
**风险分级表** ### 阶段 3diff 生成
| 风险等级 | 条件 | 确认要求 | 生成变更前后 diff 展示给用户(只展示实际改动),例如:
| -------- | ------------------------------ | ---------------------- |
| 低 | 仅影响非核心配置(如记忆条目) | 简单确认 |
| 中 | 影响 persona 或普通 principles | 展示 diff 后确认 |
| 高 | 影响核心 principles 或工具权限 | 详细说明 + diff + 确认 |
| 受保护 | 触及受保护路径 | 阻断,需 owner 权限 |
### 阶段 3Diff 生成
**Diff 格式示例**
```diff ```diff
# persona.md # persona.md → ## 沟通风格
## 沟通风格
- 友好、随和、轻松幽默 - 友好、随和、轻松幽默
+ 专业、严谨、适度幽默 + 专业、严谨、适度幽默
## 决策偏好
保持不变...
```
**Diff 元数据**
```yaml
diff_metadata:
files_affected: 1
lines_added: 1
lines_removed: 1
risk_level: medium
reversible: true
estimated_impact: '沟通风格会变得更正式'
``` ```
### 阶段 4用户确认 ### 阶段 4用户确认
**确认界面** 展示 diff 预览(影响文件、风险等级、影响说明 + diff请用户确认「应用 / 取消 / 修改」;选"修改"进入微调后再确认。(工具层对更新他人/核心体另有强制确认,见阶段 5。
```
变更预览
影响文件: persona.md
风险等级: 中
影响说明: 沟通风格会从"友好随和"变为"专业严谨"
--- 变更内容 ---
[展示 diff]
----------------
请确认是否应用此变更?
[应用] [取消] [修改]
```
**确认选项**
- **应用**:执行变更
- **取消**:放弃变更
- **修改**:进入编辑模式微调
### 阶段 5变更应用 ### 阶段 5变更应用
变更应用分两条路径,取决于目标是**结构化字段**还是**自由格式文件**。**不要调 HTTP API**(实例鉴权后 Agent 无法访问本机 HTTP API**不要直接操作 Git**(版本管理由后端自动处理)。 不要调 HTTP API实例鉴权后不可达),不要直接操作 git(后端自动提交)。按目标分两路:
#### 路径 A结构化字段 → ManageAgent 内置工具(强制) **路径 A · 结构化字段 → ManageAgent(强制;禁止直接 Write `agent.json` / `persona.md` / `principles.md`**
以下字段**必须**通过进程内内置工具 `ManageAgent``update` 动作更新,**禁止**直接 Write `agent.json` / `persona.md` / `principles.md` 字段与约束:`name`150 字符)、`description`≤200`config.llm`(增量浅合并,**config 仅允许 llm**)、`persona` / `principles`(结构化对象 `{L0, L1:{...}, L2}` 或 markdown 字符串)。调用
| 字段 | 约束 | 落地位置 |
| ------------- | -------------------------------------- | ----------------- |
| `name` | 150 字符 | `agent.json` |
| `description` | ≤200 字符 | `agent.json` |
| `config.llm` | 增量浅合并;**config 只允许 `llm`** | `agent.json` |
| `persona` | 结构化对象 `{L0, L1:{...}, L2}` 或 markdown 字符串 | `persona.md` |
| `principles` | 结构化对象 `{L0, L1:{...}, L2}` 或 markdown 字符串 | `principles.md` |
**调用形式**
``` ```
ManageAgent(action='update', id='<agent-id>', name='新名称') ManageAgent(action='update', id='<agent-id>', name='新名称')
ManageAgent(action='update', id='<agent-id>', description='一句话简介')
ManageAgent(action='update', id='<agent-id>', config={ llm: { model: 'xxx', temperature: 0.7 } })
ManageAgent(action='update', id='<agent-id>', persona={ L1: { personality: ["专业","严谨"] } }) ManageAgent(action='update', id='<agent-id>', persona={ L1: { personality: ["专业","严谨"] } })
ManageAgent(action='update', id='<agent-id>', principles='...完整 markdown...') ManageAgent(action='update', id='<agent-id>', principles='完整 markdown')
``` ```
**合并语义(重要)** **合并语义**结构化 persona/principles 为**字段级合并**(省略字段保留原值,如只传 `L1.personality` 不会清掉 L0/rolemarkdown 字符串为**整体替换**(整篇重写);`config.llm` 为**增量浅合并**。合并结果整体过 schema 校验,非法配置不落盘。
- 结构化 `persona` / `principles` 是**字段级合并**:省略的字段保留原值(如只传 `L1.personality` 不会清掉 L0 / role 要点:
- markdown 字符串是**整体替换**(用于整篇重写)
- `config.llm` 是**增量浅合并**:只覆盖你传入的 key
- 合并后的 `agent.json` 会整体过 schema 校验,非法配置不落盘
**确认行为** - **改前先读**:先 `ManageAgent(action='get', id)` 取现值,用于生成 diff、校对字段名。结构化字段名固定persona 的 `L1.role` / `personality`(字符串数组)/ `communication_style`principles 的 `L1.must_do` / `must_not`(字符串数组)/ `priority`,加顶层 `L0` / `L2`
- **确认与边界**:更新自身免二次确认;更新其他智能体触发用户确认(与本技能 diff 确认叠加);核心智能体(`desirecore` / `core`)拒绝更新。
- **config 白名单**`config` 仅接受 `llm``mcp_servers` / `tool_permissions` / `version` / `id` 等会被拒并指明字段名——这类运行时配置不走 ManageAgent向用户说明暂需经对应机制处理。
- **部分写入失败**:工具精确报告已生效/失败字段,仅重试失败字段,不整体重发。
- **改名一次调用完成**:用户要改显示名称时直接 `ManageAgent(action='update', id, name='Y')`(写 agent.json 并刷新列表),如需人格文档标题同步可同轮追加 persona 更新。**绝不在未实际调用 ManageAgent 时声称已改名。**
- 更新**自身**免二次确认 **路径 B · 自由格式文件 → Read/Write**`memory/` / `skills/` / `tools/`,根 `${DESIRECORE_ROOT}/agents/<agentId>/`):先 Read 现值,再 Write/Edit写后重读确认。编辑前对照 `_protected-paths.yaml`,触及受保护路径应阻断并提示需 owner 权限。写入后后端文件监控自动 git 提交,无需手动 git。
- 更新**其他智能体**会触发用户确认(与本技能的 diff 确认叠加)
- 核心智能体(`desirecore` / `core`)拒绝更新
**改前先读**:改之前先用 `ManageAgent(action='get', id='<agent-id>')` 读取现值,用于生成 diff、校对字段名persona / principles 的实际字段名以 `get` 返回的结构为准)。 ### 阶段 6回执
**config 白名单**`config` 仅接受 `llm`。传入 `mcp_servers` / `tool_permissions` / `version` / `id` 等会被拒绝并指明字段名——`llm` 以外的运行时配置不走 ManageAgent见「阶段 5 · 路径 B」与错误处理 以用户友好方式呈现变更摘要(不暴露内部路径/技术细节),并告知可随时说"撤销刚才的修改"回滚
**部分写入失败**:工具会精确报告"哪些字段已生效、哪个失败",重试时**只提交失败字段**,不要整体重发。 ### 版本回滚
> **改名一次调用完成。** 用户要改**显示名称**(如"把 X 改名为 Y")时,直接 `ManageAgent(action='update', id='<agent-id>', name='Y')` 即可——`name` 写入 `agent.json` 并触发智能体列表刷新,无需再手动编辑任何文件。若用户希望人格文档标题也同步,可在同一轮追加一次 `persona` 更新。**绝不要在没有实际调用 ManageAgent 的情况下声称已改名。** 触发:用户说"撤销/回滚/恢复原来的设置"。流程:
#### 路径 B自由格式文件 → Read/Write 直接编辑 1. Agent 目录下 `git log --oneline -10` 看历史、`git show <commit>:<file>` 取目标版本内容,展示给用户确认。
2. 确认后按类型回写结构化字段persona/principles、agent.json 的 name/description/llm`ManageAgent(action='update', ...)`persona/principles 以 markdown 字符串**整体替换**为历史内容自由文件memory/skills→ Write 直接写回。
3. 展示 diff 确认回滚成功。
记忆、技能、工具等**自由格式文件**不在 ManageAgent 范围,仍用 Read/Write 工具直接编辑: git 仅用于**读**历史,回写一律走上述两路径,不要用 git 命令直接改工作区文件。)
| 目标 | AgentFS 路径 | ### 背景与错误处理
| -------- | ------------ |
| 记忆条目 | `memory/` |
| 技能包 | `skills/` |
| 工具配置 | `tools/` |
**AgentFS 根目录**`${DESIRECORE_ROOT}/agents/<agentId>/` - AgentFS 结构、受保护路径详见 `_agentfs-background.md``_protected-paths.yaml`
- 工具报错时config 非白名单字段 / schema 校验失败 / 核心体拒绝 → 按工具提示修正或告知用户;受保护路径 → 阻断并提示需 owner回滚版本不存在 → 列出可用版本请用户重选。
**读取文件**:使用 Read 工具读取目标文件当前内容。
**写入文件**:使用 Write / Edit 工具直接写入目标文件。写入后重新读取文件确认内容正确。
**受保护路径**:编辑前对照 `_protected-paths.yaml`,触及受保护路径应阻断并提示需 owner 权限。
**注意**:直接写入自由格式文件后,后端文件监控会自动检测变更并触发 Git 提交,无需手动执行 git 命令。
### 阶段 6回执生成
创建成功后,以用户友好的方式呈现回执(不要暴露内部路径或技术细节):
> 已更新「法律顾问小助手」的沟通风格。
>
> **变更摘要**:沟通风格从"友好随和"调整为"专业严谨"
>
> 如果不满意,可以随时说"撤销刚才的修改"来回滚。
### 特殊操作:版本回滚
**触发条件**:用户说"撤销刚才的修改"、"回滚到之前的版本"、"恢复原来的设置"
**回滚流程**
1. 在 Agent 目录下执行 `git log --oneline -10` 查看最近的版本历史
2. 使用 `git show <commit>:<file>` 获取目标版本的文件内容,展示给用户确认
3. 用户确认后,按目标文件类型应用:
- **结构化字段**`persona.md` / `principles.md` / `agent.json` 的 name/description/llm→ 用 `ManageAgent(action='update', ...)` 写回persona / principles 以 markdown 字符串**整体替换**为该历史内容)
- **自由格式文件**`memory/` / `skills/`)→ 用 Write 工具直接写回
4. 展示变更 diff确认回滚成功
`git log` / `git show` 仅用于**读取**历史,回写一律走上述两条路径,不要用 git 命令直接改写工作区文件。)
```bash
# 查看版本历史
cd ${DESIRECORE_ROOT}/agents/<agentId>
git log --oneline -10
# 查看某个版本的文件内容
git show <commit>:persona.md
```
### 背景知识
> AgentFS 仓库结构与受保护路径详见 `_agentfs-background.md` 和 `_protected-paths.yaml`。
**更新操作对照表**
| 用户意图 | 更新手段 |
| --------------------- | ------------------------------------------------------------------------ |
| **改名(显示名称)** | `ManageAgent(action='update', id, name='...')` |
| 改简介 | `ManageAgent(action='update', id, description='...')` |
| 修改 LLM 配置(模型/温度等) | `ManageAgent(action='update', id, config={ llm: {...} })` |
| 修改性格/风格 | `ManageAgent(action='update', id, persona={...} 或 markdown)` |
| 修改行为规则 | `ManageAgent(action='update', id, principles={...} 或 markdown)` |
| 安装/卸载技能 | Read/Write `skills/``${DESIRECORE_ROOT}/agents/<agentId>/skills/` |
| 添加记忆 | Read/Write `memory/``${DESIRECORE_ROOT}/agents/<agentId>/memory/` |
| 修改工具配置 | Read/Write `tools/``${DESIRECORE_ROOT}/agents/<agentId>/tools/`,注意受保护路径) |
> `agent.json` 中 `llm` 以外的运行时配置(`mcp_servers` / `tool_permissions` 等)当前不在 ManageAgent 白名单,也不应直接 Write `agent.json` 绕过校验。遇到此类需求,向用户说明暂需通过对应机制处理。
### 错误处理
| 错误场景 | 处理方式 |
| ---------------------------- | ---------------------------------------------------------- |
| `config` 含非白名单字段 | ManageAgent 拒绝并指明字段名;改走对应机制或告知用户暂不支持 |
| schema 校验失败 | 非法配置不落盘;按工具返回修正字段后重试 |
| 更新核心智能体desirecore/core | ManageAgent 拒绝更新;告知用户核心智能体不可修改 |
| 部分字段写入失败 | 工具报告已生效/失败字段;仅重试失败字段,不整体重发 |
| 尝试修改受保护路径(自由文件) | 阻断操作,提示需要 owner 权限 |
| 文件不存在 | Agent 或目标文件不存在,提示用户检查 |
| 权限不足 | 文件系统权限错误,提示用户检查目录权限 |
| 回滚版本不存在 | 列出可用版本,请用户重新选择 |
### 权限要求
| 操作 | 所需角色 |
| --------------------------- | ------------- |
| 更新 persona | owner, member |
| 更新 principles普通规则 | owner, member |
| 更新 principles安全红线 | owner |
| 安装/卸载 skills | owner, member |
| 修改 tools 权限 | owner |
| 版本回滚 | owner |
---
## 附录:更新示例
### Persona 修改示例
**用户输入**"说话再正式一点,不要太随意"
**操作流程**
```
# 1. 读取当前 persona定位要改的字段字段名以返回结构为准
ManageAgent(action='get', id='legal-assistant')
# 返回中的 "## persona.md" 段落即当前 persona 原文L0/L1/L2 分层 markdown例如:
# ## persona.md
# # L0
# 专业的法律咨询助手
# # L1
# ## role
# 法律顾问
# ## personality
# - 友好
# - 随和
# ## communication_style
# 轻松幽默
# 2. 分析需要修改的部分,生成 diff 展示给用户确认
# 3. 用户确认后,用 ManageAgent 字段级合并更新只改这两个字段L0/role 保留)
ManageAgent(action='update', id='legal-assistant', persona={
L1: { personality: ["专业", "严谨"], communication_style: '正式、克制' }
})
# 4. 复核结果
ManageAgent(action='get', id='legal-assistant')
```
---
### Principles 更新示例
### 添加新规则
**用户输入**"以后遇到法律问题,先提醒我找专业律师"
**生成的 Diff**
```diff
# principles.md
## 必须做
- 始终保持礼貌和尊重
- 不确定时主动询问
+ - 遇到法律相关问题时,提醒用户咨询专业律师
## 绝不做
...
```
**用户确认后应用**:先 `ManageAgent(action='get', id)` 取当前 principles把整篇内容含新增规则以 markdown 字符串整体替换:
```
ManageAgent(action='update', id='legal-assistant', principles='...(整篇 markdown含新增规则...')
```
(若只改结构化对象的某个字段,也可用字段级合并传 `principles={ L1: { must_do: [...] } }`。结构化字段名固定为persona 的 `L1.role` / `L1.personality`(字符串数组)/ `L1.communication_style`principles 的 `L1.must_do` / `L1.must_not`(均为字符串数组)/ `L1.priority`,另有顶层 `L0` / `L2` 字符串。)
### 修改现有规则
**用户输入**"不要每次都提醒我,太啰嗦了"
**生成的 Diff**
```diff
# principles.md
## 必须做
- - 每次回答后都提醒用户检查内容
+ - 仅在重要决策时提醒用户检查内容
```
**用户确认后应用**:同上,用 `ManageAgent(action='update', id, principles=...)` 写回修改后的内容。