skill-list-page.md 1.63 KB

Plan: Skill List Page — File 1: app.py Routes

目标

在 app.py 中新增 4 个路由:/skills 页面、/skill/ 详情页、/api/skills API、/api/skill/ API

数据流

  1. /api/skills 扫描 ~/.hermes/skills/ 所有子目录中带 SKILL.md 的 skill → 合并 .usage.json(use_count, created_at)→ 查 hermes_jobs 表(job_name 匹配 skill 名)统计任务数
  2. /api/skill/<name> 读 ~/.hermes/skills/<name>/SKILL.md → 去掉 YAML frontmatter → 查 hermes_jobs WHERE job_name LIKE '%%' 返回关联任务
  3. /skills → render skills.html
  4. /skill/<name> → render skill_detail.html with name context

涉及文件

  • app.py — 新增 4 个路由(约 80 行)
  • (后续)templates/skills.html
  • (后续)templates/skill_detail.html
  • (后续)templates/base.html

验证命令

curl -s http://127.0.0.1:5001/api/skills | python3 -c "import json,sys; d=json.load(sys.stdin); assert d['ok']; assert len(d['data'])>0; print('OK')"
curl -s http://127.0.0.1:5001/api/skill/feishu-todo-sync | python3 -c "import json,sys; d=json.load(sys.stdin); assert d['ok']; assert 'content' in d['data']; print('OK')"
curl -s http://127.0.0.1:5001/skills | grep -c 'skills'
curl -s http://127.0.0.1:5001/skill/feishu-todo-sync | grep -c 'skill'

验收标准

  • [ ] TC1: GET /api/skills → 200, ok=true, data 为 array,每个元素有 name/use_count/created_at/job_count
  • [ ] TC2: GET /api/skill/feishu-todo-sync → 200, ok=true, data 含 content 和 jobs
  • [ ] TC3: GET /skills → 200 HTML
  • [ ] TC4: GET /skill/feishu-todo-sync → 200 HTML
  • [ ] TC5: 不存在的 skill → 404