nyk commited on
Commit
28f45a6
·
unverified ·
1 Parent(s): 608b8db

feat: add workspace skill root and root-based filtering to Skills Hub (#408)

Browse files

- Add `workspace` skill root (~/.openclaw/workspace/skills) for
workspace-local skill discovery alongside the existing 5 roots
- Make group cards clickable to filter the installed skills list by root
- Add `workspace` as valid target for skill creation and registry install
- Add `showAllRoots` i18n key to all 10 locale files

Closes #364

messages/ar.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "حذف",
1823
  "save": "حفظ",
1824
  "loadingSkillContent": "جارٍ تحميل SKILL.md...",
1825
- "noContent": "لا يوجد محتوى."
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "حذف",
1823
  "save": "حفظ",
1824
  "loadingSkillContent": "جارٍ تحميل SKILL.md...",
1825
+ "noContent": "لا يوجد محتوى.",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/de.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "Löschen",
1823
  "save": "Speichern",
1824
  "loadingSkillContent": "SKILL.md wird geladen...",
1825
- "noContent": "Kein Inhalt."
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "Löschen",
1823
  "save": "Speichern",
1824
  "loadingSkillContent": "SKILL.md wird geladen...",
1825
+ "noContent": "Kein Inhalt.",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/en.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "Delete",
1823
  "save": "Save",
1824
  "loadingSkillContent": "Loading SKILL.md...",
1825
- "noContent": "No content."
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "Delete",
1823
  "save": "Save",
1824
  "loadingSkillContent": "Loading SKILL.md...",
1825
+ "noContent": "No content.",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/es.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "Eliminar",
1823
  "save": "Guardar",
1824
  "loadingSkillContent": "Cargando SKILL.md...",
1825
- "noContent": "Sin contenido."
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "Eliminar",
1823
  "save": "Guardar",
1824
  "loadingSkillContent": "Cargando SKILL.md...",
1825
+ "noContent": "Sin contenido.",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/fr.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "Supprimer",
1823
  "save": "Enregistrer",
1824
  "loadingSkillContent": "Chargement du SKILL.md...",
1825
- "noContent": "Aucun contenu."
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "Supprimer",
1823
  "save": "Enregistrer",
1824
  "loadingSkillContent": "Chargement du SKILL.md...",
1825
+ "noContent": "Aucun contenu.",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/ja.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "削除",
1823
  "save": "保存",
1824
  "loadingSkillContent": "SKILL.md を読み込み中...",
1825
- "noContent": "コンテンツがありません。"
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "削除",
1823
  "save": "保存",
1824
  "loadingSkillContent": "SKILL.md を読み込み中...",
1825
+ "noContent": "コンテンツがありません。",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/ko.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "삭제",
1823
  "save": "저장",
1824
  "loadingSkillContent": "SKILL.md 로드 중...",
1825
- "noContent": "내용 없음."
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "삭제",
1823
  "save": "저장",
1824
  "loadingSkillContent": "SKILL.md 로드 중...",
1825
+ "noContent": "내용 없음.",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/pt.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "Excluir",
1823
  "save": "Salvar",
1824
  "loadingSkillContent": "Carregando SKILL.md...",
1825
- "noContent": "Sem conteúdo."
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "Excluir",
1823
  "save": "Salvar",
1824
  "loadingSkillContent": "Carregando SKILL.md...",
1825
+ "noContent": "Sem conteúdo.",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/ru.json CHANGED
@@ -1822,7 +1822,8 @@
1822
  "delete": "Удалить",
1823
  "save": "Сохранить",
1824
  "loadingSkillContent": "Загрузка SKILL.md...",
1825
- "noContent": "Нет содержимого."
 
1826
  },
1827
  "agentSquadPhase3": {
1828
  "title": "Agent Squad",
 
1822
  "delete": "Удалить",
1823
  "save": "Сохранить",
1824
  "loadingSkillContent": "Загрузка SKILL.md...",
1825
+ "noContent": "Нет содержимого.",
1826
+ "showAllRoots": "Show all roots"
1827
  },
1828
  "agentSquadPhase3": {
1829
  "title": "Agent Squad",
messages/zh.json CHANGED
@@ -692,7 +692,8 @@
692
  "delete": "删除",
693
  "save": "保存",
694
  "loadingSkillContent": "加载 SKILL.md...",
695
- "noContent": "无内容。"
 
696
  },
