Skip to content

🤯 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.

✨ feat(hetero): surface project skills in working sidebar + markdown preview (#14896)

Arvin Xu4766bb3eb3a6
diff --git a/apps/desktop/src/main/controllers/LocalFileCtr.ts b/apps/desktop/src/main/controllers/LocalFileCtr.ts
index 7d59c4db092..a3e9b39a707 100644
--- a/apps/desktop/src/main/controllers/LocalFileCtr.ts
+++ b/apps/desktop/src/main/controllers/LocalFileCtr.ts
@@ -1,5 +1,5 @@
import { constants } from 'node:fs';
-import { access, mkdir, readFile, realpath, rm, stat, writeFile } from 'node:fs/promises';
+import { access, mkdir, readdir, readFile, realpath, rm, stat, writeFile } from 'node:fs/promises';
import path from 'node:path';
import {
@@ -12,6 +12,8 @@ import {
type GrepContentParams,
type GrepContentResult,
type ListLocalFileParams,
+ type ListProjectSkillsParams,
+ type ListProjectSkillsResult,
type LocalFilePreviewUrlParams,
type LocalFilePreviewUrlResult,
type LocalMoveFilesResultItem,
@@ -120,6 +122,62 @@ const collectProjectDirectories = (files: string[], root: string): ProjectFileIn
return [...directories].map((directory) => createProjectFileEntry(root, directory, true));
};
+const SKILL_FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---/;
+
+// Cap recursion to guard against pathological directory trees.
+const MAX_SKILL_FILE_COUNT = 1000;
+
+const listSkillFilesRecursive = async (dir: string): Promise<string[]> => {
+ const results: string[] = [];
+ const stack: string[] = [dir];
+
+ while (stack.length > 0 && results.length < MAX_SKILL_FILE_COUNT) {
+ const current = stack.pop()!;
+ let entries;
+ try {
+ entries = await readdir(current, { withFileTypes: true });
+ } catch {
+ continue;
+ }
+ for (const entry of entries) {
+ if (entry.name.startsWith('.')) continue;
+ const full = path.join(current, entry.name);
+ if (entry.isDirectory()) {
+ stack.push(full);
+ } else if (entry.isFile()) {
+ results.push(toPosixRelativePath(path.relative(dir, full)));
+ if (results.length >= MAX_SKILL_FILE_COUNT) break;
+ }
+ }
+ }
+ return results.sort();
+};
+
+// Parse a minimal YAML frontmatter block for SKILL.md files.
+// Only handles `key: value` lines; multi-line block scalars fall back to the first line.
+const parseSkillFrontmatter = (raw: string): Record<string, string> => {
+ const match = raw.match(SKILL_FRONTMATTER_RE);
+ if (!match) return {};
+
+ const fields: Record<string, string> = {};
+ for (const line of match[1].split(/\r?\n/)) {
+ const colonIdx = line.indexOf(':');
+ if (colonIdx === -1) continue;
+ const key = line.slice(0, colonIdx).trim();
+ if (!key || key.startsWith('#')) continue;
+ let value = line.slice(colonIdx + 1).trim();
+ if (value.startsWith('|') || value.startsWith('>')) continue;
+ if (
+ (value.startsWith('"') && value.endsWith('"')) ||
+ (value.startsWith("'") && value.endsWith("'"))
+ ) {
+ value = value.slice(1, -1);
+ }
+ fields[key] = value;
+ }
+ return fields;
+};
+
const createDetectedProjectFileEntry = async (
root: string,
absolutePath: string,
@@ -596,6 +654,61 @@ export default class LocalFileCtr extends ControllerModule {
};
}
+ /**
+ * Scan agent skill directories under the project root and return parsed
+ * frontmatter for each SKILL.md. Used by the hetero agent's working sidebar
+ * to surface skills available in the current project.
+ */
+ @IpcMethod()
+ async listProjectSkills(params: ListProjectSkillsParams): Promise<ListProjectSkillsResult> {
+ const root = params.scope;
+ const sources = ['.agents/skills', '.claude/skills'] as const;
+
+ for (const source of sources) {
+ const dir = path.join(root, source);
+ try {
+ const entries = await readdir(dir, { withFileTypes: true });
+ const skills = (
+ await Promise.all(
+ entries
+ .filter((entry) => entry.isDirectory() || entry.isSymbolicLink())
+ .map(async (entry) => {
+ const skillDir = path.join(dir, entry.name);
+ const skillFile = path.join(skillDir, 'SKILL.md');
+ try {
+ const raw = await readFile(skillFile, 'utf8');
+ const fields = parseSkillFrontmatter(raw);
+ const files = await listSkillFilesRecursive(skillDir);
+ return {
+ description: fields.description || undefined,
+ fileCount: files.length,
+ files,
+ name: fields.name || entry.name,
+ path: skillFile,
+ skillDir,
+ source,
+ };
+ } catch {
+ return null;
+ }
+ }),
+ )
+ )
+ .filter((skill): skill is NonNullable<typeof skill> => skill !== null)
+ .sort((a, b) => a.name.localeCompare(b.name));
+
+ if (skills.length > 0) {
+ await this.approveProjectRootForPreview(root);
+ return { root, skills, source };
+ }
+ } catch {
+ // Directory does not exist or is not readable; try the next candidate.
+ }
+ }
+
+ return { root, skills: [], source: null };
+ }
+
/**
* Handle IPC event for local file search
*/
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 402b5077564..1fe13bf5abc 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -891,6 +891,8 @@
"workingPanel.localFile.closeOther": "Close Others",
"workingPanel.localFile.closeRight": "Close to the Right",
"workingPanel.localFile.error": "Couldn't load this file",
+ "workingPanel.localFile.preview.raw": "Raw",
+ "workingPanel.localFile.preview.render": "Preview",
"workingPanel.localFile.truncated": "File preview truncated to {{limit}} characters",
"workingPanel.progress": "Progress",
"workingPanel.progress.allCompleted": "All tasks completed",
@@ -956,6 +958,8 @@
"workingPanel.review.viewMode.unified": "Switch to unified view",
"workingPanel.review.wordWrap.disable": "Disable word wrap",
"workingPanel.review.wordWrap.enable": "Enable word wrap",
+ "workingPanel.skills.empty": "No skills found in this project",
+ "workingPanel.skills.title": "Skills",
"workingPanel.space": "Space",
"workingPanel.title": "Working Panel",
"you": "You",
diff --git a/locales/en-US/editor.json b/locales/en-US/editor.json
index 657561a7772..d5464989555 100644
--- a/locales/en-US/editor.json
+++ b/locales/en-US/editor.json
@@ -1,8 +1,10 @@
{
"actionTag.category.command": "Command",
+ "actionTag.category.projectSkill": "Project skill",
"actionTag.category.skill": "Skill",
"actionTag.category.tool": "Tool",
"actionTag.tooltip.command": "Runs a client-side slash command before sending.",
+ "actionTag.tooltip.projectSkill": "Sent as a slash invocation so the agent's CLI runs the matching project skill.",
"actionTag.tooltip.skill": "Loads a reusable skill package for this request.",
"actionTag.tooltip.tool": "Marks a tool the user explicitly selected for this request.",
"actions.expand.off": "Collapse",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 46a977eef4e..afd4c1f2caa 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -891,6 +891,8 @@
"workingPanel.localFile.closeOther": "关闭其他",
"workingPanel.localFile.closeRight": "关闭右侧",
"workingPanel.localFile.error": "无法加载此文件",
+ "workingPanel.localFile.preview.raw": "原文",
+ "workingPanel.localFile.preview.render": "预览",
"workingPanel.localFile.truncated": "文件预览被截断至 {{limit}} 个字符",
"workingPanel.progress": "进度",
"workingPanel.progress.allCompleted": "所有任务已完成",
@@ -956,6 +958,8 @@
"workingPanel.review.viewMode.unified": "切换到合并视图",
"workingPanel.review.wordWrap.disable": "关闭自动换行",
"workingPanel.review.wordWrap.enable": "启用自动换行",
+ "workingPanel.skills.empty": "当前项目未发现 Skills",
+ "workingPanel.skills.title": "Skills",
"workingPanel.space": "空间",
"workingPanel.title": "工作面板",
"you": "你",
diff --git a/locales/zh-CN/editor.json b/locales/zh-CN/editor.json
index 3c4d5918237..d561d93afa4 100644
--- a/locales/zh-CN/editor.json
+++ b/locales/zh-CN/editor.json
@@ -1,8 +1,10 @@
{
"actionTag.category.command": "指令",
+ "actionTag.category.projectSkill": "项目技能",
"actionTag.category.skill": "技能",
"actionTag.category.tool": "工具",
"actionTag.tooltip.command": "发送前会先在客户端执行这条 slash 指令。",
+ "actionTag.tooltip.projectSkill": "以 slash 形式发送,由 Agent CLI 自行识别并执行项目内的对应技能。",
"actionTag.tooltip.skill": "表示这是一条可为本次请求加载的技能包。",
"actionTag.tooltip.tool": "表示这是用户为本次请求显式选中的工具。",
"actions.expand.off": "收起",
diff --git a/packages/builtin-tool-claude-code/src/client/Inspector/Task.tsx b/packages/builtin-tool-claude-code/src/client/Inspector/Task.tsx
index 91abe890f57..680ace25332 100644
--- a/packages/builtin-tool-claude-code/src/client/Inspector/Task.tsx
+++ b/packages/builtin-tool-claude-code/src/client/Inspector/Task.tsx
@@ -35,6 +35,19 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
background: ${cssVar.colorFillSecondary};
`,
+ countChip: css`
+ flex-shrink: 0;
+
+ padding-block: 1px;
+ padding-inline: 6px;
+ border-radius: 999px;
+
+ font-family: ${cssVar.fontFamilyCode};
+ font-size: 12px;
+ color: ${cssVar.colorTextSecondary};
+
+ background: ${cssVar.colorFillTertiary};
+ `,
ring: css`
transform: rotate(-90deg);
flex-shrink: 0;
@@ -157,9 +170,12 @@ export const TaskInspector = memo<BuiltinInspectorProps<TaskInspectorArgs, TaskP
const stats = useMemo(() => computeStats(items), [items]);
const allDone = stats.total > 0 && stats.completed === stats.total;
- // TaskCreate: chip always identifies the task being added, not the
- // accumulated todo count. Drop the aggregate path entirely so the
- // chip stays informative whether or not pluginState is populated yet.
+ // TaskCreate: chip identifies the task being added, not the accumulated
+ // count — keep `Creating task: <subject>` as the label so per-row signal
+ // stays sharp. The ProgressRing is rendered from the cumulative
+ // pluginState snapshot; the trailing `completed/total` chip makes the
+ // accumulation visible across rows (the ring alone stays empty while
+ // every new task is still `todo`, so total wouldn't otherwise show).
if (apiName === ClaudeCodeApiName.TaskCreate) {
const subject = ((args || partialArgs) as TaskCreateArgs | undefined)?.subject;
const text = subject
@@ -172,7 +188,13 @@ export const TaskInspector = memo<BuiltinInspectorProps<TaskInspectorArgs, TaskP
(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,
)}
>
- {text}
+ <ProgressRing stats={stats} />
+ {stats.total > 0 && (
+ <span className={styles.countChip}>
+ {stats.completed}/{stats.total}
+ </span>
+ )}
+ <span style={{ marginInlineStart: 6 }}>{text}</span>
</div>
);
}
@@ -184,6 +206,9 @@ export const TaskInspector = memo<BuiltinInspectorProps<TaskInspectorArgs, TaskP
// is the resume-gap fallback when the snapshot hasn't been built yet.
// Cryptic `#N` is intentionally NOT user-facing — fall back to the bare
// verb if subject is missing (rare; happens before first pluginState).
+ // Leading slot is the same ProgressRing as TaskCreate so the left edge
+ // of a mixed create/update column reads as one continuous progress
+ // gauge — the verb in the label carries the per-row status signal.
// TaskUpdate without `status` (metadata-only edit) falls through to the
// aggregate path — no single-word verb describes those.
if (apiName === ClaudeCodeApiName.TaskUpdate) {
@@ -209,7 +234,15 @@ export const TaskInspector = memo<BuiltinInspectorProps<TaskInspectorArgs, TaskP
(isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,
)}
>
- {subject ? `${verb}: ${subject}` : verb}
+ <ProgressRing stats={stats} />
+ {stats.total > 0 && (
+ <span className={styles.countChip}>
+ {stats.completed}/{stats.total}
+ </span>
+ )}
+ <span style={{ marginInlineStart: stats.total > 0 ? 6 : 0 }}>
+ {subject ? `${verb}: ${subject}` : verb}
+ </span>
</div>
);
}
diff --git a/packages/electron-client-ipc/src/types/localSystem.ts b/packages/electron-client-ipc/src/types/localSystem.ts
index ff6e1b4fb58..11071adfeec 100644
--- a/packages/electron-client-ipc/src/types/localSystem.ts
+++ b/packages/electron-client-ipc/src/types/localSystem.ts
@@ -410,3 +410,33 @@ export interface ResolveSkillResourcePathResult {
fullPath?: string;
success: boolean;
}
+
+export interface ProjectSkillItem {
+ description?: string;
+ /** Total number of regular files under `skillDir` (recursive, including `SKILL.md`). */
+ fileCount: number;
+ /**
+ * Relative paths (within `skillDir`) of all regular files under the skill,
+ * sorted lexicographically and capped to a safe maximum. Includes `SKILL.md`.
+ */
+ files: string[];
+ name: string;
+ /** Absolute path to the SKILL.md file. */
+ path: string;
+ /** Directory containing the SKILL.md (e.g. `<root>/.agents/skills/spa-routes`). */
+ skillDir: string;
+ /** Source directory the skill was discovered in. */
+ source: '.agents/skills' | '.claude/skills';
+}
+
+export interface ListProjectSkillsParams {
+ /** Working directory used to resolve the project root. */
+ scope: string;
+}
+
+export interface ListProjectSkillsResult {
+ root: string;
+ skills: ProjectSkillItem[];
+ /** Source directory actually scanned (after fallback resolution). */
+ source: ProjectSkillItem['source'] | null;
+}
diff --git a/src/features/ChatInput/InputEditor/ActionTag/ActionTagPlugin.ts b/src/features/ChatInput/InputEditor/ActionTag/ActionTagPlugin.ts
index a5359b1e86f..e7f4da66879 100644
--- a/src/features/ChatInput/InputEditor/ActionTag/ActionTagPlugin.ts
+++ b/src/features/ChatInput/InputEditor/ActionTag/ActionTagPlugin.ts
@@ -53,8 +53,11 @@ export class ActionTagPlugin {
const mdService = this.kernel.requireService(IMarkdownShortCutService);
// Writer: ActionTagNode → markdown
- // Skills → <skill name="..." label="..." />, Tools → <tool name="..." label="..." />
- // Commands fall back to <action type="..." category="command" label="..." />
+ // Skills → <skill name="..." label="..." />
+ // Tools → <tool name="..." label="..." />
+ // ProjectSkill → bare label text (e.g. `/local-testing`) so the downstream
+ // CLI agent recognizes its own slash-style skill invocation
+ // Commands → <action type="..." category="command" label="..." />
mdService?.registerMarkdownWriter(ActionTagNode.getType(), (ctx: any, node: any) => {
if ($isActionTagNode(node)) {
const cat = node.actionCategory;
@@ -62,6 +65,10 @@ export class ActionTagPlugin {
ctx.appendLine(`<skill name="${node.actionType}" label="${node.actionLabel}" />`);
} else if (cat === 'tool') {
ctx.appendLine(`<tool name="${node.actionType}" label="${node.actionLabel}" />`);
+ } else if (cat === 'projectSkill') {
+ // Chip / menu render the bare skill name; the slash is added here so
+ // the downstream CLI sees `/skill-name` as a slash invocation.
+ ctx.appendLine(`/${node.actionType}`);
} else {
ctx.appendLine(
`<action type="${node.actionType}" category="${cat}" label="${node.actionLabel}" />`,
@@ -83,6 +90,12 @@ export class ActionTagPlugin {
if (cat === 'tool') {
return ctx.createXmlNode('tool', { label: node.actionLabel, name: node.actionType });
}
+ if (cat === 'projectSkill') {
+ return ctx.createXmlNode('projectSkill', {
+ label: node.actionLabel,
+ name: node.actionType,
+ });
+ }
return ctx.createXmlNode('action', {
category: cat,
label: node.actionLabel,
@@ -92,7 +105,7 @@ export class ActionTagPlugin {
return false;
});
- // Read <skill>, <tool>, and legacy <action> tags
+ // Read <skill>, <tool>, <projectSkill>, and legacy <action> tags
const readSkill = (xmlElement: any): SerializedActionTagNode => ({
actionCategory: 'skill',
actionLabel: xmlElement.getAttribute('label') || '',
@@ -107,6 +120,13 @@ export class ActionTagPlugin {
type: ActionTagNode.getType(),
version: 1,
});
+ const readProjectSkill = (xmlElement: any): SerializedActionTagNode => ({
+ actionCategory: 'projectSkill',
+ actionLabel: xmlElement.getAttribute('label') || '',
+ actionType: (xmlElement.getAttribute('name') || '') as ActionTagType,
+ type: ActionTagNode.getType(),
+ version: 1,
+ });
const readLegacyAction = (xmlElement: any): SerializedActionTagNode => ({
actionCategory: (xmlElement.getAttribute('category') || 'skill') as ActionTagCategory,
actionLabel: xmlElement.getAttribute('label') || '',
@@ -117,6 +137,7 @@ export class ActionTagPlugin {
xmlService?.registerXMLReader('skill', readSkill);
xmlService?.registerXMLReader('tool', readTool);
+ xmlService?.registerXMLReader('projectSkill', readProjectSkill);
xmlService?.registerXMLReader('action', readLegacyAction);
}
diff --git a/src/features/ChatInput/InputEditor/ActionTag/ActionTagView.tsx b/src/features/ChatInput/InputEditor/ActionTag/ActionTagView.tsx
index 6ab505eb87c..5f71fa0cd00 100644
--- a/src/features/ChatInput/InputEditor/ActionTag/ActionTagView.tsx
+++ b/src/features/ChatInput/InputEditor/ActionTag/ActionTagView.tsx
@@ -13,24 +13,31 @@ export interface ActionTagViewProps {
const CATEGORY_COLOR: Record<ActionTagCategory, string> = {
command: 'purple',
+ projectSkill: 'green',
skill: 'blue',
tool: 'gold',
};
const CATEGORY_I18N_KEY: Record<ActionTagCategory, string> = {
command: 'actionTag.category.command',
+ projectSkill: 'actionTag.category.projectSkill',
skill: 'actionTag.category.skill',
tool: 'actionTag.category.tool',
};
const CATEGORY_TOOLTIP_I18N_KEY: Record<ActionTagCategory, string> = {
command: 'actionTag.tooltip.command',
+ projectSkill: 'actionTag.tooltip.projectSkill',
skill: 'actionTag.tooltip.skill',
tool: 'actionTag.tooltip.tool',
};
-const CATEGORY_STYLE_KEY: Record<ActionTagCategory, 'commandTag' | 'skillTag' | 'toolTag'> = {
+const CATEGORY_STYLE_KEY: Record<
+ ActionTagCategory,
+ 'commandTag' | 'projectSkillTag' | 'skillTag' | 'toolTag'
+> = {
command: 'commandTag',
+ projectSkill: 'projectSkillTag',
skill: 'skillTag',
tool: 'toolTag',
};
diff --git a/src/features/ChatInput/InputEditor/ActionTag/style.ts b/src/features/ChatInput/InputEditor/ActionTag/style.ts
index 8b9668048fb..3bb05ee0525 100644
--- a/src/features/ChatInput/InputEditor/ActionTag/style.ts
+++ b/src/features/ChatInput/InputEditor/ActionTag/style.ts
@@ -18,6 +18,9 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
commandTag: css`
${tagBase('#722ED1', cssVar.borderRadius)}
`,
+ projectSkillTag: css`
+ ${tagBase(cssVar.colorSuccess, cssVar.borderRadius)}
+ `,
skillTag: css`
${tagBase(cssVar.colorPrimary, cssVar.borderRadius)}
`,
diff --git a/src/features/ChatInput/InputEditor/ActionTag/types.ts b/src/features/ChatInput/InputEditor/ActionTag/types.ts
index 9c6f1869a31..4f311d6b5a7 100644
--- a/src/features/ChatInput/InputEditor/ActionTag/types.ts
+++ b/src/features/ChatInput/InputEditor/ActionTag/types.ts
@@ -1,11 +1,14 @@
/**
* Action tag architecture:
*
- * 1. Command — Built-in, line-start only (slash menu), executed client-side before send
- * 2. Skill — Skill package, inserted via @ mention, preloaded before execution
- * 3. Tool — Explicit tool selection, inserted via @ mention, context injected directly
+ * 1. Command — Built-in, line-start only (slash menu), executed client-side before send
+ * 2. Skill — Skill package, inserted via @ mention, preloaded before execution
+ * 3. Tool — Explicit tool selection, inserted via @ mention, context injected directly
+ * 4. ProjectSkill — Hetero-agent project skill (e.g. `.agents/skills/<name>/SKILL.md`),
+ * inserted via slash menu, serialized as literal `/skill-name` so the
+ * underlying CLI agent resolves and runs the skill itself.
*/
-export type ActionTagCategory = 'command' | 'skill' | 'tool';
+export type ActionTagCategory = 'command' | 'skill' | 'tool' | 'projectSkill';
// Built-in commands: client-side intercepted, never sent to AI
export type CommandType = 'compact' | 'newTopic';
diff --git a/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts b/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts
index b70ca9d8864..6857d4b760f 100644
--- a/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts
+++ b/src/features/ChatInput/InputEditor/ActionTag/useSlashActionItems.ts
@@ -1,12 +1,21 @@
+import { isDesktop } from '@lobechat/const';
+import { type ListProjectSkillsResult, type ProjectSkillItem } from '@lobechat/electron-client-ipc';
import type { IEditor, SlashOptions } from '@lobehub/editor';
+import { SkillsIcon } from '@lobehub/ui/icons';
import Fuse from 'fuse.js';
import { $getSelection, $isRangeSelection } from 'lexical';
import { ArchiveIcon, MessageSquarePlusIcon } from 'lucide-react';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
+import { useClientDataSWR } from '@/libs/swr';
+import { localFileService } from '@/services/electron/localFileService';
+import { useAgentStore } from '@/store/agent';
+import { agentByIdSelectors } from '@/store/agent/selectors';
import { useChatStore } from '@/store/chat';
+import { topicSelectors } from '@/store/chat/selectors';
+import { useAgentId } from '../../hooks/useAgentId';
import { useChatInputStore } from '../../store';
import { INSERT_ACTION_TAG_COMMAND, type InsertActionTagPayload } from './command';
import { type ActionTagData, BUILTIN_COMMANDS } from './types';
@@ -31,6 +40,26 @@ export const useSlashActionItems = (): SlashOptions['items'] => {
const editorInstance = useChatInputStore((s) => s.editor);
const activeTopicId = useChatStore((s) => s.activeTopicId);
+ // Resolve hetero-agent working directory so we can surface its project skills.
+ // Topic-level override takes precedence over the agent's configured cwd.
+ const agentId = useAgentId();
+ const isHetero = useAgentStore((s) =>
+ agentId ? !!agentByIdSelectors.getAgencyConfigById(agentId)(s)?.heterogeneousProvider : false,
+ );
+ const agentWorkingDirectory = useAgentStore((s) =>
+ agentId ? agentByIdSelectors.getAgentWorkingDirectoryById(agentId)(s) : undefined,
+ );
+ const topicWorkingDirectory = useChatStore(topicSelectors.currentTopicWorkingDirectory);
+ const workingDirectory = topicWorkingDirectory || agentWorkingDirectory;
+
+ const skillsEnabled = isDesktop && isHetero && !!workingDirectory;
+ const { data: projectSkillsData } = useClientDataSWR<ListProjectSkillsResult>(
+ skillsEnabled ? ['project-skills', workingDirectory] : null,
+ () => localFileService.listProjectSkills({ scope: workingDirectory! }),
+ { revalidateOnFocus: false, shouldRetryOnError: false },
+ );
+ const projectSkills = projectSkillsData?.skills;
+
return useCallback(
async (
search: { leadOffset: number; matchingString: string; replaceableString: string } | null,
@@ -52,6 +81,27 @@ export const useSlashActionItems = (): SlashOptions['items'] => {
},
});
+ const makeProjectSkillItem = (skill: ProjectSkillItem): SlashMenuOption => ({
+ // Slash is already implied by the trigger + tag color, so we render the
+ // bare skill name here. The markdown writer adds the `/` back on send.
+ icon: SkillsIcon,
+ key: `project-skill-${skill.name}`,
+ label: skill.name,
+ metadata: {
+ category: 'projectSkill',
+ description: skill.description,
+ type: skill.name,
+ },
+ onSelect: (editor: IEditor) => {
+ const payload: InsertActionTagPayload = {
+ category: 'projectSkill',
+ label: skill.name,
+ type: skill.name,
+ };
+ editor.dispatchCommand(INSERT_ACTION_TAG_COMMAND, payload);
+ },
+ });
+
// All action tags are line-start only for now
let isAtLineStart = search === null;
if (!isAtLineStart && editorInstance) {
@@ -74,12 +124,19 @@ export const useSlashActionItems = (): SlashOptions['items'] => {
if (!isAtLineStart) return [];
- // Built-in commands only (filter newTopic when no active topic)
+ // Built-in commands (filter newTopic when no active topic)
for (const action of BUILTIN_COMMANDS) {
if (action.type === 'newTopic' && !activeTopicId) continue;
allItems.push(makeCommandItem(action) as SlashItem);
}
+ // Hetero-agent project skills (file-system based, resolved by the CLI agent itself)
+ if (projectSkills && projectSkills.length > 0) {
+ for (const skill of projectSkills) {
+ allItems.push(makeProjectSkillItem(skill) as SlashItem);
+ }
+ }
+
// Fuzzy filtering
if (search?.matchingString && search.matchingString.length > 0) {
const fuse = new Fuse(allItems, { keys: ['key', 'label'], threshold: 0.4 });
@@ -88,6 +145,6 @@ export const useSlashActionItems = (): SlashOptions['items'] => {
return allItems;
},
- [t, editorInstance, activeTopicId],
+ [t, editorInstance, activeTopicId, projectSkills],
);
};
diff --git a/src/features/Portal/LocalFile/Body.tsx b/src/features/Portal/LocalFile/Body.tsx
index 2c687ecc7e6..dd569c9ae44 100644
--- a/src/features/Portal/LocalFile/Body.tsx
+++ b/src/features/Portal/LocalFile/Body.tsx
@@ -1,6 +1,8 @@
import { isDesktop } from '@lobechat/const';
-import { Center, Empty, Flexbox, Highlighter } from '@lobehub/ui';
-import { memo, useEffect, useState } from 'react';
+import { Center, Empty, Flexbox, Highlighter, Icon, Markdown, Segmented, Text } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { CodeIcon, EyeIcon } from 'lucide-react';
+import { memo, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import Loading from '@/components/Loading/CircleLoading';
@@ -8,6 +10,12 @@ import { useClientDataSWR } from '@/libs/swr';
import { localFileService } from '@/services/electron/localFileService';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
+import {
+ parseSkillMarkdownFrontmatter,
+ parseSkillMarkdownFrontmatterFields,
+ parseSkillMarkdownMetadata,
+ type SkillMarkdownMetadataItem,
+} from '@/utils/skillMarkdown';
import { extensionToLanguage, getFileExtension } from './Body.helpers';
@@ -98,6 +106,157 @@ const ImagePreview = memo<ImagePreviewProps>(({ blob, filename }) => {
ImagePreview.displayName = 'ImagePreview';
+// ============== TextPreviewPane ==============
+
+const MARKDOWN_EXTS = new Set(['md', 'mdx', 'markdown']);
+
+const frontmatterStyles = createStaticStyles(({ css }) => ({
+ card: css`
+ margin-block: 8px 12px;
+ margin-inline: 12px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: 8px;
+
+ background: ${cssVar.colorBgContainer};
+ `,
+ key: css`
+ flex-shrink: 0;
+
+ width: 96px;
+
+ font-family: ${cssVar.fontFamilyCode};
+ font-size: 12px;
+ color: ${cssVar.colorTextSecondary};
+ `,
+ row: css`
+ padding-block: 8px;
+ padding-inline: 12px;
+
+ &:not(:last-child) {
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
+ }
+ `,
+ value: css`
+ min-width: 0;
+ font-size: 12px;
+ white-space: pre-wrap;
+ `,
+}));
+
+interface SkillFrontmatterPreviewCardProps {
+ metadata: SkillMarkdownMetadataItem[];
+}
+
+const SkillFrontmatterPreviewCard = memo<SkillFrontmatterPreviewCardProps>(({ metadata }) => {
+ if (metadata.length === 0) return null;
+
+ return (
+ <Flexbox className={frontmatterStyles.card} style={{ flexShrink: 0 }}>
+ {metadata.map((item) => (
+ <Flexbox horizontal align={'flex-start'} className={frontmatterStyles.row} key={item.key}>
+ <Text className={frontmatterStyles.key}>{item.key}</Text>
+ <Text className={frontmatterStyles.value}>{item.value}</Text>
+ </Flexbox>
+ ))}
+ </Flexbox>
+ );
+});
+
+SkillFrontmatterPreviewCard.displayName = 'SkillFrontmatterPreviewCard';
+
+type TextPreviewMode = 'render' | 'raw';
+
+interface TextPreviewPaneProps {
+ content: string;
+ ext: string;
+ truncated: boolean;
+ truncatedLabel: string;
+}
+
+const TextPreviewPane = memo<TextPreviewPaneProps>(
+ ({ content, ext, truncated, truncatedLabel }) => {
+ const { t } = useTranslation('chat');
+ const isMarkdown = useMemo(() => MARKDOWN_EXTS.has(ext.toLowerCase()), [ext]);
+
+ const { body, frontmatter } = useMemo(
+ () => (isMarkdown ? parseSkillMarkdownFrontmatter(content) : { body: content }),
+ [isMarkdown, content],
+ );
+ const frontmatterFields = useMemo(
+ () => (frontmatter ? parseSkillMarkdownFrontmatterFields(frontmatter) : {}),
+ [frontmatter],
+ );
+ const frontmatterMetadata = useMemo(
+ () => (frontmatter ? parseSkillMarkdownMetadata(frontmatter) : []),
+ [frontmatter],
+ );
+
+ const [mode, setMode] = useState<TextPreviewMode>(isMarkdown ? 'render' : 'raw');
+
+ useEffect(() => {
+ setMode(isMarkdown ? 'render' : 'raw');
+ }, [isMarkdown]);
+
+ return (
+ <Flexbox flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'hidden' }}>
+ {isMarkdown && (
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={8}
+ paddingBlock={6}
+ paddingInline={12}
+ style={{ flexShrink: 0 }}
+ >
+ <Text ellipsis style={{ flex: 1, fontSize: 13, fontWeight: 500, minWidth: 0 }}>
+ {frontmatterFields.name ?? ''}
+ </Text>
+ <Segmented
+ size={'small'}
+ value={mode}
+ options={[
+ {
+ icon: <Icon icon={EyeIcon} />,
+ label: t('workingPanel.localFile.preview.render'),
+ value: 'render',
+ },
+ {
+ icon: <Icon icon={CodeIcon} />,
+ label: t('workingPanel.localFile.preview.raw'),
+ value: 'raw',
+ },
+ ]}
+ onChange={(v) => setMode(v as TextPreviewMode)}
+ />
+ </Flexbox>
+ )}
+ {truncated && (
+ <Center paddingBlock={4} style={{ flexShrink: 0 }}>
+ <span style={{ fontSize: 12, opacity: 0.65 }}>{truncatedLabel}</span>
+ </Center>
+ )}
+ <Flexbox flex={1} style={{ minHeight: 0, overflow: 'auto' }}>
+ {isMarkdown && mode === 'render' ? (
+ <>
+ <SkillFrontmatterPreviewCard metadata={frontmatterMetadata} />
+ <Markdown style={{ paddingBlock: 8, paddingInline: 12 }}>{body}</Markdown>
+ </>
+ ) : (
+ <Highlighter
+ language={extensionToLanguage(ext)}
+ style={{ fontSize: 12, minHeight: '100%' }}
+ >
+ {content}
+ </Highlighter>
+ )}
+ </Flexbox>
+ </Flexbox>
+ );
+ },
+);
+
+TextPreviewPane.displayName = 'TextPreviewPane';
+
// ============== ActiveFileView ==============
interface ActiveFileViewProps {
@@ -167,23 +326,14 @@ const ActiveFileView = memo<ActiveFileViewProps>(({ filePath, workingDirectory }
const displayContent = truncated ? preview.content.slice(0, MAX_PREVIEW_CHARS) : preview.content;
return (
- <Flexbox flex={1} height={'100%'} style={{ minHeight: 0, overflow: 'auto' }}>
- {truncated && (
- <Center paddingBlock={4} style={{ flexShrink: 0 }}>
- <span style={{ fontSize: 12, opacity: 0.65 }}>
- {t('workingPanel.localFile.truncated', { limit: MAX_PREVIEW_CHARS.toLocaleString() })}
- </span>
- </Center>
- )}
- <Flexbox flex={1} style={{ minHeight: 0, overflow: 'auto' }}>
- <Highlighter
- language={extensionToLanguage(ext)}
- style={{ fontSize: 12, minHeight: '100%', overflow: 'visible' }}
- >
- {displayContent}
- </Highlighter>
- </Flexbox>
- </Flexbox>
+ <TextPreviewPane
+ content={displayContent}
+ ext={ext}
+ truncated={truncated}
+ truncatedLabel={t('workingPanel.localFile.truncated', {
+ limit: MAX_PREVIEW_CHARS.toLocaleString(),
+ })}
+ />
);
});
diff --git a/src/features/Portal/LocalFile/TabStrip.tsx b/src/features/Portal/LocalFile/TabStrip.tsx
index 02a6732780b..427526e8d8e 100644
--- a/src/features/Portal/LocalFile/TabStrip.tsx
+++ b/src/features/Portal/LocalFile/TabStrip.tsx
@@ -1,15 +1,23 @@
'use client';
-import { ContextMenuTrigger, type GenericItemType } from '@lobehub/ui';
+import { ContextMenuTrigger, type GenericItemType, Icon } from '@lobehub/ui';
import { ScrollArea } from '@lobehub/ui/base-ui';
+import { SkillsIcon } from '@lobehub/ui/icons';
import { createStaticStyles } from 'antd-style';
-import { XIcon } from 'lucide-react';
+import { FileIcon, XIcon } from 'lucide-react';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useChatStore } from '@/store/chat';
import { chatPortalSelectors } from '@/store/chat/selectors';
+const SKILL_PATH_RE = /\/\.(?:agents|claude)\/skills\/([^/]+)\/SKILL\.md$/;
+
+const resolveSkillName = (filePath: string): string | null => {
+ const match = filePath.match(SKILL_PATH_RE);
+ return match ? match[1] : null;
+};
+
const styles = createStaticStyles(({ css, cssVar }) => ({
tabClose: css`
cursor: pointer;
@@ -154,6 +162,8 @@ const TabStrip = memo(() => {
>
{openLocalFiles.map(({ filePath }, index) => {
const filename = filePath.split('/').at(-1) ?? filePath;
+ const skillName = resolveSkillName(filePath);
+ const label = skillName ?? filename;
const isActive = filePath === activeLocalFilePath;
return (
@@ -172,7 +182,8 @@ const TabStrip = memo(() => {
}
}}
>
- <span className={styles.tabLabel}>{filename}</span>
+ <Icon icon={skillName ? SkillsIcon : FileIcon} size={12} />
+ <span className={styles.tabLabel}>{label}</span>
<button
aria-label={`Close ${filename}`}
className={styles.tabClose}
diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.ts
index 61faaa669fa..eb083e03312 100644
--- a/src/locales/default/chat.ts
+++ b/src/locales/default/chat.ts
@@ -972,7 +972,11 @@ export default {
'workingPanel.localFile.closeOther': 'Close Others',
'workingPanel.localFile.closeRight': 'Close to the Right',
'workingPanel.localFile.error': "Couldn't load this file",
+ 'workingPanel.localFile.preview.raw': 'Raw',
+ 'workingPanel.localFile.preview.render': 'Preview',
'workingPanel.localFile.truncated': 'File preview truncated to {{limit}} characters',
+ 'workingPanel.skills.empty': 'No skills found in this project',
+ 'workingPanel.skills.title': 'Skills',
'workingPanel.files.count_one': '{{count}} file',
'workingPanel.files.count_other': '{{count}} files',
'workingPanel.files.copyAbsolutePath': 'Copy Path',
diff --git a/src/locales/default/editor.ts b/src/locales/default/editor.ts
index 09eefdd7514..ffb04c58782 100644
--- a/src/locales/default/editor.ts
+++ b/src/locales/default/editor.ts
@@ -36,9 +36,12 @@ export default {
'modifier.reject': 'Revert',
'modifier.rejectAll': 'Revert All',
'actionTag.category.command': 'Command',
+ 'actionTag.category.projectSkill': 'Project skill',
'actionTag.category.skill': 'Skill',
'actionTag.category.tool': 'Tool',
'actionTag.tooltip.command': 'Runs a client-side slash command before sending.',
+ 'actionTag.tooltip.projectSkill':
+ "Sent as a slash invocation so the agent's CLI runs the matching project skill.",
'actionTag.tooltip.skill': 'Loads a reusable skill package for this request.',
'actionTag.tooltip.tool': 'Marks a tool the user explicitly selected for this request.',
'slash.compact': 'Compact context',
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx
new file mode 100644
index 00000000000..088c0aeed20
--- /dev/null
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/SkillsGroup.tsx
@@ -0,0 +1,363 @@
+import { isDesktop } from '@lobechat/const';
+import { type ListProjectSkillsResult, type ProjectSkillItem } from '@lobechat/electron-client-ipc';
+import { Center, Empty, Flexbox, Icon, Text, Tooltip } from '@lobehub/ui';
+import { SkillsIcon } from '@lobehub/ui/icons';
+import { Spin } from 'antd';
+import { createStaticStyles } from 'antd-style';
+import { ChevronRightIcon, FileIcon, FolderIcon } from 'lucide-react';
+import path from 'pathe';
+import { memo, useCallback, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useClientDataSWR } from '@/libs/swr';
+import { localFileService } from '@/services/electron/localFileService';
+import { useChatStore } from '@/store/chat';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ chevron: css`
+ flex-shrink: 0;
+ color: ${cssVar.colorTextTertiary};
+ transition: transform ${cssVar.motionDurationFast} ${cssVar.motionEaseInOut};
+ `,
+ chevronExpanded: css`
+ transform: rotate(90deg);
+ `,
+ childItem: css`
+ cursor: pointer;
+
+ height: 26px;
+ padding-inline-end: 8px;
+ border-radius: 6px;
+
+ font-size: 12px;
+ color: ${cssVar.colorTextSecondary};
+
+ &:hover {
+ color: ${cssVar.colorText};
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+ childItemIcon: css`
+ flex-shrink: 0;
+ color: ${cssVar.colorTextTertiary};
+ `,
+ treeChevronSlot: css`
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+
+ width: 14px;
+ height: 14px;
+ `,
+ description: css`
+ max-width: 320px;
+ font-size: 12px;
+ line-height: 1.5;
+ color: ${cssVar.colorTextSecondary};
+ `,
+ groupCount: css`
+ font-size: 12px;
+ font-variant-numeric: tabular-nums;
+ color: ${cssVar.colorTextTertiary};
+ `,
+ groupLabel: css`
+ font-size: 12px;
+ font-weight: 500;
+ `,
+ item: css`
+ cursor: pointer;
+
+ height: 28px;
+ padding-inline: 4px 8px;
+ border-radius: 6px;
+
+ font-size: 13px;
+ color: ${cssVar.colorTextSecondary};
+
+ &:hover {
+ color: ${cssVar.colorText};
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+ itemCount: css`
+ flex-shrink: 0;
+ font-size: 12px;
+ font-variant-numeric: tabular-nums;
+ color: ${cssVar.colorTextTertiary};
+ `,
+ itemIcon: css`
+ flex-shrink: 0;
+ color: ${cssVar.colorTextTertiary};
+ `,
+}));
+
+interface TreeNode {
+ children: TreeNode[];
+ isDirectory: boolean;
+ name: string;
+ path: string;
+}
+
+const buildSkillTree = (paths: string[]): TreeNode[] => {
+ const root: TreeNode = { children: [], isDirectory: true, name: '', path: '' };
+
+ for (const fullPath of paths) {
+ const parts = fullPath.split('/').filter(Boolean);
+ let current = root;
+ let accumPath = '';
+
+ for (let i = 0; i < parts.length; i++) {
+ const part = parts[i];
+ accumPath = accumPath ? `${accumPath}/${part}` : part;
+ const isDirectory = i < parts.length - 1;
+
+ let child = current.children.find((c) => c.name === part);
+ if (!child) {
+ child = { children: [], isDirectory, name: part, path: accumPath };
+ current.children.push(child);
+ }
+ current = child;
+ }
+ }
+
+ const sortNode = (node: TreeNode) => {
+ node.children.sort((a, b) => {
+ if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;
+ return a.name.localeCompare(b.name);
+ });
+ for (const child of node.children) sortNode(child);
+ };
+ sortNode(root);
+
+ return root.children;
+};
+
+const TREE_BASE_INSET = 24;
+const TREE_DEPTH_INDENT = 14;
+
+interface TreeRowProps {
+ depth: number;
+ expanded: Set<string>;
+ node: TreeNode;
+ onOpenFile: (relativePath: string) => void;
+ onToggleFolder: (folderPath: string) => void;
+}
+
+const TreeRow = memo<TreeRowProps>(({ depth, expanded, node, onOpenFile, onToggleFolder }) => {
+ const isOpen = expanded.has(node.path);
+ const paddingInlineStart = TREE_BASE_INSET + depth * TREE_DEPTH_INDENT;
+
+ if (node.isDirectory) {
+ return (
+ <>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.childItem}
+ gap={6}
+ style={{ paddingInlineStart }}
+ onClick={() => onToggleFolder(node.path)}
+ >
+ <span className={styles.treeChevronSlot}>
+ <Icon
+ className={`${styles.chevron} ${isOpen ? styles.chevronExpanded : ''}`}
+ icon={ChevronRightIcon}
+ size={12}
+ />
+ </span>
+ <Icon className={styles.childItemIcon} icon={FolderIcon} size={12} />
+ <Text ellipsis style={{ flex: 1, fontSize: 12, minWidth: 0 }}>
+ {node.name}
+ </Text>
+ </Flexbox>
+ {isOpen &&
+ node.children.map((child) => (
+ <TreeRow
+ depth={depth + 1}
+ expanded={expanded}
+ key={child.path}
+ node={child}
+ onOpenFile={onOpenFile}
+ onToggleFolder={onToggleFolder}
+ />
+ ))}
+ </>
+ );
+ }
+
+ return (
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.childItem}
+ gap={6}
+ style={{ paddingInlineStart }}
+ title={node.path}
+ onClick={() => onOpenFile(node.path)}
+ >
+ <span className={styles.treeChevronSlot} />
+ <Icon className={styles.childItemIcon} icon={FileIcon} size={12} />
+ <Text ellipsis style={{ flex: 1, fontSize: 12, minWidth: 0 }}>
+ {node.name}
+ </Text>
+ </Flexbox>
+ );
+});
+
+TreeRow.displayName = 'SkillTreeRow';
+
+interface SkillRowProps {
+ expanded: boolean;
+ onOpenFile: (relativePath: string) => void;
+ onToggle: () => void;
+ skill: ProjectSkillItem;
+ workingDirectory: string;
+}
+
+const SkillRow = memo<SkillRowProps>(
+ ({ expanded, onOpenFile, onToggle, skill, workingDirectory }) => {
+ const openLocalFile = useChatStore((s) => s.openLocalFile);
+ const handleOpenSkill = () => openLocalFile({ filePath: skill.path, workingDirectory });
+ const tree = useMemo(() => buildSkillTree(skill.files), [skill.files]);
+ const [expandedFolders, setExpandedFolders] = useState<Set<string>>(() => new Set());
+
+ const toggleFolder = useCallback((folderPath: string) => {
+ setExpandedFolders((prev) => {
+ const next = new Set(prev);
+ if (next.has(folderPath)) next.delete(folderPath);
+ else next.add(folderPath);
+ return next;
+ });
+ }, []);
+
+ return (
+ <>
+ <Tooltip
+ placement={'left'}
+ title={
+ skill.description ? (
+ <span className={styles.description}>{skill.description}</span>
+ ) : undefined
+ }
+ >
+ <Flexbox horizontal align={'center'} className={styles.item} gap={6}>
+ <Flexbox
+ align={'center'}
+ justify={'center'}
+ style={{ cursor: 'pointer', flexShrink: 0, height: 20, width: 20 }}
+ onClick={(e) => {
+ e.stopPropagation();
+ onToggle();
+ }}
+ >
+ <Icon
+ className={`${styles.chevron} ${expanded ? styles.chevronExpanded : ''}`}
+ icon={ChevronRightIcon}
+ size={14}
+ />
+ </Flexbox>
+ <Icon className={styles.itemIcon} icon={SkillsIcon} size={14} />
+ <Text ellipsis style={{ flex: 1, minWidth: 0 }} onClick={handleOpenSkill}>
+ {skill.name}
+ </Text>
+ <span className={styles.itemCount}>{skill.fileCount}</span>
+ </Flexbox>
+ </Tooltip>
+ {expanded &&
+ tree.map((node) => (
+ <TreeRow
+ depth={0}
+ expanded={expandedFolders}
+ key={node.path}
+ node={node}
+ onOpenFile={onOpenFile}
+ onToggleFolder={toggleFolder}
+ />
+ ))}
+ </>
+ );
+ },
+);
+
+SkillRow.displayName = 'SkillRow';
+
+interface SkillsGroupProps {
+ workingDirectory: string;
+}
+
+const SkillsGroup = memo<SkillsGroupProps>(({ workingDirectory }) => {
+ const { t } = useTranslation('chat');
+ const openLocalFile = useChatStore((s) => s.openLocalFile);
+ const [expanded, setExpanded] = useState<Set<string>>(() => new Set());
+
+ const toggle = useCallback((skillDir: string) => {
+ setExpanded((prev) => {
+ const next = new Set(prev);
+ if (next.has(skillDir)) {
+ next.delete(skillDir);
+ } else {
+ next.add(skillDir);
+ }
+ return next;
+ });
+ }, []);
+
+ const enabled = isDesktop && !!workingDirectory;
+ const { data, error, isLoading } = useClientDataSWR<ListProjectSkillsResult>(
+ enabled ? ['project-skills', workingDirectory] : null,
+ () => localFileService.listProjectSkills({ scope: workingDirectory }),
+ { revalidateOnFocus: false, shouldRetryOnError: false },
+ );
+
+ if (!enabled) return null;
+
+ const totalCount = data?.skills.length ?? 0;
+ // listProjectSkills approves `data.root` for preview. Hand that exact value
+ // back to openLocalFile so LocalFileProtocolManager.createPreviewUrl's
+ // approved-root check matches; fall back to the requested workingDirectory
+ // while the SWR fetch is in flight.
+ const previewWorkspaceRoot = data?.root || workingDirectory;
+
+ return (
+ <Flexbox gap={4}>
+ <Flexbox horizontal align={'center'} gap={6} paddingInline={4}>
+ <Text className={styles.groupLabel} type={'secondary'}>
+ {t('workingPanel.skills.title')}
+ </Text>
+ {totalCount > 0 && <span className={styles.groupCount}>{totalCount}</span>}
+ </Flexbox>
+ {isLoading ? (
+ <Center paddingBlock={12}>
+ <Spin size={'small'} />
+ </Center>
+ ) : error || !data || data.skills.length === 0 ? (
+ <Center gap={8} paddingBlock={16}>
+ <Empty description={t('workingPanel.skills.empty')} icon={SkillsIcon} />
+ </Center>
+ ) : (
+ <Flexbox gap={2}>
+ {data.skills.map((skill) => (
+ <SkillRow
+ expanded={expanded.has(skill.skillDir)}
+ key={skill.skillDir}
+ skill={skill}
+ workingDirectory={previewWorkspaceRoot}
+ onToggle={() => toggle(skill.skillDir)}
+ onOpenFile={(relativePath) =>
+ openLocalFile({
+ filePath: path.join(skill.skillDir, relativePath),
+ workingDirectory: previewWorkspaceRoot,
+ })
+ }
+ />
+ ))}
+ </Flexbox>
+ )}
+ </Flexbox>
+ );
+});
+
+SkillsGroup.displayName = 'SkillsGroup';
+
+export default SkillsGroup;
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx
index 423b81f625a..fdb87e4c63d 100644
--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/ResourcesSection/index.tsx
@@ -1,20 +1,36 @@
import { Flexbox } from '@lobehub/ui';
import { memo } from 'react';
+import { useAgentStore } from '@/store/agent';
+import { agentByIdSelectors, agentSelectors } from '@/store/agent/selectors';
+import { useChatStore } from '@/store/chat';
+import { topicSelectors } from '@/store/chat/selectors';
+
import AgentDocumentsGroup from './AgentDocumentsGroup';
+import SkillsGroup from './SkillsGroup';
export type ResourceViewMode = 'list' | 'tree';
const ResourcesSection = memo(() => {
+ const isHetero = useAgentStore(agentSelectors.isCurrentAgentHeterogeneous);
+ const activeAgentId = useAgentStore((s) => s.activeAgentId);
+ const agentWorkingDirectory = useAgentStore((s) =>
+ activeAgentId ? agentByIdSelectors.getAgentWorkingDirectoryById(activeAgentId)(s) : undefined,
+ );
+ const topicWorkingDirectory = useChatStore(topicSelectors.currentTopicWorkingDirectory);
+ const workingDirectory = topicWorkingDirectory || agentWorkingDirectory;
+
return (
<Flexbox
data-testid="workspace-resources"
flex={1}
+ gap={16}
paddingBlock={8}
paddingInline={'8px 12px'}
style={{ minHeight: 0 }}
>
- <AgentDocumentsGroup style={{ flex: 1, minHeight: 0 }} viewMode={'list'} />
+ {isHetero && workingDirectory && <SkillsGroup workingDirectory={workingDirectory} />}
+ {!isHetero && <AgentDocumentsGroup style={{ flex: 1, minHeight: 0 }} viewMode={'list'} />}
</Flexbox>
);
});
diff --git a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx
index 35eb84d42b5..e48cce9c013 100644
--- a/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/WorkingSidebar/index.tsx
@@ -100,6 +100,7 @@ const AgentWorkingSidebar = memo(() => {
if (storedTab === 'review' && reviewAvailable) return 'review';
if (storedTab === 'files' && filesAvailable) return 'files';
if (storedTab === 'resources') return 'resources';
+ if (isHetero) return 'resources';
if (reviewAvailable) return 'review';
if (filesAvailable) return 'files';
return 'resources';
diff --git a/src/services/electron/localFileService.ts b/src/services/electron/localFileService.ts
index 09e9d9be168..35bc0fcdb4e 100644
--- a/src/services/electron/localFileService.ts
+++ b/src/services/electron/localFileService.ts
@@ -13,6 +13,8 @@ import {
type KillCommandResult,
type ListLocalFileParams,
type ListLocalFilesResult,
+ type ListProjectSkillsParams,
+ type ListProjectSkillsResult,
type LocalFileItem,
type LocalFilePreviewUrlParams,
type LocalFilePreviewUrlResult,
@@ -62,6 +64,10 @@ class LocalFileService {
return ensureElectronIpc().localSystem.getProjectFileIndex(params);
}
+ async listProjectSkills(params: ListProjectSkillsParams): Promise<ListProjectSkillsResult> {
+ return ensureElectronIpc().localSystem.listProjectSkills(params);
+ }
+
async openLocalFile(params: OpenLocalFileParams) {
return ensureElectronIpc().localSystem.handleOpenLocalFile(params);
}