Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions plugins/skill-hub/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{json,yaml,yml}]
indent_size = 2
38 changes: 38 additions & 0 deletions plugins/skill-hub/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 依赖
node_modules

# 构建产物
dist/
*.tsbuildinfo

# 环境变量
.env
.env.local
.env.*.local

# 工具
.claude/
.mimocode/
.agents/
.skill-archive/
api-tests/

# IDE
.vscode/
.idea/
*.swp
*.swo

# 测试
coverage/
test-builtin-skills.html

# 日志
*.log

# OS
Thumbs.db
.DS_Store

# 文档(本地副本,不提交)
docs/ztools-doc/
65 changes: 65 additions & 0 deletions plugins/skill-hub/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Skill Hub

ZTools 插件 — Vue 3 + Vite + TypeScript 技能商店与一键分发工具。

## 命令

```bash
pnpm dev # Vite 开发服务器 → http://localhost:5173
pnpm build # vue-tsc 类型检查 → vite 构建 → dist/
pnpm build-zip # 构建 + 打包 zip 到系统下载文件夹
```

未配置测试/lint/格式化工具。`build` 是唯一的验证步骤。

## 架构

- **单页应用**:无 vue-router,手动管理路由状态(`route` ref in `App.vue`)
- **分栏布局**:左侧可调宽度面板 + 右侧内容区,通过 `startResize` 实现拖拽调整
- **Preload 脚本**:`public/preload/services.js` 提供 Node.js 能力(文件系统、GitHub API、zip 解压)
- **技能扫描**:通过 `window.services.scanForSkillFiles()` 扫描目录中的 SKILL.md 文件

## 目录结构

```
src/
├── views/ # 页面组件(Home, SkillStore, AgentSkills, ProjectSkills, Settings, Sources)
├── components/ # 共享组件(Modal, Toast, PlatformIcon 等)
├── composables/ # Vue 组合式函数(useSettings 等)
├── utils/ # 工具函数(storage, theme 等)
├── data/ # 静态数据(platforms 等)
└── types.ts # TypeScript 类型定义
public/
├── preload/
│ └── services.js # Node.js 服务(文件操作、GitHub API、压缩包处理)
└── plugin.json # ZTools 插件配置
```

## 关键约束

- **禁止使用浏览器内置弹窗 API**:所有需要用户确认/提示/输入的场景,必须使用项目中已有的自定义 Modal 组件(如 `DeployModal`、`SkillDetailModal`、`AddProjectModal` 等)或 `AppToast`,不得使用 `alert()`、`confirm()`、`prompt()`

- TypeScript `strict: false`,`noImplicitAny: false`(宽松模式)
- 无测试框架,构建即验证
- Preload 脚本使用 CommonJS(`public/preload/package.json` 中 `"type": "commonjs"`)
- 主应用使用 ES Modules(`package.json` 中 `"type": "module"`)
- 样式使用 CSS 变量系统,支持明暗主题切换

## 开发注意

- 添加新功能需在 `src/App.vue` 的路由表中注册
- Preload 服务通过 `window.services` 全局访问
- ZTools API 通过 `window.ztools` 全局访问
- 构建产物在 `dist/` 目录,需复制到 ZTools 插件目录测试
- **打包 zip 文件时,保存到系统下载文件夹**:是系统下载路径,而非应用默认路径

## API 测试

- `api-tests/openai-api.http` — kulala.nvim 测试文件,包含 OpenAI API 多个接口
- 使用前设置环境变量 `OPENAI_API_KEY`

## ZTools 文档

- 本地副本:`docs/ztools-doc/`(9 个 markdown 文件)
- 在线地址:https://ztoolscenter.github.io/ZTools-doc/
- 包含:快速开始、目录结构、plugin.json 配置、preload.js、Node.js 能力、插件 API、发布流程
21 changes: 21 additions & 0 deletions plugins/skill-hub/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 zibo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
130 changes: 130 additions & 0 deletions plugins/skill-hub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Skill Hub

> 一个 ZTools 插件 — AI 编写代码,本人负责使用与维护。

Vue 3 + Vite + TypeScript 构建的技能商店与一键分发工具。浏览 GitHub / skills.sh / 本地的 SKILL.md,扫描项目或 AI Agent 中的已有技能,并通过符号链接或复制的方式一键分发到多个 AI 平台。

## 快速开始

```bash
pnpm dev # 开发服务器 → http://localhost:5173
pnpm build # vue-tsc 类型检查 → vite 构建 → dist/
```

## 功能

### 我的 Skill(默认首页)

列出已下载的技能,支持按分类筛选(全部/收藏/已分发/待分发)。每个技能卡片显示名称、作者、标签、来源,可一键安装到已检测到的 AI Agent 平台,或卸载、收藏、查看详情。

### Skill 商店

从多个来源浏览和搜索技能:

