Skip to content

[agent] feat: Skills 支持(per-user MinIO 懒加载 + GitHub skill store + 客户端商店)#40

Merged
atoncooper merged 4 commits into
mainfrom
feat/agent-skills
Jul 24, 2026
Merged

[agent] feat: Skills 支持(per-user MinIO 懒加载 + GitHub skill store + 客户端商店)#40
atoncooper merged 4 commits into
mainfrom
feat/agent-skills

Conversation

@atoncooper

Copy link
Copy Markdown
Owner

背景

完善 agent 能力:支持 Skills(指令包 + 工具混合),agent 按需加载技能扩展能力。skill 不落本地存 MinIO;来源是 GitHub repo 搜索(关键词 + topic 市场)。

核心设计

存储(不落本地)

  • skill zip 存 MinIO skills/{uid}/{skill_id}.zip
  • 元数据存 MySQL installed_skills(per-user:uid + UniqueConstraint(uid, skill_id))
  • agent 用时从 MinIO 懒加载(内存解压 + LRU 缓存)

per-user

  • 每个用户独立 skill 集合,agent 只用自己装的
  • load_skill tool 通过 runtime_dispatch 注入的 _uid 定位用户

skill store(GitHub repo 搜索)

  • list_repos(query): GitHub Search API(q=query,无 query 时 fallback topic:mindbase-skill
  • download_repo(repo, branch): GitHub zipball 整包下载,repo = 1 个 skill(不拆分子目录)
  • get_contents(repo, path, branch): 浏览 repo 目录/文件
  • 配置 SKILL_STORE__TOPIC / SKILL_STORE__API_KEY(GitHub token 可选)

两层缓存

  • 后端:list_repos per-query TTL 缓存(5min,跨用户,应对 GitHub Search rate limit)
  • 前端:store tab 首次加载,切 tab 不重载,搜索/刷新手动

代码工具

  • skill 自带代码工具当前不执行(沙箱后续 PR)
  • has_code_tools=trueload_skill 返回指令 + "需沙箱支持"提示

端点(get_current_uid 用户自主,非 admin)

方法 路径 说明
GET /skills/installed 用户已安装列表
POST /skills/install 上传 zip 安装
DELETE /skills/{skill_id} 卸载
GET /skills/{skill_id}/preview 预览已安装 skill(SKILL.md + 文件列表)
GET /skills/store/list?q= 搜索 GitHub repo
GET /skills/store/contents?repo=&path=&branch= 浏览 repo 目录/文件
POST /skills/store/install 从 repo 安装(body: {repo, branch})

前端(Google × Apple 风)

  • 技能工坊 dock 面板:已安装 + 商店 tab
  • 商店:repo 卡片列表 + 目录浏览(RepoBrowser) + 一键安装
  • 已安装:skill 卡片 + 预览(SKILL.md/manifest/文件列表) + 卸载
  • 设计:Geist display + Roboto body + Google 蓝(#4285F4) + 大圆角卡片(16px) + elevation 阴影 + spring 动效;实色 surface 无玻璃拟态
  • lib/api.ts: skillsApi 完整封装

验证

  • 后端 69 passed(skills 24 + store 15 + runtime 14 + scheduler 11 + agent runtime api 4 + 1)
  • ruff check app/ All checks passed(含既有 E402 noqa 修复)
  • 前端 eslint 0 errors、tsc exit 0
  • per-user 隔离测试(用户 1 的 skill 对用户 2 不可见)
  • zipball 前缀查找测试(owner-repo-sha/SKILL.md
  • 缓存测试(TTL 内不重调 / per-query 独立 / invalidate)

范围外(后续)

  • 沙箱执行 skill 代码工具
  • CLAUDE.md admin 规范(本地保留,不提交)

- skill 不落本地:zip 存 MinIO skills/{uid}/{skill_id}.zip,元数据存 installed_skills 表
- per-user:每个用户独立 skill 集合,agent 只用自己装的
- 懒加载:load_skill tool 从 MinIO 拉取 + LRU 缓存
- skill store:GitHub repo 搜索(list_repos + zipball 下载),repo 作为 1 个 skill 不拆分
- 目录浏览 get_contents + 已安装预览 preview_skill(inspect_zip 支持 zipball 前缀)
- 两层缓存:后端 per-query TTL(5min) + 前端切 tab 不重载
- 端点(get_current_uid 用户自主):/skills/installed|install|{id}|{id}/preview + /skills/store/list|contents|install
- 代码工具不执行(沙箱后续)
- 配置 SKILL_STORE__TOPIC/API_KEY,.env.example + default.yaml 同步
- 69 测试 passed
- 技能工坊 dock 面板:已安装 + 商店 tab
- 商店:GitHub repo 搜索 + 卡片列表 + 目录浏览(RepoBrowser) + 一键安装
- 已安装:skill 卡片 + 预览(SKILL.md/manifest/文件列表) + 卸载
- Google × Apple 设计:Geist display + Roboto body + Google 蓝 accent(#4285F4)
  + 大圆角卡片(16px) + elevation 阴影 + spring 动效;实色 surface 无玻璃拟态
- 两层缓存(前端切 tab 不重载 + 后端 TTL)
- lib/api.ts: skillsApi(listInstalled/uploadInstall/uninstall/storeList/storeInstall/storeContents/preview)
- frontend: 移除 RepoBrowser 未用 branch prop(eslint no-unused-vars warning)
- backend: security.py / eval_ragas.py 既有 E402 加 noqa(非本次引入,ruff app/ 清零)
CI 的 pip install ruff 装最新版,默认规则集变严(含 BLE001/I001/UP045/SIM),
既有代码 ~1800 违规导致 ruff action 失败。加 ruff.toml 固定 select E4/E7/E9/F +
ignore E501/E402,与项目历史 lint 表面一致,跨 ruff 版本稳定。

验证:ruff check app/ / ruff check . / CI 命令 均通过。
broader rules (B/I/UP/SIM) 后续逐步启用。
@atoncooper
atoncooper merged commit a6795c5 into main Jul 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant