mod-tools
Tools 模块知识库。修改 tools/*.go 时自动激活。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Tools 模块知识库。修改 tools/*.go 时自动激活。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Manage SubAgent roles: create, view, modify, delete, or install agent definitions. MUST activate when user asks to create/edit/view/inspect any agent, install agents from external sources, or when you need to look at agent files under ~/.xbot/agents/. Agents are universal — install whatever the user needs.
Create, modify, and manage xbot plugins. Use when the user asks to create a plugin, set up script plugins, configure widgets, register custom tools via plugins, or create channel plugins.
Create, update, delete, or install skills. Use when the user asks to create a new skill, modify an existing skill, install/import a skill from external sources (GitHub, URLs), package scripts/assets into a skill, or discusses skill design and structure. Skills are universal agent capabilities — install whatever the user wants.
Guide for AI to configure xbot TUI, themes, subscriptions, and settings. Activate when the user asks to customize the TUI appearance, create themes, manage LLM subscriptions, or make bulk configuration changes.
Build implementation plans for complex tasks. Use when the user asks to plan, design an approach, or think through a task before coding. Also activate for large refactorings, multi-file changes, or when the user says 'plan first' or '/plan'.
Post-development cleanup: update AGENTS.md and docs/agent/ knowledge files to reflect code changes. MUST activate before git commit (or when user asks to commit/push). Also activate after any code modification that adds/removes files, changes architecture, or modifies core behavior.
| name | mod-tools |
| description | Tools 模块知识库。修改 tools/*.go 时自动激活。 |
| user-invokable | true |
tools/ 目录实现 Agent 可调用的工具集,遵循统一的 Tool 接口:
type Tool interface {
Name() string
Description() string
Parameters() []llm.ToolParam
Execute(toolCtx *ToolContext, input string) (*ToolResult, error)
}
工具通过 DefaultRegistry() 注册,Agent 在运行时查找并调用。
| 文件 | 功能 |
|---|---|
interface.go | Tool 接口定义、Registry、ToolContext、ToolResult |
mcp.go | MCP 管理器、远程工具适配 |
mcp_common.go | MCP 公共函数(连接、配置加载) |
session_mcp.go | 会话级 MCP 管理(懒加载、超时卸载) |
feishu_mcp/*.go | 飞书 MCP 工具封装 |
type ToolResult struct {
Summary string // 精简结果,进入 LLM 上下文
Detail string // 详细内容,仅前端展示
Tips string // 操作指引,帮助 LLM 理解下一步
WaitingUser bool // 是否等待用户响应
}
辅助函数:
NewResult(content) - 创建简单结果NewResultWithDetail(summary, detail) - 创建带详情的结果NewResultWithTips(summary, tips) - 创建带指引的结果NewResultWithUserResponse(summary) - 创建等待用户响应的结果type ToolContext struct {
Ctx context.Context
WorkingDir string
Channel, ChatID, SenderID, SenderName string
SendFunc func(channel, chatID, content string) error
Registry *Registry
// ... 其他字段
}
Tips 字段中NewResult() 或 NewResultWithTips()Tips 字段告诉 LLM 下一步可以做什么error 传递,由 Agent 统一处理xxx.feishu.cn)Client.BuildURL(token, objType) 构建完整 URLFeishuMCP → OAuth Manager → FeishuProvider → Lark Client
↓
Token.Raw["tenant_domain"] ← 自动获取企业域名
type Client struct {
lark *lark.Client
accessToken string
tenantDomain string // 企业域名,如 "example.feishu.cn"
}
// 构建完整 URL
func (c *Client) BuildURL(token, objType string) string
| 前缀 | 类型 |
|---|---|
wikcn | wiki |
doxcn | docx |
basc | bitable |
shtcn | sheet |
ndtbn | mindnote |
pptcn | slides |
filcn | file |
在 oauth/providers/feishu.go 中,OAuth 授权成功后自动调用:
resp, err := p.client.Tenant.V2.Tenant.Query(ctx, larkcore.WithUserAccessToken(accessToken))
// 存储到 token.Raw["tenant_domain"]
问题:在 Description 中写步骤指引,浪费 LLM context
解决:Description 只写功能描述,操作指引放 Tips 字段
问题:使用 xxx.feishu.cn 会导致 LLM 输出无效 URL
解决:使用 client.BuildURL() 构建真实 URL
问题:实现了 Tool 接口但未注册
解决:在 main.go 中调用 agentLoop.RegisterTool()