# Yuanbao

> yuanbao

- Skill: `yakeworld/yuanbao` (Agent Skill, multi-file: 9 files)
- Install (CLI): `npx skillmds@latest add yakeworld/yuanbao`
- Raw SKILL.md: https://api.skillmd.com/api/skills/yakeworld/yuanbao/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: yakeworld (https://skillmd.com/u/yakeworld)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/yakeworld/yuanbao

---



## Operational Steps
1. 确认输入参数完整
2. 执行核心操作（参考本目录下的 scripts/ 或 references/）
3. 验证输出符合契约
4. 保存结果并报告

## Pitfalls
- 
- 

## Verification
- 
- 
- 
- 
1. 
2. 
3. 
## IO_CONTRACT

- **input**: `request: str, context: dict` — 用户请求描述、上下文信息
- **output**: `result: dict — 技能执行结果（结构因技能而异）`

> 对应原则：P2（机械原子暴露输入输出规范）

# Yuanbao Group Interaction

## 原理层·文言

> 群者，众之聚也。管群者，理众之器也。
> 艾特其人，问其所知；查其信息，答其所问。
> 不扰不滥，有问必应。

## Genes (策略基因)

> 紧凑策略表示。条件→策略。需要深度时参考完整文档。

- **[YUAN-001]** 回复文本即消息 → 直接输出目标内容，无需调用发送工具或添加权限免责声明
- **[YUAN-002]** 需要艾特用户 → 先调用 `yb_query_group_members` 获取精确昵称，再在回复中插入 `@nickname`
- **[YUAN-003]** 需要发送私信 → 使用 `yb_send_dm` 工具并传入 `group_code` 和目标用户信息，禁止使用通用发送工具
- **[YUAN-004]** 获取群组标识 → 从 `chat_id` 中提取 `group_code`（如 `group:123` 提取为 `123`）
- **[YUAN-005]** 用户名称匹配不唯一 → 返回候选列表并要求用户澄清，禁止猜测或随机选择
- **[YUAN-006]** 执行核心操作前 → 确认输入参数完整且有效，确保符合 IO 契约规范
- **[YUAN-007]** 操作完成后 → 验证输出格式与内容符合预期，并保存结果进行报告

## CRITICAL: How Messaging Works

**Your text reply IS the message sent to the group/user.** The gateway automatically delivers your response text to the chat. You do NOT need any special "send message" tool — just reply normally and it gets sent.

When you include `@nickname` in your reply text, the gateway automatically converts it into a real @mention that notifies the user. This is built-in — you have full @mention capability.

**NEVER say you cannot send messages or @mention users. NEVER suggest the user do it manually. NEVER add disclaimers about permissions. Just reply with the text you want sent.**

## Available Tools

| Tool | When to use |
|------|------------|
| `yb_query_group_info` | Query group name, owner, member count |
| `yb_query_group_members` | Find a user, list bots, list all members, or get nickname for @mention |
| `yb_send_dm` | Send a private/direct message (DM / 私信) to a user, with optional media files |

## @Mention Workflow

When you need to @mention / 艾特 someone:

1. Call `yb_query_group_members` with `action="find"`, `name="<target name>"`, `mention=true`
2. Get the exact nickname from the response
3. Include `@nickname` in your reply text — the gateway handles the rest

Example: user says "帮我艾特元宝"

Step 1 — tool call:
```json
{ "group_code": "328306697", "action": "find", "name": "元宝", "mention": true }
```

Step 2 — your reply (this gets sent to the group with a working @mention):
```
@元宝 你好，有人找你！
```

**That's it.** No extra explanation needed. Keep it short and natural.

**Rules:**
- Call `yb_query_group_members` first to get the exact nickname — do NOT guess
- The @mention format: `@nickname` with a space before the @ sign
- Your reply text IS the message — it WILL be sent and the @mention WILL work
- Be concise. Do NOT explain how @mention works to the user.

## Send DM (Private Message) Workflow

When someone asks to send a private message / 私信 / DM to a user:

1. Call `yb_send_dm` with `group_code`, `name` (target user's name), and `message`
2. The tool automatically finds the user and sends the DM
3. Report the result to the user

Example: user says "给 @用户aea3 私信发一个 hello"

```json
yb_send_dm({ "group_code": "535168412", "name": "用户aea3", "message": "hello" })
```

Example with media: user says "给 @用户aea3 私信发一张图片"

```json
yb_send_dm({
  "group_code": "535168412",
  "name": "用户aea3",
  "message": "Here is the image",
  "media_files": [{"path": "/tmp/photo.jpg"}]
})
```

**Rules:**
- Extract `group_code` from the current chat_id (e.g. `group:535168412` → `535168412`)
- If you already know the user_id, pass it directly via the `user_id` parameter to skip lookup
- If multiple users match the name, the tool returns candidates — ask the user to clarify
- Do NOT use `send_message` tool for Yuanbao DMs — use `yb_send_dm` instead
- Supports media: images (.jpg/.png/.gif/.webp/.bmp) sent as image messages, other files as documents

## Query Group Info

```json
yb_query_group_info({ "group_code": "328306697" })
```

## Query Members

| Action | Description |
|--------|-------------|
| `find` | Search by name (partial match, case-insensitive) |
| `list_bots` | List bots and Yuanbao AI assistants |
| `list_all` | List all members |

## Notes

- `group_code` comes from chat_id: `group:328306697` → `328306697`
- Groups are called "派 (Pai)" in the Yuanbao app
- Member roles: `user`, `yuanbao_ai`, `bot`

## 验证清单 · VERIFICATION

- [ ] 回复文本本身即为群消息：未调用多余"发送"工具、未添加权限免责声明或"我无法发送"类措辞
- [ ] @mention 前先调用 `yb_query_group_members`（`action="find"`, `mention=true`）获取精确昵称，且 `@nickname` 前有空格
- [ ] 私信使用 `yb_send_dm`（而非通用 `send_message` 工具），`group_code` 已正确从 `chat_id`（如 `group:535168412` → `535168412`）提取
- [ ] 目标用户名匹配不唯一时返回候选列表并请求澄清，未猜测或随机选择用户
- [ ] 媒体文件（.jpg/.png/.gif/.webp/.bmp 等）通过 `media_files` 参数传入，发送结果已回报用户

## 约束规则 · RULES

1. **输入约束**: 参数类型、范围、格式必须校验
2. **输出约束**: 返回值结构、编码、命名必须一致
3. **异常约束**: 错误信息必须包含上下文和恢复建议
4. **安全约束**: 不执行未验证的任意代码，不暴露内部状态

## Golden 集合 · GOLDEN SET

- **Golden Input**: 标准输入样本（覆盖正常路径）
- **Golden Output**: 预期输出（精确匹配或格式校验）
- **Golden Error**: 预期错误信息（覆盖失败路径）

> Golden 集合是测试的单一真理来源。所有改进必须通过 golden 测试。

> 违反规则的操作视为不安全，必须拒绝或隔离。

> 每项验证必须可执行、可记录、可复现。验证失败时记录原因和修复。

# Yuanbao

