fix(skills): distinguish external skill install paths and open real location (#463)
This commit is contained in:
@@ -49,11 +49,25 @@
|
||||
"saveConfig": "Save Configuration",
|
||||
"configSaved": "Configuration saved",
|
||||
"openManual": "Open Manual",
|
||||
"openActualFolder": "Open Actual Folder",
|
||||
"copyPath": "Copy path",
|
||||
"pathUnavailable": "Path not available",
|
||||
"configurable": "Configurable",
|
||||
"uninstall": "Uninstall",
|
||||
"enable": "Enable",
|
||||
"disable": "Disable"
|
||||
},
|
||||
"source": {
|
||||
"badge": {
|
||||
"bundled": "Bundled",
|
||||
"managed": "Managed",
|
||||
"workspace": "Workspace",
|
||||
"extra": "Extra dirs",
|
||||
"agentsPersonal": "Personal .agents",
|
||||
"agentsProject": "Project .agents",
|
||||
"unknown": "Unknown source"
|
||||
}
|
||||
},
|
||||
"toast": {
|
||||
"enabled": "Skill enabled",
|
||||
"disabled": "Skill disabled",
|
||||
@@ -66,6 +80,9 @@
|
||||
"failedInstall": "Failed to install",
|
||||
"failedUninstall": "Failed to uninstall",
|
||||
"failedFolderNotFound": "Skills folder does not exist yet. Install a skill first.",
|
||||
"copiedPath": "Path copied",
|
||||
"failedCopyPath": "Failed to copy path",
|
||||
"failedOpenActualFolder": "Failed to open actual skill folder",
|
||||
"searchTimeoutError": "Search timed out, check network. You can also search on ClawHub.ai, download the ZIP, and extract it to \"{{path}}\"",
|
||||
"installTimeoutError": "Installation timed out, check network. You can also download the ZIP from ClawHub.ai and extract it to \"{{path}}\"",
|
||||
"searchRateLimitError": "Search rate limit exceeded. You can also search on ClawHub.ai, download the ZIP, and extract it to \"{{path}}\"",
|
||||
|
||||
@@ -49,11 +49,25 @@
|
||||
"saveConfig": "設定を保存",
|
||||
"configSaved": "設定を保存しました",
|
||||
"openManual": "マニュアルを開く",
|
||||
"openActualFolder": "実際のフォルダを開く",
|
||||
"copyPath": "パスをコピー",
|
||||
"pathUnavailable": "パスを取得できません",
|
||||
"configurable": "設定可能",
|
||||
"uninstall": "アンインストール",
|
||||
"enable": "有効化",
|
||||
"disable": "無効化"
|
||||
},
|
||||
"source": {
|
||||
"badge": {
|
||||
"bundled": "内蔵",
|
||||
"managed": "管理ディレクトリ",
|
||||
"workspace": "ワークスペース",
|
||||
"extra": "追加ディレクトリ",
|
||||
"agentsPersonal": "個人 .agents",
|
||||
"agentsProject": "プロジェクト .agents",
|
||||
"unknown": "不明なソース"
|
||||
}
|
||||
},
|
||||
"toast": {
|
||||
"enabled": "スキルを有効にしました",
|
||||
"disabled": "スキルを無効にしました",
|
||||
@@ -66,6 +80,9 @@
|
||||
"failedInstall": "インストールに失敗しました",
|
||||
"failedUninstall": "アンインストールに失敗しました",
|
||||
"failedFolderNotFound": "スキルフォルダがまだ存在しません。先にスキルをインストールしてください。",
|
||||
"copiedPath": "パスをコピーしました",
|
||||
"failedCopyPath": "パスのコピーに失敗しました",
|
||||
"failedOpenActualFolder": "スキルの実際のフォルダを開けませんでした",
|
||||
"searchTimeoutError": "検索がタイムアウトしました。ClawHub.aiで検索してZIPをダウンロードし、\"{{path}}\" に展開することも可能です",
|
||||
"installTimeoutError": "インストールがタイムアウトしました。ClawHub.aiでZIPをダウンロードし、\"{{path}}\" に展開することも可能です",
|
||||
"searchRateLimitError": "検索リクエストの制限を超過しました。ClawHub.aiで検索してZIPをダウンロードし、\"{{path}}\" に展開することも可能です",
|
||||
|
||||
@@ -49,11 +49,25 @@
|
||||
"saveConfig": "保存配置",
|
||||
"configSaved": "配置已保存",
|
||||
"openManual": "打开手册",
|
||||
"openActualFolder": "打开实际目录",
|
||||
"copyPath": "复制路径",
|
||||
"pathUnavailable": "路径不可用",
|
||||
"configurable": "可配置",
|
||||
"uninstall": "卸载",
|
||||
"enable": "启用",
|
||||
"disable": "禁用"
|
||||
},
|
||||
"source": {
|
||||
"badge": {
|
||||
"bundled": "内置",
|
||||
"managed": "托管目录",
|
||||
"workspace": "工作区",
|
||||
"extra": "额外目录",
|
||||
"agentsPersonal": "个人 .agents",
|
||||
"agentsProject": "项目 .agents",
|
||||
"unknown": "未知来源"
|
||||
}
|
||||
},
|
||||
"toast": {
|
||||
"enabled": "技能已启用",
|
||||
"disabled": "技能已禁用",
|
||||
@@ -66,6 +80,9 @@
|
||||
"failedInstall": "安装失败",
|
||||
"failedUninstall": "卸载失败",
|
||||
"failedFolderNotFound": "技能文件夹尚不存在,请先安装一个技能。",
|
||||
"copiedPath": "路径已复制",
|
||||
"failedCopyPath": "复制路径失败",
|
||||
"failedOpenActualFolder": "打开技能实际目录失败",
|
||||
"searchTimeoutError": "搜索超时,请检查网络。您也可访问 ClawHub.ai 搜索并下载压缩包,解压到 \"{{path}}\"",
|
||||
"installTimeoutError": "安装超时,请检查网络。您也可在 ClawHub.ai 下载该技能压缩包,解压到 \"{{path}}\"",
|
||||
"searchRateLimitError": "搜索请求过于频繁。您也可访问 ClawHub.ai 搜索并下载压缩包,解压到 \"{{path}}\"",
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
FolderOpen,
|
||||
FileCode,
|
||||
Globe,
|
||||
Copy,
|
||||
} from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -33,6 +34,7 @@ import { trackUiEvent } from '@/lib/telemetry';
|
||||
import { toast } from 'sonner';
|
||||
import type { Skill } from '@/types/skill';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import type { TFunction } from 'i18next';
|
||||
|
||||
|
||||
|
||||
@@ -44,9 +46,25 @@ interface SkillDetailDialogProps {
|
||||
onClose: () => void;
|
||||
onToggle: (enabled: boolean) => void;
|
||||
onUninstall?: (slug: string) => void;
|
||||
onOpenFolder?: (skill: Skill) => Promise<void> | void;
|
||||
}
|
||||
|
||||
function SkillDetailDialog({ skill, isOpen, onClose, onToggle, onUninstall }: SkillDetailDialogProps) {
|
||||
function resolveSkillSourceLabel(skill: Skill, t: TFunction<'skills'>): string {
|
||||
const source = (skill.source || '').trim().toLowerCase();
|
||||
if (!source) {
|
||||
if (skill.isBundled) return t('source.badge.bundled', { defaultValue: 'Bundled' });
|
||||
return t('source.badge.unknown', { defaultValue: 'Unknown source' });
|
||||
}
|
||||
if (source === 'openclaw-bundled') return t('source.badge.bundled', { defaultValue: 'Bundled' });
|
||||
if (source === 'openclaw-managed') return t('source.badge.managed', { defaultValue: 'Managed' });
|
||||
if (source === 'openclaw-workspace') return t('source.badge.workspace', { defaultValue: 'Workspace' });
|
||||
if (source === 'openclaw-extra') return t('source.badge.extra', { defaultValue: 'Extra dirs' });
|
||||
if (source === 'agents-skills-personal') return t('source.badge.agentsPersonal', { defaultValue: 'Personal .agents' });
|
||||
if (source === 'agents-skills-project') return t('source.badge.agentsProject', { defaultValue: 'Project .agents' });
|
||||
return source;
|
||||
}
|
||||
|
||||
function SkillDetailDialog({ skill, isOpen, onClose, onToggle, onUninstall, onOpenFolder }: SkillDetailDialogProps) {
|
||||
const { t } = useTranslation('skills');
|
||||
const { fetchSkills } = useSkillsStore();
|
||||
const [envVars, setEnvVars] = useState<Array<{ key: string; value: string }>>([]);
|
||||
@@ -86,7 +104,7 @@ function SkillDetailDialog({ skill, isOpen, onClose, onToggle, onUninstall }: Sk
|
||||
try {
|
||||
const result = await hostApiFetch<{ success: boolean; error?: string }>('/api/clawhub/open-readme', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ skillKey: skill.id, slug: skill.slug }),
|
||||
body: JSON.stringify({ skillKey: skill.id, slug: skill.slug, baseDir: skill.baseDir }),
|
||||
});
|
||||
if (result.success) {
|
||||
toast.success(t('toast.openedEditor'));
|
||||
@@ -98,6 +116,16 @@ function SkillDetailDialog({ skill, isOpen, onClose, onToggle, onUninstall }: Sk
|
||||
}
|
||||
};
|
||||
|
||||
const handleCopyPath = async () => {
|
||||
if (!skill?.baseDir) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(skill.baseDir);
|
||||
toast.success(t('toast.copiedPath'));
|
||||
} catch (err) {
|
||||
toast.error(t('toast.failedCopyPath') + ': ' + String(err));
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddEnv = () => {
|
||||
setEnvVars([...envVars, { key: '', value: '' }]);
|
||||
};
|
||||
@@ -192,6 +220,42 @@ function SkillDetailDialog({ skill, isOpen, onClose, onToggle, onUninstall }: Sk
|
||||
</div>
|
||||
|
||||
<div className="space-y-7 px-1">
|
||||
<div className="space-y-2">
|
||||
<h3 className="text-[13px] font-bold text-foreground/80">{t('detail.source')}</h3>
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<Badge variant="secondary" className="font-mono text-[11px] font-medium px-3 py-0.5 rounded-full bg-black/[0.04] dark:bg-white/[0.08] border-0 shadow-none text-foreground/70">
|
||||
{resolveSkillSourceLabel(skill, t)}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
value={skill.baseDir || t('detail.pathUnavailable')}
|
||||
readOnly
|
||||
className="h-[38px] font-mono text-[12px] bg-[#eeece3] dark:bg-muted border-black/10 dark:border-white/10 rounded-xl text-foreground/70"
|
||||
/>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="h-[38px] w-[38px] border-black/10 dark:border-white/10"
|
||||
disabled={!skill.baseDir}
|
||||
onClick={handleCopyPath}
|
||||
title={t('detail.copyPath')}
|
||||
>
|
||||
<Copy className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="h-[38px] w-[38px] border-black/10 dark:border-white/10"
|
||||
disabled={!skill.baseDir}
|
||||
onClick={() => onOpenFolder?.(skill)}
|
||||
title={t('detail.openActualFolder')}
|
||||
>
|
||||
<FolderOpen className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* API Key Section */}
|
||||
{!skill.isCore && (
|
||||
<div className="space-y-2">
|
||||
@@ -471,6 +535,24 @@ export function Skills() {
|
||||
}
|
||||
}, [t]);
|
||||
|
||||
const handleOpenSkillFolder = useCallback(async (skill: Skill) => {
|
||||
try {
|
||||
const result = await hostApiFetch<{ success: boolean; error?: string }>('/api/clawhub/open-path', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
skillKey: skill.id,
|
||||
slug: skill.slug,
|
||||
baseDir: skill.baseDir,
|
||||
}),
|
||||
});
|
||||
if (!result.success) {
|
||||
throw new Error(result.error || 'Failed to open folder');
|
||||
}
|
||||
} catch (err) {
|
||||
toast.error(t('toast.failedOpenActualFolder') + ': ' + String(err));
|
||||
}
|
||||
}, [t]);
|
||||
|
||||
const [skillsDirPath, setSkillsDirPath] = useState('~/.openclaw/skills');
|
||||
|
||||
useEffect(() => {
|
||||
@@ -698,6 +780,14 @@ export function Skills() {
|
||||
<p className="text-[13.5px] text-muted-foreground line-clamp-1 pr-6 leading-relaxed">
|
||||
{skill.description}
|
||||
</p>
|
||||
<div className="mt-1 flex items-center gap-2 text-[11px] text-foreground/55">
|
||||
<Badge variant="secondary" className="px-1.5 py-0 h-5 text-[10px] font-medium bg-black/5 dark:bg-white/10 border-0 shadow-none">
|
||||
{resolveSkillSourceLabel(skill, t)}
|
||||
</Badge>
|
||||
<span className="truncate font-mono">
|
||||
{skill.baseDir || t('detail.pathUnavailable')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-6 shrink-0" onClick={e => e.stopPropagation()}>
|
||||
@@ -858,6 +948,7 @@ export function Skills() {
|
||||
setSelectedSkill({ ...selectedSkill, enabled });
|
||||
}}
|
||||
onUninstall={handleUninstall}
|
||||
onOpenFolder={handleOpenSkillFolder}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -20,6 +20,9 @@ type GatewaySkillStatus = {
|
||||
config?: Record<string, unknown>;
|
||||
bundled?: boolean;
|
||||
always?: boolean;
|
||||
source?: string;
|
||||
baseDir?: string;
|
||||
filePath?: string;
|
||||
};
|
||||
|
||||
type GatewaySkillsStatusResult = {
|
||||
@@ -29,6 +32,8 @@ type GatewaySkillsStatusResult = {
|
||||
type ClawHubListResult = {
|
||||
slug: string;
|
||||
version?: string;
|
||||
source?: string;
|
||||
baseDir?: string;
|
||||
};
|
||||
|
||||
function mapErrorCodeToSkillErrorKey(
|
||||
@@ -120,6 +125,9 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
|
||||
},
|
||||
isCore: s.bundled && s.always,
|
||||
isBundled: s.bundled,
|
||||
source: s.source,
|
||||
baseDir: s.baseDir,
|
||||
filePath: s.filePath,
|
||||
};
|
||||
});
|
||||
} else if (currentSkills.length > 0) {
|
||||
@@ -131,22 +139,31 @@ export const useSkillsStore = create<SkillsState>((set, get) => ({
|
||||
if (clawhubResult.success && clawhubResult.results) {
|
||||
clawhubResult.results.forEach((cs: ClawHubListResult) => {
|
||||
const existing = combinedSkills.find(s => s.id === cs.slug);
|
||||
if (!existing) {
|
||||
const directConfig = configResult[cs.slug] || {};
|
||||
combinedSkills.push({
|
||||
id: cs.slug,
|
||||
slug: cs.slug,
|
||||
name: cs.slug,
|
||||
description: 'Recently installed, initializing...',
|
||||
enabled: false,
|
||||
icon: '⌛',
|
||||
version: cs.version || 'unknown',
|
||||
author: undefined,
|
||||
config: directConfig,
|
||||
isCore: false,
|
||||
isBundled: false,
|
||||
});
|
||||
if (existing) {
|
||||
if (!existing.baseDir && cs.baseDir) {
|
||||
existing.baseDir = cs.baseDir;
|
||||
}
|
||||
if (!existing.source && cs.source) {
|
||||
existing.source = cs.source;
|
||||
}
|
||||
return;
|
||||
}
|
||||
const directConfig = configResult[cs.slug] || {};
|
||||
combinedSkills.push({
|
||||
id: cs.slug,
|
||||
slug: cs.slug,
|
||||
name: cs.slug,
|
||||
description: 'Recently installed, initializing...',
|
||||
enabled: false,
|
||||
icon: '⌛',
|
||||
version: cs.version || 'unknown',
|
||||
author: undefined,
|
||||
config: directConfig,
|
||||
isCore: false,
|
||||
isBundled: false,
|
||||
source: cs.source || 'openclaw-managed',
|
||||
baseDir: cs.baseDir,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ export interface Skill {
|
||||
isCore?: boolean;
|
||||
isBundled?: boolean;
|
||||
dependencies?: string[];
|
||||
source?: string;
|
||||
baseDir?: string;
|
||||
filePath?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user