🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(skills): filter disable-model-invocation/empty-description device skills and dedupe symlinks (#23514)
AmAzing-585ae785c682
diff --git a/apps/server/src/services/aiAgent/__tests__/execAgent.topicWorkingDirectory.test.ts b/apps/server/src/services/aiAgent/__tests__/execAgent.topicWorkingDirectory.test.tsindex 7a1d9115148..2df176dcd8a 100644--- a/apps/server/src/services/aiAgent/__tests__/execAgent.topicWorkingDirectory.test.ts+++ b/apps/server/src/services/aiAgent/__tests__/execAgent.topicWorkingDirectory.test.ts@@ -642,6 +642,63 @@ describe('AiAgentService.execAgent - topic working directory binding', () => {);});+ it('excludes disable-model-invocation and description-less skills from automatic discovery unless explicitly selected', async () => {+ mockGetAgentConfig.mockResolvedValue(+ createAgentConfig({ boundDeviceId: DEVICE_ID, executionTarget: 'device' }),+ );+ mockInitWorkspace.mockResolvedValue({+ instructions: [],+ skills: [+ {+ description: 'Visible device skill',+ name: 'visible',+ path: '/home/user/.agents/skills/visible/SKILL.md',+ scope: 'device',+ },+ {+ description: 'Manual-only deploy skill',+ disableModelInvocation: true,+ name: 'deploy',+ path: '/home/user/.agents/skills/deploy/SKILL.md',+ scope: 'device',+ },+ {+ description: ' ',+ name: 'undescribed',+ path: '/project/.agents/skills/undescribed/SKILL.md',+ scope: 'project',+ },+ ],+ });++ await service.execAgent(topicRunInput());++ const defaultOperation = mockCreateOperation.mock.calls[0][0];+ expect(defaultOperation.operationSkillSet?.skills).toEqual([+ {+ description: 'Visible device skill',+ identifier: 'device:visible',+ location: '/home/user/.agents/skills/visible/SKILL.md',+ name: 'visible',+ source: 'device',+ },+ ]);++ mockCreateOperation.mockClear();+ await service.execAgent({+ ...topicRunInput(),+ selectedSkillIds: ['projectSkill:deploy', 'projectSkill:undescribed'],+ });++ const selectedOperation = mockCreateOperation.mock.calls[0][0];+ expect(+ selectedOperation.operationSkillSet?.skills.map((s: { name: string }) => s.name),+ ).toEqual(['visible', 'deploy', 'undescribed']);+ expect(selectedOperation.operationSkillSet?.enabledPluginIds).toEqual(+ expect.arrayContaining(['device:deploy', 'project:undescribed']),+ );+ });+it('continues without device skills when a directory-less device scan is unavailable', async () => {mockGetAgentConfig.mockResolvedValue({...createAgentConfig({ boundDeviceId: DEVICE_ID, executionTarget: 'device' }),diff --git a/apps/server/src/services/aiAgent/pipeline/operationSkillSet.ts b/apps/server/src/services/aiAgent/pipeline/operationSkillSet.tsindex 17f38773e80..cc42200a6bf 100644--- a/apps/server/src/services/aiAgent/pipeline/operationSkillSet.ts+++ b/apps/server/src/services/aiAgent/pipeline/operationSkillSet.ts@@ -4,7 +4,7 @@ import { mentionsTopic } from '@lobechat/context-engine';import type { LobeChatDatabase } from '@lobechat/database';import { assembleSkillPool } from '@lobechat/mecha';import { resourcesTreePrompt } from '@lobechat/prompts';-import { getActivePluginIds } from '@lobechat/types';+import { FILESYSTEM_SKILL_SELECTION_PREFIX, getActivePluginIds } from '@lobechat/types';import debug from 'debug';import type { AgentModel } from '@/database/models/agent';@@ -110,8 +110,11 @@ export const buildOperationSkillSet = async (} = input;try {+ const injectedSkillIds = new Set(+ selectedSkillIds.filter((id) => !id.startsWith(FILESYSTEM_SKILL_SELECTION_PREFIX)),+ );const builtinMetas = builtinSkills.map((s) => ({- content: selectedSkillIds.includes(s.identifier) ? s.content : undefined,+ content: injectedSkillIds.has(s.identifier) ? s.content : undefined,description: s.description,identifier: s.identifier,name: s.name,@@ -122,7 +125,6 @@ export const buildOperationSkillSet = async (// Only a topic selection requests a body up front. A saved (legacy)// pin, like auto, advertises the skill for on-demand activation.const pinnedSkillIds = new Set(getActivePluginIds(agentConfig.plugins));- const injectedSkillIds = new Set(selectedSkillIds);const pinnedDbSkillIds = dbSkills.filter((s) => injectedSkillIds.has(s.identifier)).map((s) => s.id);@@ -212,13 +214,25 @@ export const buildOperationSkillSet = async (})),];- const projectMetas = workspaceInit.workspace.skills.map((s) => ({- description: s.description ?? '',- identifier: `${s.scope === 'device' ? 'device' : 'project'}:${s.name}`,- location: s.path,- name: s.name,- source: s.scope === 'device' ? ('device' as const) : ('project' as const),- }));+ // Exclude skills with `disable-model-invocation: true` or missing description+ // from automatic model discovery (<available_skills>), unless the user+ // explicitly invoked the skill in the conversation (`selectedSkillIds`).+ const selectedFilesystemSkillIds: string[] = [];+ const workspaceSelections = new Set(selectedSkillIds);+ const projectMetas = workspaceInit.workspace.skills.flatMap<+ OperationSkillSet['skills'][number]+ >((skill) => {+ const source = skill.scope === 'device' ? 'device' : 'project';+ const identifier = `${source}:${skill.name}`;+ const selected =+ workspaceSelections.has(identifier) ||+ workspaceSelections.has(FILESYSTEM_SKILL_SELECTION_PREFIX + skill.name);+ const description = skill.description?.trim() ?? '';+ if (!selected && (skill.disableModelInvocation || !description)) return [];++ if (selected) selectedFilesystemSkillIds.push(identifier);+ return [{ description, identifier, location: skill.path, name: skill.name, source }];+ });if (projectMetas.length) {log(@@ -284,7 +298,12 @@ export const buildOperationSkillSet = async (// Selected skills join the enabled set so the resolver auto-activates// them; a share allowlist or a disabled entry still drops them above.enabledPluginIds: [- ...new Set([...(agentPlugins ?? []), ...shareEnabledSkillIds, ...selectedSkillIds]),+ ...new Set([+ ...(agentPlugins ?? []),+ ...shareEnabledSkillIds,+ ...injectedSkillIds,+ ...selectedFilesystemSkillIds,+ ]),],shareAllowedIds: shareAllowedSkillIds,skillActivateMode: agentConfig.chatConfig?.skillActivateMode,diff --git a/apps/server/src/services/deviceGateway/index.projectFiles.test.ts b/apps/server/src/services/deviceGateway/index.projectFiles.test.tsindex 3109eaba55a..8fde72cb8ad 100644--- a/apps/server/src/services/deviceGateway/index.projectFiles.test.ts+++ b/apps/server/src/services/deviceGateway/index.projectFiles.test.ts@@ -69,6 +69,7 @@ describe('DeviceGateway', () => {createProjectSkillItem(),{description: 'device',+ disableModelInvocation: true,name: 'device-writer',path: '/home/.agents/skills/device-writer/SKILL.md',previewRoot: '/home/.agents/skills',@@ -95,6 +96,7 @@ describe('DeviceGateway', () => {},{description: 'device',+ disableModelInvocation: true,name: 'device-writer',path: '/home/.agents/skills/device-writer/SKILL.md',scope: 'device',diff --git a/apps/server/src/services/deviceGateway/workspace.ts b/apps/server/src/services/deviceGateway/workspace.tsindex 0ff3155b892..05cb22310a0 100644--- a/apps/server/src/services/deviceGateway/workspace.ts+++ b/apps/server/src/services/deviceGateway/workspace.ts@@ -55,8 +55,9 @@ export async function initWorkspace(const { instructions, skills } = result.data;return {instructions: instructions ?? [],- skills: (skills ?? []).map(({ description, name, path, scope }) => ({+ skills: (skills ?? []).map(({ description, disableModelInvocation, name, path, scope }) => ({description,+ ...(disableModelInvocation ? { disableModelInvocation: true } : {}),name,path,scope,diff --git a/packages/device-control/src/__tests__/workspace.test.ts b/packages/device-control/src/__tests__/workspace.test.tsindex c179595472d..a1f73a58def 100644--- a/packages/device-control/src/__tests__/workspace.test.ts+++ b/packages/device-control/src/__tests__/workspace.test.ts@@ -37,6 +37,25 @@ afterEach(async () => {});describe('initWorkspace', () => {+ it('keeps a device skill alias when the original name is shadowed by a project skill', async () => {+ const repo = path.join(base, 'repo');+ const projectSkills = path.join(repo, '.agents', 'skills');+ const deviceSkill = path.join(home, '.agents', 'skills', 'foo');+ const alias = path.join(home, '.claude', 'skills', 'bar');+ await mkdir(path.join(repo, '.git'), { recursive: true });+ await writeSkill(projectSkills, 'foo');+ await write(path.join(deviceSkill, 'SKILL.md'), '---\ndescription: Device skill\n---\n');+ await mkdir(path.dirname(alias), { recursive: true });+ await symlink(deviceSkill, alias, 'dir');++ const result = await initWorkspace({ scope: repo });++ expect(result.skills).toMatchObject([+ { name: 'bar', path: path.join(alias, 'SKILL.md'), scope: 'device' },+ { name: 'foo', path: path.join(projectSkills, 'foo', 'SKILL.md'), scope: 'project' },+ ]);+ });+it('reads instructions from the working directory up to the repository root, root first', async () => {const repo = path.join(base, 'outside', 'repo');const pkg = path.join(repo, 'packages', 'web');@@ -220,6 +239,35 @@ describe('listProjectSkills', () => {expect(approveProjectRoot).toHaveBeenCalledWith(path.join(repo, '.agents', 'skills'));});+ it('deduplicates symlinked skills pointing to the same physical SKILL.md via realpath', async () => {+ const repo = path.join(base, 'repo');+ await mkdir(path.join(repo, '.git'), { recursive: true });+ // Physical skill without frontmatter `name`, so directory name would otherwise decide `name`+ const targetDir = path.join(repo, '.agents', 'skills', 'shared-skill');+ await write(path.join(targetDir, 'SKILL.md'), '---\ndescription: Shared physical skill\n---\n');++ // Symlink in .claude/skills under a different directory name and in home .codex/skills+ await mkdir(path.join(repo, '.claude', 'skills'), { recursive: true });+ await symlink(targetDir, path.join(repo, '.claude', 'skills', 'claude-alias'), 'dir');+ await mkdir(path.join(home, '.codex', 'skills'), { recursive: true });+ await symlink(targetDir, path.join(home, '.codex', 'skills', 'codex-alias'), 'dir');++ const result = await initWorkspace({ scope: repo });++ expect(result.skills).toMatchObject([+ {+ description: 'Shared physical skill',+ disableModelInvocation: false,+ name: 'shared-skill',+ path: path.join(targetDir, 'SKILL.md'),+ previewRoot: repo,+ scope: 'project',+ skillDir: targetDir,+ source: '.agents/skills',+ },+ ]);+ });+it('stops at SKILL.md without traversing subdirectories inside a skill directory', async () => {const repo = path.join(base, 'repo');const skillDir = path.join(repo, '.agents', 'skills', 'lobe-design');diff --git a/packages/device-control/src/workspace.ts b/packages/device-control/src/workspace.tsindex 25a9b4416da..51cbde9f817 100644--- a/packages/device-control/src/workspace.ts+++ b/packages/device-control/src/workspace.ts@@ -148,19 +148,19 @@ const parseSkillFrontmatter = (raw: string): SkillFrontmatterFields => {}};+type SkillCandidate = ProjectSkillItem & { realPath: string };+/*** Scan one skill source directory and return parsed frontmatter for each* `SKILL.md`. Once a directory contains `SKILL.md`, treat it as a skill root* and do not recurse into its subdirectories (`scripts/`, `references/`, etc.).* Returns `[]` when the source directory is absent or unreadable.- * Unsorted — callers sort/merge.+ * Candidates are ordered by directory name to make alias precedence stable.*/-const scanSkillsInSource = async ({- previewRoot,- scope,- source,- sourceRoot,-}: SkillScanRoot): Promise<ProjectSkillItem[]> => {+const scanSkillsInSource = async (+ { previewRoot, scope, source, sourceRoot }: SkillScanRoot,+ seenRealPaths: ReadonlySet<string>,+): Promise<(SkillCandidate | null)[]> => {let entries;try {entries = await readdir(sourceRoot, { withFileTypes: true });@@ -168,15 +168,19 @@ const scanSkillsInSource = async ({return [];}- const skills = await Promise.all(+ return Promise.all(entries.filter((entry) => !entry.name.startsWith('.') && (entry.isDirectory() || entry.isSymbolicLink()),)- .map(async (entry): Promise<ProjectSkillItem | null> => {+ .sort((a, b) => a.name.localeCompare(b.name))+ .map(async (entry): Promise<SkillCandidate | null> => {const skillDir = path.join(sourceRoot, entry.name);const skillFile = path.join(skillDir, 'SKILL.md');try {+ const realPath = await realpath(skillFile);+ if (seenRealPaths.has(realPath)) return null;+const raw = await readFile(skillFile, 'utf8');const fields = parseSkillFrontmatter(raw);return {@@ -185,6 +189,7 @@ const scanSkillsInSource = async ({name: fields.name || entry.name,path: skillFile,previewRoot,+ realPath,scope,skillDir,source,@@ -194,19 +199,20 @@ const scanSkillsInSource = async ({}}),);-- return skills.filter((skill): skill is ProjectSkillItem => skill !== null);};const collectSkills = async (roots: SkillScanRoot[]): Promise<ProjectSkillItem[]> => {- const seen = new Set<string>();+ const seenNames = new Set<string>();+ const seenRealPaths = new Set<string>();const skills: ProjectSkillItem[] = [];for (const root of roots) {- for (const skill of await scanSkillsInSource(root)) {- if (seen.has(skill.name)) continue;- seen.add(skill.name);- skills.push(skill);+ for (const skill of await scanSkillsInSource(root, seenRealPaths)) {+ if (!skill || seenNames.has(skill.name) || seenRealPaths.has(skill.realPath)) continue;+ const { realPath, ...item } = skill;+ seenNames.add(item.name);+ seenRealPaths.add(realPath);+ skills.push(item);}}diff --git a/packages/types/src/device.ts b/packages/types/src/device.tsindex 89804b2d7ff..b61510b1840 100644--- a/packages/types/src/device.ts+++ b/packages/types/src/device.ts@@ -25,6 +25,9 @@ export interface DeviceUnavailableErrorData {export type ProjectSkillScope = 'device' | 'project';export type ProjectSkillSource = '.agents/skills' | '.claude/skills' | '.codex/skills';+/** A composer selection by filesystem skill name, before the execution scope is known. */+export const FILESYSTEM_SKILL_SELECTION_PREFIX = 'projectSkill:';+/*** A filesystem skill discovered on the execution device by the client at* request time. Project skills live under the current working directory;@@ -36,6 +39,8 @@ export type ProjectSkillSource = '.agents/skills' | '.claude/skills' | '.codex/sexport interface ProjectSkillMeta {/** Skill description from SKILL.md frontmatter. */description?: string;+ /** SKILL.md declares that the model must not invoke this skill automatically. */+ disableModelInvocation?: boolean;/** Skill name from frontmatter (falls back to the directory name). */name: string;/** Absolute path to the skill's SKILL.md on the device filesystem. */diff --git a/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.gatewaySkills.test.ts b/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.gatewaySkills.test.tsindex 2cf8dbeae37..4baaea7fbab 100644--- a/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.gatewaySkills.test.ts+++ b/src/store/chat/slices/agentRun/actions/__tests__/conversationLifecycle.gatewaySkills.test.ts@@ -71,7 +71,7 @@ describe('sendMessage in gateway mode', () => {//// Before the fix, the server run never injected the skill body.// The fix forwards the picks as `selectedSkillIds`.- it('forwards the selected skills so the server injects their bodies', async () => {+ it('forwards library and filesystem skill chips to the gateway', async () => {const { result } = renderHook(() => useChatStore());const executeGatewayAgentSpy = vi.fn().mockResolvedValue({assistantMessageId: TEST_IDS.ASSISTANT_MESSAGE_ID,@@ -108,6 +108,7 @@ describe('sendMessage in gateway mode', () => {{children: [skillTag('ux-audit', 'UX Audit'),+ { ...skillTag('local-audit', 'Local Audit'), actionCategory: 'projectSkill' },{ text: ' review the page', type: 'text' },skillTag('ux-audit', 'UX Audit'),],@@ -117,12 +118,13 @@ describe('sendMessage in gateway mode', () => {type: 'root',},},- message: '<skill name="ux-audit" label="UX Audit" /> review the page',+ message:+ '<skill name="ux-audit" label="UX Audit" /> <projectSkill name="local-audit" label="Local Audit" /> review the page',});});expect(executeGatewayAgentSpy).toHaveBeenCalledWith(- expect.objectContaining({ selectedSkillIds: ['ux-audit'] }),+ expect.objectContaining({ selectedSkillIds: ['ux-audit', 'projectSkill:local-audit'] }),);});diff --git a/src/store/chat/slices/agentRun/actions/entries/commandBus/index.ts b/src/store/chat/slices/agentRun/actions/entries/commandBus/index.tsindex bd95d2385b5..65bab8c1d32 100644--- a/src/store/chat/slices/agentRun/actions/entries/commandBus/index.ts+++ b/src/store/chat/slices/agentRun/actions/entries/commandBus/index.ts@@ -11,6 +11,7 @@ export {hasNonActionContent,mergeLocalFileReferences,parseCommandsFromEditorData,+ parseGatewaySkillIdsFromEditorData,parseLocalFileReferencesFromEditorData,parseMentionedAgentsFromEditorData,parseSelectedSkillsFromEditorData,diff --git a/src/store/chat/slices/agentRun/actions/entries/commandBus/parseCommands.ts b/src/store/chat/slices/agentRun/actions/entries/commandBus/parseCommands.tsindex 54074638681..dfd897e71c0 100644--- a/src/store/chat/slices/agentRun/actions/entries/commandBus/parseCommands.ts+++ b/src/store/chat/slices/agentRun/actions/entries/commandBus/parseCommands.ts@@ -3,6 +3,7 @@ import type {RuntimeSelectedSkill,RuntimeSelectedTool,} from '@lobechat/types';+import { FILESYSTEM_SKILL_SELECTION_PREFIX } from '@lobechat/types';import type {ActionTagCategory,@@ -80,6 +81,18 @@ export const parseSelectedSkillsFromEditorData = (}, []);};+export const parseGatewaySkillIdsFromEditorData = (+ editorData: Record<string, any> | undefined,+): string[] => {+ const ids = new Set<string>();+ for (const { category, type } of parseActionTagsFromEditorData(editorData)) {+ if (!type) continue;+ if (category === 'skill') ids.add(String(type));+ if (category === 'projectSkill') ids.add(FILESYSTEM_SKILL_SELECTION_PREFIX + type);+ }+ return [...ids];+};+export const parseSelectedToolsFromEditorData = (editorData: Record<string, any> | undefined,): RuntimeSelectedTool[] => {diff --git a/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle/index.ts b/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle/index.tsindex d9a14e614bd..716747de31a 100644--- a/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle/index.ts+++ b/src/store/chat/slices/agentRun/actions/entries/conversationLifecycle/index.ts@@ -118,6 +118,7 @@ import {hasNonActionContent,injectReferTopicNode,mergeLocalFileReferences,+ parseGatewaySkillIdsFromEditorData,parseLocalFileReferencesFromEditorData,parseMentionedAgentsFromEditorData,parseSelectedSkillsFromEditorData,@@ -338,6 +339,7 @@ export class ConversationLifecycleActionImpl {const targetInputEditor = inputEditor === undefined ? mainInputEditor : inputEditor;const ownerAgentId = context.agentId;const selectedSkills = parseSelectedSkillsFromEditorData(editorData);+ const selectedSkillIds = parseGatewaySkillIdsFromEditorData(editorData);const selectedTools = parseSelectedToolsFromEditorData(editorData);if (isGoalPrompt(message) &&@@ -685,7 +687,7 @@ export class ConversationLifecycleActionImpl {mentionedAgents: hasMentionedAgents ? mentionedAgents : undefined,message,pageSelections,- selectedSkillIds: selectedSkills.map((skill) => skill.identifier),+ selectedSkillIds,selectedToolIds: selectedTools.map((tool) => tool.identifier),trigger: requestTrigger,}),@@ -1241,7 +1243,7 @@ export class ConversationLifecycleActionImpl {fileIds: fileIdList,mentionedAgents: hasMentionedAgents ? mentionedAgents : undefined,prompt: message,- selectedSkillIds: selectedSkills.map(({ identifier }) => identifier),+ selectedSkillIds,selectedToolIds: selectedTools.map(({ identifier }) => identifier),topicId: mintedTopicId ?? generateEntityId('topics'),userInterventionConfig: resolveUserInterventionConfig(),@@ -1645,10 +1647,8 @@ export class ConversationLifecycleActionImpl {// selection (only the client runtime did). Omit when empty.selectedToolIds:selectedTools.length > 0 ? selectedTools.map((tool) => tool.identifier) : undefined,- // Forward selected skills so the server injects their bodies, as the- // client runtime does by persisting them into the message content.- selectedSkillIds:- selectedSkills.length > 0 ? selectedSkills.map((skill) => skill.identifier) : undefined,+ // Forward both library and filesystem skill selections to the server.+ selectedSkillIds: selectedSkillIds.length ? selectedSkillIds : undefined,// Forward @-mentioned agents so the server supervisor can delegate to// them (multi-mention). Mirrors the client runtime's `initialContext`// injection: the server enables the callAgent tool and injects the