Skip to content

Commit 6c0d1a7

Browse files
committed
refactor: 使用 skill cli 安装 skills
1 parent 783e700 commit 6c0d1a7

4 files changed

Lines changed: 25 additions & 33 deletions

File tree

Storage/skills/KhazixW2/pipeline-testing/SKILL.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
name: pipeline-testing
3+
description: 测试 MaaFramework Pipeline JSON 节点、识别结果与设备控制流程,并排查 OCR、ROI 和跨页面导航问题。
4+
---
5+
16
# Pipeline Testing Skill
27

38
## 概述

website/src/components/SkillDetailApp.tsx

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { cn } from '../lib/utils';
66
import { sitePath } from '../lib/routes';
77
import { FileViewer, type DownloadFile } from './FileViewer';
88
import { DownloadSection } from './DownloadSection';
9+
import { getSkillInstallCommand } from '../lib/skillInstall';
910

1011
type SkillDetailData = {
1112
id: string;
@@ -35,8 +36,7 @@ type SkillDetailData = {
3536
// In a real app, this data would come from the astro page props (fetched from getCollection)
3637
export function SkillDetailApp({ skillId, skillData, lang = 'zh' }: { skillId: string, skillData: SkillDetailData, lang?: 'zh' | 'en' }) {
3738
const [currentLang, setCurrentLang] = React.useState(lang);
38-
const [isCopied1, setIsCopied1] = React.useState(false);
39-
const [isCopied2, setIsCopied2] = React.useState(false);
39+
const [isInstallCommandCopied, setIsInstallCommandCopied] = React.useState(false);
4040

4141
const [isClient, setIsClient] = React.useState(false);
4242

@@ -59,20 +59,15 @@ export function SkillDetailApp({ skillId, skillData, lang = 'zh' }: { skillId: s
5959

6060
const t = (key: keyof typeof ui['zh']) => ui[currentLang][key];
6161

62-
const handleCopy1 = () => {
63-
navigator.clipboard.writeText(`git clone https://github.com/MaaXYZ/MaaHub.git --depth=1`);
64-
setIsCopied1(true);
65-
setTimeout(() => setIsCopied1(false), 2000);
66-
};
62+
const packageName = skillData.id.split('/')[1] || skillData.id;
63+
const installCommand = getSkillInstallCommand(skillData.skillName || packageName);
6764

68-
const handleCopy2 = () => {
69-
navigator.clipboard.writeText(`cp -r MaaHub/Storage/skills/${skillData.author}/${skillData.id.split('/')[1]} ./your_agent_skills/`);
70-
setIsCopied2(true);
71-
setTimeout(() => setIsCopied2(false), 2000);
65+
const handleCopyInstallCommand = () => {
66+
navigator.clipboard.writeText(installCommand);
67+
setIsInstallCommandCopied(true);
68+
setTimeout(() => setIsInstallCommandCopied(false), 2000);
7269
};
7370

74-
const packageName = skillData.id.split('/')[1] || skillData.id;
75-
7671
return (
7772
<>
7873
<Header lang={currentLang} toggleLang={toggleLang} />
@@ -141,28 +136,16 @@ export function SkillDetailApp({ skillId, skillData, lang = 'zh' }: { skillId: s
141136
<Terminal className="mr-2 h-4 w-4 text-muted-foreground" />
142137
{t('skill.install')}
143138
</h3>
144-
<div className="relative mb-2">
145-
<pre className="overflow-x-auto rounded bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all pr-10">
146-
<code>{`git clone https://github.com/MaaXYZ/MaaHub.git --depth=1`}</code>
147-
</pre>
148-
<button
149-
onClick={handleCopy1}
150-
className="absolute right-2 top-2 rounded bg-background p-1.5 text-muted-foreground hover:text-foreground border shadow-sm transition-colors"
151-
title="Copy clone command"
152-
>
153-
{isCopied1 ? <Check className="h-3.5 w-3.5 text-green-500" /> : <Copy className="h-3.5 w-3.5" />}
154-
</button>
155-
</div>
156139
<div className="relative">
157140
<pre className="overflow-x-auto rounded bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all pr-10">
158-
<code>{`cp -r MaaHub/Storage/skills/${skillData.author}/${skillData.id.split('/')[1]} ./your_agent_skills/`}</code>
141+
<code>{installCommand}</code>
159142
</pre>
160143
<button
161-
onClick={handleCopy2}
144+
onClick={handleCopyInstallCommand}
162145
className="absolute right-2 top-2 rounded bg-background p-1.5 text-muted-foreground hover:text-foreground border shadow-sm transition-colors"
163-
title="Copy copy command"
146+
title="Copy install command"
164147
>
165-
{isCopied2 ? <Check className="h-3.5 w-3.5 text-green-500" /> : <Copy className="h-3.5 w-3.5" />}
148+
{isInstallCommandCopied ? <Check className="h-3.5 w-3.5 text-green-500" /> : <Copy className="h-3.5 w-3.5" />}
166149
</button>
167150
</div>
168151
</div>

website/src/lib/skillInstall.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const SKILLS_REPOSITORY_URL = 'https://github.com/MaaXYZ/MaaHub';
2+
3+
export function getSkillInstallCommand(skillName: string) {
4+
return `npx skills add ${SKILLS_REPOSITORY_URL} --skill ${skillName}`;
5+
}

website/src/pages/skills/[...id]/index.astro

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Layout from '../../../layouts/Layout.astro';
33
import { SkillDetailApp } from '../../../components/SkillDetailApp';
44
import { withDownloadFiles } from '../../../lib/downloadFiles';
55
import { getAllSkills } from '../../../lib/skills';
6+
import { getSkillInstallCommand } from '../../../lib/skillInstall';
67
78
export async function getStaticPaths() {
89
const skills = await getAllSkills();
@@ -34,8 +35,7 @@ const jsonLd = {
3435
"runtimePlatform": "MaaFramework",
3536
};
3637
37-
const installCmd1 = `git clone https://github.com/MaaXYZ/MaaHub.git --depth=1`;
38-
const installCmd2 = `cp -r MaaHub/Storage/skills/${skill.id} ./your_agent_skills/`;
38+
const installCommand = getSkillInstallCommand(skill.skillName);
3939
---
4040

4141
<Layout
@@ -77,8 +77,7 @@ const installCmd2 = `cp -r MaaHub/Storage/skills/${skill.id} ./your_agent_skills
7777

7878
<section>
7979
<h2>Installation</h2>
80-
<pre><code>{installCmd1}</code></pre>
81-
<pre><code>{installCmd2}</code></pre>
80+
<pre><code>{installCommand}</code></pre>
8281
</section>
8382

8483
{skill.downloadFiles?.length && (

0 commit comments

Comments
 (0)