mod-tools
Tools 模块知识库。修改 tools/*.go 时自动激活。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Tools 模块知识库。修改 tools/*.go 时自动激活。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Debug xbot TUI and remote mode issues. Launches isolated CLI client (and optionally server) with --debug flags, auto-input key sequences, and periodic UI captures. Activate when you need to reproduce, diagnose, or verify TUI bugs (spinner freeze, key event delay, cancel flow, render issues) or end-to-end remote mode issues.
Manage SubAgent roles: create, view, modify, or delete agent definitions. MUST activate when user asks to create/edit/view/inspect any agent, or when you need to look at agent files under ~/.xbot/agents/.
Investigate and fix bugs. Use when the user reports a bug, failing behavior, regression, flaky case, crash, panic, incorrect output, or asks to debug an issue.
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 AGENT.md and 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.
Create, update, or delete skills. Use when the user asks to create a new skill, modify an existing skill, package scripts/assets into a skill, or discusses skill design and structure.
| 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()