697
  "agentSquadPhase3": {
698
  "title": "Agent Squad",
 
692
  "delete": "删除",
693
  "save": "保存",
694
  "loadingSkillContent": "加载 SKILL.md...",
695
+ "noContent": "无内容。",
696
+ "showAllRoots": "Show all roots"
697
  },
698
  "agentSquadPhase3": {
699
  "title": "Agent Squad",
src/app/api/skills/registry/route.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
  } from '@/lib/skill-registry'
10
 
11
  const VALID_SOURCES: RegistrySource[] = ['clawhub', 'skills-sh', 'awesome-openclaw']
12
- const VALID_TARGETS = ['user-agents', 'user-codex', 'project-agents', 'project-codex', 'openclaw']
13
 
14
  /**
15
  * GET /api/skills/registry?source=clawhub&q=terraform
 
9
  } from '@/lib/skill-registry'
10
 
11
  const VALID_SOURCES: RegistrySource[] = ['clawhub', 'skills-sh', 'awesome-openclaw']
12
+ const VALID_TARGETS = ['user-agents', 'user-codex', 'project-agents', 'project-codex', 'openclaw', 'workspace']
13
 
14
  /**
15
  * GET /api/skills/registry?source=clawhub&q=terraform
src/app/api/skills/route.ts CHANGED
@@ -88,6 +88,12 @@ function getSkillRoots(): SkillRoot[] {
88
  const openclawState = process.env.OPENCLAW_STATE_DIR || process.env.OPENCLAW_HOME || join(home, '.openclaw')
89
  const openclawSkills = resolveSkillRoot('MC_SKILLS_OPENCLAW_DIR', join(openclawState, 'skills'))
90
  roots.push({ source: 'openclaw', path: openclawSkills })
 
 
 
 
 
 
91
  return roots
92
  }
93
 
 
88
  const openclawState = process.env.OPENCLAW_STATE_DIR || process.env.OPENCLAW_HOME || join(home, '.openclaw')
89
  const openclawSkills = resolveSkillRoot('MC_SKILLS_OPENCLAW_DIR', join(openclawState, 'skills'))
90
  roots.push({ source: 'openclaw', path: openclawSkills })
91
+
92
+ // Add OpenClaw workspace-local skills (takes precedence when names conflict)
93
+ const workspaceDir = process.env.OPENCLAW_WORKSPACE_DIR || process.env.MISSION_CONTROL_WORKSPACE_DIR || join(openclawState, 'workspace')
94
+ const workspaceSkills = resolveSkillRoot('MC_SKILLS_WORKSPACE_DIR', join(workspaceDir, 'skills'))
95
+ roots.push({ source: 'workspace', path: workspaceSkills })
96
+
97
  return roots
98
  }
99
 
src/components/panels/skills-panel.tsx CHANGED
@@ -56,6 +56,7 @@ const SOURCE_LABELS: Record<string, string> = {
56
  'project-agents': '.agents/skills (project)',
57
  'project-codex': '.codex/skills (project)',
58
  'openclaw': '~/.openclaw/skills (gateway)',
 
59
  }
60
 
61
  export function SkillsPanel() {
@@ -65,6 +66,7 @@ export function SkillsPanel() {
65
  const [saving, setSaving] = useState(false)
66
  const [error, setError] = useState<string | null>(null)
67
  const [query, setQuery] = useState('')
 
68
  const [selectedSkill, setSelectedSkill] = useState<SkillSummary | null>(null)
69
  const [selectedContent, setSelectedContent] = useState<SkillContentResponse | null>(null)
70
  const [draftContent, setDraftContent] = useState('')
@@ -142,14 +144,15 @@ export function SkillsPanel() {
142
  }, [loadSkills])
143
 
144
  const filtered = useMemo(() => {
145
- const list = skillsList || []
 
146
  const q = query.trim().toLowerCase()
147
  if (!q) return list
148
  return list.filter((skill) => {
149
  const haystack = `${skill.name} ${skill.source} ${skill.description || ''}`.toLowerCase()
150
  return haystack.includes(q)
151
  })
152
- }, [skillsList, query])
153
 
154
  useEffect(() => {
155
  if (!selectedSkill) return
@@ -513,6 +516,7 @@ export function SkillsPanel() {
513
  {dashboardMode === 'full' && (
514
  <option value="openclaw">{SOURCE_LABELS['openclaw']}</option>
515
  )}
 
516
  </select>
517
  <input
518
  value={createName}
@@ -540,14 +544,28 @@ export function SkillsPanel() {
540
  ) : (
541
  <>
542
  <div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3">
543
- {(skillGroups || []).filter(g => g.skills.length > 0 || ['user-agents', 'user-codex', 'openclaw'].includes(g.source)).map((group) => (
544
- <div key={group.source} className={`rounded-lg border bg-card p-3 ${
545
- group.source === 'openclaw' ? 'border-cyan-500/30' : 'border-border'
546
- }`}>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  <div className="text-xs font-medium text-muted-foreground">{SOURCE_LABELS[group.source] || group.source}</div>
548
  <div className="mt-1 text-lg font-semibold text-foreground">{group.skills.length}</div>
549
  <div className="mt-1 text-2xs text-muted-foreground truncate">{group.path}</div>
550
- </div>
551
  ))}
552
  </div>
553
 
@@ -641,6 +659,7 @@ export function SkillsPanel() {
641
  {dashboardMode === 'full' && (
642
  <option value="openclaw">{SOURCE_LABELS['openclaw']}</option>
643
  )}
 
644
  </select>
645
  </div>
646
  </div>
 
56
  'project-agents': '.agents/skills (project)',
57
  'project-codex': '.codex/skills (project)',
58
  'openclaw': '~/.openclaw/skills (gateway)',
59
+ 'workspace': '~/.openclaw/workspace/skills',
60
  }
61
 
62
  export function SkillsPanel() {
 
66
  const [saving, setSaving] = useState(false)
67
  const [error, setError] = useState<string | null>(null)
68
  const [query, setQuery] = useState('')
69
+ const [activeRoot, setActiveRoot] = useState<string | null>(null)
70
  const [selectedSkill, setSelectedSkill] = useState<SkillSummary | null>(null)
71
  const [selectedContent, setSelectedContent] = useState<SkillContentResponse | null>(null)
72
  const [draftContent, setDraftContent] = useState('')
 
144
  }, [loadSkills])
145
 
146
  const filtered = useMemo(() => {
147
+ let list = skillsList || []
148
+ if (activeRoot) list = list.filter((s) => s.source === activeRoot)
149
  const q = query.trim().toLowerCase()
150
  if (!q) return list
151
  return list.filter((skill) => {
152
  const haystack = `${skill.name} ${skill.source} ${skill.description || ''}`.toLowerCase()
153
  return haystack.includes(q)
154
  })
155
+ }, [skillsList, query, activeRoot])
156
 
157
  useEffect(() => {
158
  if (!selectedSkill) return
 
516
  {dashboardMode === 'full' && (
517
  <option value="openclaw">{SOURCE_LABELS['openclaw']}</option>
518
  )}
519
+ <option value="workspace">{SOURCE_LABELS['workspace']}</option>
520
  </select>
521
  <input
522
  value={createName}
 
544
  ) : (
545
  <>
546
  <div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3">
547
+ {activeRoot && (
548
+ <button
549
+ onClick={() => setActiveRoot(null)}
550
+ className="col-span-full text-left text-2xs text-primary hover:underline"
551
+ >
552
+ {t('showAllRoots')}
553
+ </button>
554
+ )}
555
+ {(skillGroups || []).filter(g => g.skills.length > 0 || ['user-agents', 'user-codex', 'openclaw', 'workspace'].includes(g.source)).map((group) => (
556
+ <button
557
+ key={group.source}
558
+ onClick={() => setActiveRoot(activeRoot === group.source ? null : group.source)}
559
+ className={`rounded-lg border bg-card p-3 text-left transition-colors ${
560
+ activeRoot === group.source
561
+ ? 'border-primary ring-1 ring-primary/30'
562
+ : group.source === 'openclaw' ? 'border-cyan-500/30 hover:border-cyan-500/50' : 'border-border hover:border-border/80'
563
+ }`}
564
+ >
565
  <div className="text-xs font-medium text-muted-foreground">{SOURCE_LABELS[group.source] || group.source}</div>
566
  <div className="mt-1 text-lg font-semibold text-foreground">{group.skills.length}</div>
567
  <div className="mt-1 text-2xs text-muted-foreground truncate">{group.path}</div>
568
+ </button>
569
  ))}
570
  </div>
571
 
 
659
  {dashboardMode === 'full' && (
660
  <option value="openclaw">{SOURCE_LABELS['openclaw']}</option>
661
  )}
662
+ <option value="workspace">{SOURCE_LABELS['workspace']}</option>
663
  </select>
664
  </div>
665
  </div>