- **Claude Code** — 官方 [anthropics/skills](https://github.com/anthropics/skills) 仓库
- **OpenAI Codex** — 官方 [openai/skills](https://github.com/openai/skills) 仓库
- **skills.sh** — 社区技能市场,支持搜索、热门排序、精选作者
- **自定义源** — 可添加任意 GitHub 仓库或本地目录作为来源

商店支持模糊搜索和语义搜索,提供技能安全审计信息(风险等级、审查摘要)。

### 项目 Skill

注册本地项目目录,自动扫描其中约定的子目录(`.claude/skills`、`.agents/skills`、`skills`、`.cursor/skills`、`.windsurf/skills` 等),识别项目内定义的 SKILL.md 文件。支持添加、编辑、删除项目,查看项目内技能的原始内容和元数据。

### Agent Skill

自动检测本地已安装的 AI Agent 平台(Claude Code / Codex / Cursor / Windsurf / Cline 等),扫描各平台的技能目录,列出已有技能。支持查看技能详情和原始文件内容。

### 商店源管理

管理自定义技能来源,支持三种类型:

- **GitHub 仓库** — 指定仓库名、分支和子目录
- **skills.sh 源** — 社区市场
- **本地目录** — 文件系统中的任意目录

### 设置

- 默认安装模式(符号链接/复制)
- GitHub Token 配置(用于 API 限频提升)
- 各 AI Agent 平台的路径自定义
- 界面主题(浅色/深色/跟随系统)
- 主题色系(雾霾蓝/烟熏紫/豆沙绿/杏色橙/青碧色等莫兰迪色系)
- 字体大小、动画偏好、紧凑模式
- 自定义背景图片
- AI 翻译模型配置(用于技能内容的翻译)

## 架构

```
src/
├── views/ 页面视图(8 个路由页面)
│ ├── MySkills/ 我的技能库
│ ├── SkillStore/ 技能商店(列表 + 详情)
│ ├── ProjectSkills/ 项目技能管理
│ ├── AgentSkills/ Agent 平台技能(列表 + 详情)
│ ├── Sources/ 商店源管理
│ └── Settings/ 设置页面
├── components/ 共享组件(15 个)
│ ├── Modal 家族 AddProjectModal / SkillDetailModal / ConfirmModal 等
│ ├── AppToast 全局 Toast 提示
│ ├── DownloadIndicator 下载进度指示器
│ ├── PlatformIcon 平台图标
│ ├── QuickSwitcher 快捷切换
│ └── ... 编辑器、选择器等
├── composables/ Vue 组合式函数
│ ├── useSettings 设置读写与持久化
│ ├── useProjectState 项目状态管理
│ └── useDownloadQueue 下载队列
├── utils/ 工具函数(9 个)
│ ├── storage.ts 本地存储(localStorage 封装)
│ ├── ai.ts AI 翻译与模型调用
│ ├── theme.ts 主题切换
│ ├── github.ts GitHub API 调用
│ ├── frontmatter.ts SKILL.md 解析
│ ├── skill-registry.ts 技能注册表
│ ├── skills-sh.ts skills.sh API 客户端
│ ├── source-info.ts 来源信息
│ └── translate.ts 翻译服务
├── data/ 静态数据
│ ├── platforms.ts AI Agent 平台定义
│ ├── ai-providers.ts AI 提供方配置
│ └── skill-categories.ts 技能分类
└── types.ts 全部 TypeScript 类型定义

public/
├── plugin.json ZTools 插件配置(4 个 feature / 命令词)
└── preload/
└── services.js Node.js 桥接层(30+ 方法)
```

## 平台支持

自动检测以下 AI Agent 平台的安装位置,支持一键分发技能:

| 平台 | 类型 |
|---|---|
| Claude Code | 官方 |
| OpenAI Codex | 官方 |
| Cursor | 官方 |
| Windsurf | 官方 |
| Cline | 社区 |
| Gemini | 官方 |
| Trae | 社区 |
| Cherry Studio | 社区 |
| Kiro | 社区 |
| 及其他社区客户端 | — |

## 技术栈

- **框架** Vue 3 + TypeScript
- **构建** Vite 6
- **编辑器** CodeMirror 6(支持 YAML / JSON / Markdown / Python / JS / CSS / HTML 语法高亮)
- **后端** ZTools Preload 机制(Node.js 桥接)
- **包管理** pnpm

## 说明

- 源代码由 AI 辅助生成,本人负责功能设计、使用与持续维护。
- 详细开发约束与项目规范见 `AGENTS.md`。
11 changes: 11 additions & 0 deletions plugins/skill-hub/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions plugins/skill-hub/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "skill-hub",
"version": "1.0.0",
"description": "A ZTools plugin",
"license": "MIT",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"build-zip": "pnpm build && node scripts/build-zip.cjs"
},
"dependencies": {
"@codemirror/autocomplete": "^6.20.3",
"@codemirror/commands": "^6.10.3",
"@codemirror/lang-css": "^6.3.1",
"@codemirror/lang-html": "^6.4.11",
"@codemirror/lang-javascript": "^6.2.5",
"@codemirror/lang-json": "^6.0.2",
"@codemirror/lang-markdown": "^6.5.0",
"@codemirror/lang-python": "^6.2.1",
"@codemirror/lang-yaml": "^6.1.3",
"@codemirror/language": "^6.12.3",
"@codemirror/search": "^6.7.1",
"@codemirror/state": "^6.6.0",
"@codemirror/view": "^6.43.1",
"@lezer/highlight": "^1.2.3",
"codemirror": "^6.0.2",
"vue": "^3.5.13"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"@ztools-center/ztools-api-types": "^1.0.1",
"typescript": "^5.3.0",
"vite": "^6.0.11",
"vue-tsc": "^2.0.0"
}
}
Loading
Loading