Skip to content

The agent that grows with you

feat(desktop): lock a skill from the Capabilities pane

Teknium722d4fac961f
diff --git a/apps/desktop/src/api/skills.ts b/apps/desktop/src/api/skills.ts
index f4d32f4dcca..b0c6068e4d7 100644
--- a/apps/desktop/src/api/skills.ts
+++ b/apps/desktop/src/api/skills.ts
@@ -43,6 +43,20 @@ export function setSkillEnabled(
})
}
+/** Lock/unlock a skill against AGENT edits (`hermes curator lock`); the user's own edits stay allowed. */
+export function setSkillLocked(
+ name: string,
+ locked: boolean,
+ profile?: ProfileScope
+): Promise<{ ok: boolean; name: string; locked: boolean }> {
+ return window.hermesDesktop.api<{ ok: boolean; name: string; locked: boolean }>({
+ ...capabilityScoped(profile),
+ path: '/api/skills/lock',
+ method: 'PUT',
+ body: { name, locked }
+ })
+}
+
export function getStarmapGraph(): Promise<StarmapGraph> {
return hermesApi<StarmapGraph>({
...profileScoped(),
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-data.ts b/apps/desktop/src/app/capabilities/catalog/catalog-data.ts
index 569c074408d..05fc0219d12 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-data.ts
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-data.ts
@@ -38,6 +38,8 @@ export interface CatalogEntry {
imageUrl: string | null
screenshots?: string[]
addedAt?: string
+ /** Installed skill the user locked against agent edits. */
+ locked?: boolean
updatedAt?: string
stars: number | null
/** 1-based curated hero rank from the catalog feed (`catalog-curation.json`). */
diff --git a/apps/desktop/src/app/capabilities/catalog/catalog-list-row.tsx b/apps/desktop/src/app/capabilities/catalog/catalog-list-row.tsx
index f933fb7e25e..1259fa755a1 100644
--- a/apps/desktop/src/app/capabilities/catalog/catalog-list-row.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/catalog-list-row.tsx
@@ -1,5 +1,7 @@
import { Codicon } from '@/components/ui/codicon'
import { RowButton } from '@/components/ui/row-button'
+import { useI18n } from '@/i18n'
+import { Lock } from '@/lib/icons'
import { cn } from '@/lib/utils'
import { type CatalogEntry, type CatalogKind, catalogLabel } from './catalog-data'
@@ -26,6 +28,8 @@ export function CatalogListRow({
onTag,
onSearch
}: CatalogListRowProps) {
+ const { t } = useI18n()
+
return (
<div
className={cn(
@@ -49,6 +53,17 @@ export function CatalogListRow({
<span className="flex items-center gap-2">
<span className="truncate text-[0.78rem] font-medium">{entry.name}</span>
{installed && <Codicon className="shrink-0 text-(--ui-text-tertiary)" name="check" />}
+ {entry.locked && (
+ <span
+ aria-label={t.skills.locked}
+ className="inline-flex shrink-0 text-(--ui-text-tertiary)"
+ data-slot="skill-locked-indicator"
+ role="img"
+ title={t.skills.lockHint}
+ >
+ <Lock className="size-3.5" />
+ </span>
+ )}
</span>
<span className="mt-1 line-clamp-2 text-[length:var(--conversation-caption-font-size)] leading-(--conversation-caption-line-height) text-(--ui-text-tertiary)">
{entry.description}
diff --git a/apps/desktop/src/app/capabilities/catalog/skill-catalog.tsx b/apps/desktop/src/app/capabilities/catalog/skill-catalog.tsx
index 1e1a6fed0f1..cf8ff71aec3 100644
--- a/apps/desktop/src/app/capabilities/catalog/skill-catalog.tsx
+++ b/apps/desktop/src/app/capabilities/catalog/skill-catalog.tsx
@@ -47,7 +47,10 @@ function ScopedSkillCatalog({
const { t } = useI18n()
const h = t.skills.hub
// "Try …" nudges from the user's own skills: search reads categories, not just names.
- const searchHints = useMemo(() => (skills.length ? skillSearchTerms(skills).map(term => t.common.tryHint(term)) : undefined), [skills, t])
+ const searchHints = useMemo(
+ () => (skills.length ? skillSearchTerms(skills).map(term => t.common.tryHint(term)) : undefined),
+ [skills, t]
+ )
const mounted = useRef(true)
const pending = useRef(new Set<string>())
const [installing, setInstalling] = useState<ReadonlySet<string>>(new Set())
@@ -112,7 +115,7 @@ function ScopedSkillCatalog({
}))
).map(entry => {
const skill = skillsByName.get(entry.name)!
- const installed = { ...entry, id: `installed:${skill.name}`, installIdentifier: null }
+ const installed = { ...entry, id: `installed:${skill.name}`, installIdentifier: null, locked: !!skill.locked }
skillsById.set(installed.id, skill)
installedByName.set(skill.name, installed)
diff --git a/apps/desktop/src/app/capabilities/skills/skill-detail.test.tsx b/apps/desktop/src/app/capabilities/skills/skill-detail.test.tsx
new file mode 100644
index 00000000000..6b347eea45c
--- /dev/null
+++ b/apps/desktop/src/app/capabilities/skills/skill-detail.test.tsx
@@ -0,0 +1,87 @@
+// @vitest-environment jsdom
+import { QueryClientProvider, useQuery } from '@tanstack/react-query'
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+
+import type * as HermesApi from '@/hermes'
+import { queryClient } from '@/lib/query-client'
+import type { SkillInfo } from '@/types/hermes'
+
+import { SkillDetail } from './skill-detail'
+import { skillsQueryKey } from './skills-data'
+
+const setSkillLocked = vi.fn()
+const notifyError = vi.fn()
+
+vi.mock('@/hermes', async importOriginal => ({
+ ...(await importOriginal<typeof HermesApi>()),
+ getSkillContent: async (name: string) => ({ content: `---\nname: ${name}\n---\n\n# body\n`, name, path: '' }),
+ setSkillLocked: (name: string, locked: boolean, profile?: unknown) => setSkillLocked(name, locked, profile)
+}))
+
+vi.mock('@/store/notifications', () => ({ notify: vi.fn(), notifyError: (...args: unknown[]) => notifyError(...args) }))
+
+const PROFILE = 'researcher'
+
+function seed(skill: SkillInfo) {
+ queryClient.setQueryData<SkillInfo[]>(skillsQueryKey(PROFILE), [skill])
+}
+
+// Reads the row from the list cache like the real catalog does (a disabled observer:
+// optimistic writes and rollbacks re-render it, nothing refetches).
+function Harness({ name }: { name: string }) {
+ const { data } = useQuery<SkillInfo[]>({ enabled: false, queryFn: () => [], queryKey: skillsQueryKey(PROFILE) })
+ const skill = data?.find(row => row.name === name)
+
+ return skill ? <SkillDetail onArchive={() => {}} onEdit={() => {}} profile={PROFILE} skill={skill} /> : null
+}
+
+function renderDetail(name: string) {
+ render(
+ <QueryClientProvider client={queryClient}>
+ <Harness name={name} />
+ </QueryClientProvider>
+ )
+}
+
+const lockedOf = (name: string) =>
+ queryClient.getQueryData<SkillInfo[]>(skillsQueryKey(PROFILE))?.find(row => row.name === name)?.locked
+
+describe('SkillDetail lock control', () => {
+ beforeEach(() => {
+ setSkillLocked.mockReset()
+ notifyError.mockReset()
+ queryClient.clear()
+ })
+
+ afterEach(() => cleanup())
+
+ it('locks any provenance (bundled here) with the scoped profile', async () => {
+ seed({ category: 'x', description: '', enabled: true, locked: false, name: 'arxiv', provenance: 'bundled' })
+ setSkillLocked.mockResolvedValue({ locked: true, name: 'arxiv', ok: true })
+ renderDetail('arxiv')
+
+ const toggle = screen.getByRole('button', { name: /lock/i })
+ expect(toggle.getAttribute('aria-pressed')).toBe('false')
+ fireEvent.click(toggle)
+
+ await waitFor(() => expect(setSkillLocked).toHaveBeenCalledWith('arxiv', true, PROFILE))
+ await waitFor(() =>
+ expect(screen.getByRole('button', { name: /locked/i }).getAttribute('aria-pressed')).toBe('true')
+ )
+ expect(lockedOf('arxiv')).toBe(true)
+ })
+
+ it('rolls the optimistic flip back and reports when the write fails', async () => {
+ seed({ category: 'x', description: '', enabled: true, locked: true, name: 'mine', provenance: 'agent' })
+ setSkillLocked.mockRejectedValue(new Error('not writable'))
+ renderDetail('mine')
+
+ fireEvent.click(screen.getByRole('button', { name: /locked/i }))
+
+ await waitFor(() => expect(setSkillLocked).toHaveBeenCalledWith('mine', false, PROFILE))
+ await waitFor(() => expect(notifyError).toHaveBeenCalled())
+ expect(lockedOf('mine')).toBe(true)
+ expect(screen.getByRole('button', { name: /locked/i }).getAttribute('aria-pressed')).toBe('true')
+ })
+})
diff --git a/apps/desktop/src/app/capabilities/skills/skill-detail.tsx b/apps/desktop/src/app/capabilities/skills/skill-detail.tsx
index 260b4c02c91..b0cb0c5cd00 100644
--- a/apps/desktop/src/app/capabilities/skills/skill-detail.tsx
+++ b/apps/desktop/src/app/capabilities/skills/skill-detail.tsx
@@ -1,14 +1,19 @@
import { useQuery } from '@tanstack/react-query'
-import { useMemo } from 'react'
+import { useMemo, useState } from 'react'
import { PageLoader } from '@/components/page-loader'
import { Button } from '@/components/ui/button'
-import { getSkillContent, type ProfileScope, profileScopeKey } from '@/hermes'
+import { getSkillContent, type ProfileScope, profileScopeKey, setSkillLocked } from '@/hermes'
import { useI18n } from '@/i18n'
+import { Lock, LockOpen } from '@/lib/icons'
+import { queryClient } from '@/lib/query-client'
+import { cn } from '@/lib/utils'
+import { notifyError } from '@/store/notifications'
import type { SkillInfo } from '@/types/hermes'
import { parseFrontmatter } from './frontmatter'
import { isEditableProvenance } from './skill-provenance'
+import { skillsQueryKey } from './skills-data'
export function SkillDetail({
onArchive,
@@ -35,6 +40,38 @@ export function SkillDetail({
staleTime: 60_000
})
+ // Lock is a user declaration against AGENT edits — offered for every provenance
+ // (bundled/hub/external can be locked too) and never blocks the user's own edits.
+ const locked = Boolean(skill.locked)
+ const [lockPending, setLockPending] = useState(false)
+
+ const setLocked = (name: string, next: boolean) =>
+ queryClient.setQueryData<SkillInfo[]>(skillsQueryKey(profile), current =>
+ current?.map(row => (row.name === name ? { ...row, locked: next } : row))
+ )
+
+ const toggleLock = async () => {
+ if (lockPending) {
+ return
+ }
+
+ const { name } = skill
+ const next = !locked
+ setLockPending(true)
+ await queryClient.cancelQueries({ queryKey: skillsQueryKey(profile), exact: true })
+ setLocked(name, next)
+
+ try {
+ await setSkillLocked(name, next, profile)
+ } catch (err) {
+ setLocked(name, !next)
+ notifyError(err, t.skills.failedToUpdate(name))
+ } finally {
+ setLockPending(false)
+ void queryClient.invalidateQueries({ queryKey: skillsQueryKey(profile), exact: true })
+ }
+ }
+
const parsed = useMemo(
() => (contentQuery.data ? parseFrontmatter(contentQuery.data.content) : null),
[contentQuery.data]
@@ -42,16 +79,33 @@ export function SkillDetail({
return (
<>
- {editable && (
+ <div className="grid gap-1">
<div className="flex items-center gap-2">
- <Button onClick={onEdit} size="xs" variant="text">
- {t.skills.edit}
- </Button>
- <Button className="text-destructive hover:text-destructive" onClick={onArchive} size="xs" variant="text">
- {t.skills.archive}
+ {editable && (
+ <>
+ <Button onClick={onEdit} size="xs" variant="text">
+ {t.skills.edit}
+ </Button>
+ <Button className="text-destructive hover:text-destructive" onClick={onArchive} size="xs" variant="text">
+ {t.skills.archive}
+ </Button>
+ </>
+ )}
+ <Button
+ aria-pressed={locked}
+ className={cn(locked && 'text-foreground')}
+ data-slot="skill-lock-toggle"
+ disabled={lockPending}
+ onClick={() => void toggleLock()}
+ size="xs"
+ variant="text"
+ >
+ {locked ? <Lock /> : <LockOpen />}
+ {locked ? t.skills.locked : t.skills.lock}
</Button>
</div>
- )}
+ <p className="text-xs text-(--ui-text-tertiary)">{locked ? t.skills.lockHint : t.skills.unlockedHint}</p>
+ </div>
{contentQuery.isLoading ? (
<PageLoader className="h-40" label={t.skills.loading} />
) : parsed ? (
diff --git a/apps/desktop/src/app/capabilities/skills/skills-tab.tsx b/apps/desktop/src/app/capabilities/skills/skills-tab.tsx
index 76b98337950..dffd259dc2f 100644
--- a/apps/desktop/src/app/capabilities/skills/skills-tab.tsx
+++ b/apps/desktop/src/app/capabilities/skills/skills-tab.tsx
@@ -6,6 +6,7 @@ import { Button } from '@/components/ui/button'
import { Loader } from '@/components/ui/loader'
import { editLearningNode, getLearningNode, type ProfileScope, profileScopeKey, setSkillEnabled } from '@/hermes'
import { useI18n } from '@/i18n'
+import { Lock } from '@/lib/icons'
import { queryClient } from '@/lib/query-client'
import { invalidateSlashCompletions } from '@/lib/slash-completion-cache'
import { notify, notifyError } from '@/store/notifications'
@@ -258,13 +259,26 @@ function ScopedSkillsTab({
profile={profile}
query={query}
renderInstalledAction={skill => (
- <CatalogSwitch
- aria-label={skill.name}
- checked={skill.enabled}
- disabled={controlsDisabled}
- onCheckedChange={enabled => void applyEnabled([skill], enabled)}
- size="xs"
- />
+ <span className="inline-flex items-center gap-2">
+ {skill.locked && (
+ <span
+ aria-label={t.skills.locked}
+ className="inline-flex text-(--ui-text-tertiary)"
+ data-slot="skill-locked-indicator"
+ role="img"
+ title={t.skills.lockHint}
+ >
+ <Lock className="size-3.5" />
+ </span>
+ )}
+ <CatalogSwitch
+ aria-label={skill.name}
+ checked={skill.enabled}
+ disabled={controlsDisabled}
+ onCheckedChange={enabled => void applyEnabled([skill], enabled)}
+ size="xs"
+ />
+ </span>
)}
renderInstalledDetail={skill => (
<>
diff --git a/apps/desktop/src/i18n/ar_capabilities.ts b/apps/desktop/src/i18n/ar_capabilities.ts
index 32a3e50e146..c01929ca7e5 100644
--- a/apps/desktop/src/i18n/ar_capabilities.ts
+++ b/apps/desktop/src/i18n/ar_capabilities.ts
@@ -37,6 +37,10 @@ export const arCapabilities = {
searchSkills: 'البحث في المهارات',
searchToolsets: 'البحث في مجموعات الأدوات',
refresh: 'تحديث',
+ lock: 'قفل',
+ locked: 'مقفلة',
+ lockHint: 'لا يمكن للوكيل تغيير هذه المهارة ما دامت مقفلة. لا يزال بإمكانك تعديلها بنفسك.',
+ unlockedHint: 'اقفلها لمنع الوكيل من تغيير هذه المهارة. لا يزال بإمكانك تعديلها بنفسك.',
refreshing: 'جار التحديث...',
loading: 'جار التحميل...',
noSkillsTitle: 'لا توجد مهارات',
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index 21ea3a2ab90..aff00e17f90 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -2457,6 +2457,11 @@ export const deOverrides = {
changesApplyNewSessions: 'Änderungen gelten für neue Sessions.',
skillUpdated: 'Skill aktualisiert',
edit: 'Bearbeiten',
+ lock: 'Sperren',
+ locked: 'Gesperrt',
+ lockHint:
+ 'Der Agent kann diesen Skill nicht ändern, solange er gesperrt ist. Du kannst ihn weiterhin selbst bearbeiten.',
+ unlockedHint: 'Sperren, damit der Agent diesen Skill nicht ändert. Du kannst ihn weiterhin selbst bearbeiten.',
archive: 'Archivieren',
skillArchivedTitle: 'Skill archiviert',
skillArchivedMessage: 'Wiederherstellbar über „hermes curator restore“.',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 75b9b0b3e95..548d7e7b8ad 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -2098,6 +2098,10 @@ export const en: Translations = {
edit: 'Edit',
archive: 'Archive',
skillArchivedTitle: 'Skill archived',
+ lock: 'Lock',
+ locked: 'Locked',
+ lockHint: "The agent can't change this skill while it's locked. You can still edit it yourself.",
+ unlockedHint: 'Lock to stop the agent from changing this skill. You can still edit it yourself.',
skillArchivedMessage: 'Restorable via hermes curator restore.',
tabPlugins: 'Plugins',
plugins: {
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index b41d6c6c6e2..38a296ee59a 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -2447,6 +2447,10 @@ export const esOverrides = {
changesApplyNewSessions: 'Los cambios se aplican a las sesiones nuevas.',
skillUpdated: 'Skill actualizado',
edit: 'Editar',
+ lock: 'Bloquear',
+ locked: 'Bloqueado',
+ lockHint: 'El agente no puede cambiar este skill mientras esté bloqueado. Tú puedes seguir editándolo.',
+ unlockedHint: 'Bloquéalo para que el agente no pueda cambiar este skill. Tú puedes seguir editándolo.',
archive: 'Archivar',
skillArchivedTitle: 'Skill archivado',
skillArchivedMessage: 'Puedes restaurarlo con hermes curator restore.',
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index 9e176f0ca47..535b7c1a465 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -2463,6 +2463,12 @@ export const frOverrides = {
changesApplyNewSessions: "Les modifications s'appliquent aux nouvelles sessions.",
skillUpdated: 'Skill mis à jour',
edit: 'Modifier',
+ lock: 'Verrouiller',
+ locked: 'Verrouillé',
+ lockHint:
+ 'L’agent ne peut pas modifier ce skill tant qu’il est verrouillé. Vous pouvez toujours le modifier vous-même.',
+ unlockedHint:
+ 'Verrouillez-le pour que l’agent ne puisse pas modifier ce skill. Vous pouvez toujours le modifier vous-même.',
archive: 'Archiver',
skillArchivedTitle: 'Skill archivé',
skillArchivedMessage: 'Restaurable via hermes curator restore.',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index f66cd382952..56124d19e30 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -1381,6 +1381,10 @@ export const jaOverrides = {
changesApplyNewSessions: '変更は新しいセッションに適用されます。',
skillUpdated: 'スキルを更新しました',
edit: '編集',
+ lock: 'ロック',
+ locked: 'ロック中',
+ lockHint: 'ロック中はエージェントがこのスキルを変更できません。自分では引き続き編集できます。',
+ unlockedHint: 'ロックすると、エージェントはこのスキルを変更できなくなります。自分では引き続き編集できます。',
archive: 'アーカイブ',
skillArchivedTitle: 'スキルをアーカイブしました',
skillArchivedMessage: 'hermes curator restore で復元できます。',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 4b2d472cdda..853b2798c99 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -1475,6 +1475,10 @@ export const ruOverrides = {
changesApplyNewSessions: 'Изменения применяются к новым сеансам.',
skillUpdated: 'Навык обновлён',
edit: 'Изменить',
+ lock: 'Заблокировать',
+ locked: 'Заблокирован',
+ lockHint: 'Пока навык заблокирован, агент не может его менять. Вы по-прежнему можете редактировать его сами.',
+ unlockedHint: 'Заблокируйте навык, чтобы агент не мог его менять. Вы по-прежнему можете редактировать его сами.',
archive: 'В архив',
skillArchivedTitle: 'Навык в архиве',
skillArchivedMessage: 'Восстановить через hermes curator restore.',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index d28c1524604..8876283e45f 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -1898,6 +1898,10 @@ export interface Translations extends NoticeTranslations {
edit: string
archive: string
skillArchivedTitle: string
+ lock: string
+ locked: string
+ lockHint: string
+ unlockedHint: string
skillArchivedMessage: string
tabPlugins: string
plugins: PluginUpdateTranslations &
diff --git a/apps/desktop/src/i18n/zh-hant_capabilities.ts b/apps/desktop/src/i18n/zh-hant_capabilities.ts
index 44f9a85a16b..6848d1f3d18 100644
--- a/apps/desktop/src/i18n/zh-hant_capabilities.ts
+++ b/apps/desktop/src/i18n/zh-hant_capabilities.ts
@@ -79,6 +79,10 @@ export const zhHantCapabilities = {
changesApplyNewSessions: '變更將套用至新工作階段。',
skillUpdated: '技能已更新',
edit: '編輯',
+ lock: '鎖定',
+ locked: '已鎖定',
+ lockHint: '鎖定期間,代理程式無法變更此技能。你仍可自行編輯。',
+ unlockedHint: '鎖定後,代理程式將無法變更此技能。你仍可自行編輯。',
archive: '封存',
skillArchivedTitle: '技能已封存',
skillArchivedMessage: '可透過 hermes curator restore 還原。',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 5e07e00512e..b43c662e520 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2058,6 +2058,10 @@ export const zhOverrides = {
changesApplyNewSessions: '更改将应用于新会话。',
skillUpdated: '技能已更新',
edit: '编辑',
+ lock: '锁定',
+ locked: '已锁定',
+ lockHint: '锁定期间,智能体无法更改此技能。你仍可以自己编辑。',
+ unlockedHint: '锁定后,智能体将无法更改此技能。你仍可以自己编辑。',
archive: '归档',
skillArchivedTitle: '技能已归档',
skillArchivedMessage: '可通过 hermes curator restore 恢复。',
diff --git a/apps/desktop/src/lib/icons.ts b/apps/desktop/src/lib/icons.ts
index 3c0a6ea6798..0dd5627e6b0 100644
--- a/apps/desktop/src/lib/icons.ts
+++ b/apps/desktop/src/lib/icons.ts
@@ -70,6 +70,7 @@ import {
IconLoader2 as Loader2,
IconLoader2 as Loader2Icon,
IconLock as Lock,
+ IconLockOpen as LockOpen,
IconLogin as LogIn,
IconMail as Mail,
IconMaximize as Maximize,
@@ -208,6 +209,7 @@ export {
Loader2,
Loader2Icon,
Lock,
+ LockOpen,
LogIn,
Mail,
Maximize,
diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.ts
index 8e71d417b62..99a45a8e19f 100644
--- a/apps/desktop/src/types/hermes.ts
+++ b/apps/desktop/src/types/hermes.ts
@@ -1255,6 +1255,8 @@ export interface SkillInfo {
/** 'agent' = learned/local (editable), 'bundled' = ships with Hermes, 'hub' = installed,
* 'external' = mounted from skills.external_dirs (externally authored, still editable). */
provenance?: 'agent' | 'bundled' | 'external' | 'hub'
+ /** User lock: the AGENT may not change this skill (the user still can). Absent on older backends. */
+ locked?: boolean
}
/** One entry of the built-in optional-skills catalog (optional-skills/ in the
diff --git a/hermes_cli/web_models.py b/hermes_cli/web_models.py
index 1cdaf300f2e..e5e0603dcd2 100644
--- a/hermes_cli/web_models.py
+++ b/hermes_cli/web_models.py
@@ -503,6 +503,11 @@ class SkillToggle(BaseModel):
enabled: bool
profile: Optional[str] = None
+class SkillLock(BaseModel):
+ name: str
+ locked: bool
+ profile: Optional[str] = None
+
class SkillCreate(BaseModel):
name: str
content: str
diff --git a/hermes_cli/web_routers/skills.py b/hermes_cli/web_routers/skills.py
index c354183a3a1..608742f89a2 100644
--- a/hermes_cli/web_routers/skills.py
+++ b/hermes_cli/web_routers/skills.py
@@ -15,8 +15,8 @@ from fastapi import APIRouter, HTTPException
from hermes_cli.web_deps import late
from hermes_cli.web_server_profiles import _hub_action_name, _installed_hub_identifiers
from hermes_cli.web_models import (
- SkillContentUpdate, SkillCreate, SkillInstallRequest, SkillToggle, SkillUninstallRequest,
- SkillsUpdateRequest)
+ SkillContentUpdate, SkillCreate, SkillInstallRequest, SkillLock, SkillToggle,
+ SkillUninstallRequest, SkillsUpdateRequest)
from hermes_cli.web_routers._common import (
_profile_scope, config_write_scope, http_failure, log as _log, require, scoped_to_thread,
spawn_profile_action)
@@ -363,7 +363,9 @@ async def get_skills(profile: Optional[str] = None):
bundled_names = _read_bundled_names()
hub_names = _read_hub_installed_names()
external_names = _external_skill_names() - bundled_names - hub_names
+ locked_dirs, dir_by_name = _locked_index()
for s in skills:
+ s["locked"] = dir_by_name.get(s["name"], s["name"]) in locked_dirs
s["enabled"] = s["name"] not in disabled
s["usage"] = activity_count(usage.get(s["name"], {}))
s["provenance"] = (
@@ -376,6 +378,43 @@ async def get_skills(profile: Optional[str] = None):
return await asyncio.to_thread(_run)
+def _locked_index() -> tuple[set, dict]:
+ """(locked directory names, load name -> directory name) for the ``locked`` row flag.
+ Locks are keyed by the skill's DIRECTORY (what the write guards resolve to) while rows
+ carry the load name. A corrupt sidecar reads as unlocked here (``locked_skill_names`` is
+ best-effort); the write guards decide enforcement."""
+ from tools.skill_usage import locked_skill_names
+ locked = set(locked_skill_names())
+ if not locked:
+ return set(), {}
+ from tools.skills_tool import _skill_catalog
+ return locked, {e["load_name"]: e["path"].parent.name
+ for e in _skill_catalog(skip_disabled=True) if e.get("load_name")}
+
+
[email protected]("/api/skills/lock")
+async def lock_skill(body: SkillLock, profile: Optional[str] = None):
+ """Lock/unlock a skill against AGENT edits (same record as ``hermes curator lock``).
+ The user's own edits (this dashboard's editor, their editor) stay allowed."""
+ from tools import skill_usage
+ from tools.skill_manager_tool import _find_skill
+
+ def _run():
+ with config_write_scope(body.profile or profile):
+ existing = _find_skill(body.name)
+ if existing is None:
+ raise HTTPException(status_code=404, detail=f"Skill '{body.name}' not found.")
+ key = existing["path"].name
+ if not skill_usage.set_locked(key, body.locked):
+ verb = "lock" if body.locked else "unlock"
+ raise HTTPException(
+ status_code=500,
+ detail=f"Could not {verb} '{key}': skills/.usage.json is not writable.")
+ return {"ok": True, "name": body.name, "locked": body.locked}
+
+ return await asyncio.to_thread(_run)
+
+
@router.put("/api/skills/toggle")
async def toggle_skill(body: SkillToggle, profile: Optional[str] = None):
from hermes_cli.skills_config import get_disabled_skills, save_disabled_skills
diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.json
index db7f29e6eea..ea7e991d714 100644
--- a/locales/_keys.desktop.json
+++ b/locales/_keys.desktop.json
@@ -4914,6 +4914,9 @@
"skills.hub.verdictSafe",
"skills.hub.viewScan",
"skills.loading",
+ "skills.lock",
+ "skills.lockHint",
+ "skills.locked",
"skills.needsKeys",
"skills.noDescription",
"skills.noSkillsDesc",
@@ -5042,6 +5045,7 @@
"skills.toolsetEnabled",
"skills.toolsetsEnabled",
"skills.toolsetsRefreshFailed",
+ "skills.unlockedHint",
"skills.usageCount",
"skills.visionModelHint",
"skills.visionModelLink",
diff --git a/tests/hermes_cli/test_web_server_skills_profiles.py b/tests/hermes_cli/test_web_server_skills_profiles.py
index c0b544e9a00..e304d731e0b 100644
--- a/tests/hermes_cli/test_web_server_skills_profiles.py
+++ b/tests/hermes_cli/test_web_server_skills_profiles.py
@@ -123,6 +123,44 @@ class TestProfileScopedSkills:
assert default_md.read_text() == before
assert not (isolated_profiles["default"] / "skills" / "shared-skill-2").exists()
+ def test_lock_round_trips_in_target_profile_and_list_carries_it(
+ self, client, isolated_profiles, monkeypatch):
+ """PUT /api/skills/lock keys the record by DIRECTORY (what the write guards resolve)
+ in the requested profile; GET /api/skills maps it back onto the row's load name."""
+ from tools import skill_usage
+
+ worker_skills = isolated_profiles["worker_alpha"] / "skills"
+ d = worker_skills / "dir-name" # declared name differs from the directory
+ d.mkdir()
+ (d / "SKILL.md").write_text("---\nname: shown-name\ndescription: x\n---\n\n# x\n")
+
+ resp = client.put("/api/skills/lock", params={"profile": "worker_alpha"},
+ json={"name": "shown-name", "locked": True})
+ assert resp.status_code == 200, resp.text
+ assert resp.json() == {"ok": True, "name": "shown-name", "locked": True}
+ monkeypatch.setenv("HERMES_HOME", str(isolated_profiles["worker_alpha"]))
+ assert skill_usage.is_locked("dir-name")
+ monkeypatch.setenv("HERMES_HOME", str(isolated_profiles["default"]))
+ assert not skill_usage.is_locked("dir-name")
+
+ rows = client.get("/api/skills", params={"profile": "worker_alpha"}).json()
+ assert {r["name"]: r["locked"] for r in rows} == {"worker-skill": False, "shown-name": True}
+
+ resp = client.put("/api/skills/lock", params={"profile": "worker_alpha"},
+ json={"name": "shown-name", "locked": False})
+ assert resp.status_code == 200
+ monkeypatch.setenv("HERMES_HOME", str(isolated_profiles["worker_alpha"]))
+ assert not skill_usage.is_locked("dir-name")
+
+ def test_lock_unknown_skill_404_and_corrupt_sidecar_lists_unlocked(
+ self, client, isolated_profiles):
+ resp = client.put("/api/skills/lock", json={"name": "ghost", "locked": True})
+ assert resp.status_code == 404
+ (isolated_profiles["default"] / "skills" / ".usage.json").write_text("{not json")
+ resp = client.get("/api/skills")
+ assert resp.status_code == 200
+ assert [r["locked"] for r in resp.json()] == [False]
+
class TestProfileScopedHubActions:
def test_hub_install_spawns_with_profile_flag(