@workskills/getskill 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/EXAMPLES.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # GetSkill 使用示例
2
2
 
3
- > 当前版本基于 `getskill.work` 静态索引 + ZIP 包下载,搜索/安装/更新**无需 Git、无需登录**。
3
+ > 当前版本基于 `getskill.work` 静态索引 + ZIP 包下载,提供**搜索、下载(安装)、更新**三大核心功能,全部**无需 Git、无需登录**。
4
4
 
5
5
  ## 场景 1: 搜索并安装技能
6
6
 
@@ -156,26 +156,7 @@ const getskill = require('@workskills/getskill');
156
156
  })();
157
157
  ```
158
158
 
159
- ## 场景 5: 发布技能到自有 Git 仓库
160
-
161
- ```bash
162
- $ getskill publish ./my-skill --repo https://github.com/<user>/my-skill.git
163
-
164
- 校验 SKILL.md...
165
- 初始化 Git 仓库...
166
- 提交并推送到 main 分支...
167
- 发布成功: https://github.com/<user>/my-skill
168
- ```
169
-
170
- 可选参数:
171
-
172
- ```bash
173
- getskill publish <目录> --repo <git-url> --branch <name> --message <text>
174
- ```
175
-
176
- > `SKILL.md` 缺失或不符合规范(缺少 front matter、`metadata`、`## 指令` 等关键结构)时,发布会被直接阻止。
177
-
178
- ## 场景 6: 错误处理
159
+ ## 场景 5: 错误处理
179
160
 
180
161
  ```bash
181
162
  # 技能不存在
@@ -191,7 +172,7 @@ $ getskill search pdf
191
172
  提示: 尝试使用不同的关键词,或访问 https://getskill.work 查看所有可用技能
192
173
  ```
193
174
 
194
- ## 场景 7: 配置自定义索引地址
175
+ ## 场景 6: 配置自定义索引地址
195
176
 
196
177
  ```bash
197
178
  # 查看当前索引地址
@@ -206,7 +187,7 @@ BASE_URL 已设置为: https://custom-index.example.com
206
187
  $ GETSKILL_BASE_URL=https://another-index.com getskill search pdf
207
188
  ```
208
189
 
209
- ## 场景 8: 目录结构查看
190
+ ## 场景 7: 目录结构查看
210
191
 
211
192
  ```bash
212
193
  $ tree ~/.openclaw
@@ -226,9 +207,9 @@ $ tree ~/.openclaw
226
207
 
227
208
  ## 常见问题
228
209
 
229
- ### Q: 还需要安装 Git 吗?
210
+ ### Q: 需要安装 Git 吗?
230
211
 
231
- A: 搜索、安装、更新、卸载均不需要 Git(直接 HTTP 下载 ZIP 并本地解压)。只有 `publish` 命令需要本机安装 Git。
212
+ A: 不需要。搜索、安装、更新、卸载均通过 HTTP 直接下载 ZIP 并本地解压完成,全程不依赖 Git。
232
213
 
233
214
  ### Q: 如何卸载技能?
234
215
 
package/README.md CHANGED
@@ -9,19 +9,11 @@ OpenClaw 技能管理工具 - 从 getskill.work 搜索、下载和更新技能
9
9
  - 📥 通过 HTTP 直接下载技能 ZIP 包,本地解压安装(**无需安装 Git**)
10
10
  - 🏷️ 支持安装/更新指定版本(`--version <version>`)
11
11
  - 🔄 基于版本号比较的增量更新(`update` / `update --all`)
12
- - 🚀 支持将本地技能目录发布到自有 Git 远程仓库(`publish`)
13
12
  - 📂 跨平台支持(Windows/macOS/Linux)
14
13
  - 💾 自动管理技能文件到 OpenClaw skills 目录
15
14
  - ⚙️ 支持自定义索引地址
16
15
  - 📦 零第三方运行时依赖(内置 ZIP 解析/解压实现)
17
16
 
18
- ## 工作原理
19
-
20
- 1. **搜索**: 拉取 `https://getskill.work/data/skills.json` 静态索引,本地按关键词过滤
21
- 2. **安装**: 下载 `https://getskill.work/skills/<id>.zip` 到缓存目录并本地解压
22
- 3. **复制**: 将解压后的技能目录复制到 OpenClaw skills 目录,并记录版本信息
23
- 4. **更新**: 比较本地已安装版本与远端索引版本,不一致时重新下载解压
24
-
25
17
  ## 目录结构
26
18
 
27
19
  ```
@@ -75,7 +67,7 @@ npm link
75
67
 
76
68
  ### 搜索技能
77
69
 
78
- > `search` / `install` / `update` / `list` / `inspect` / `clean` **全部无需登录、无需 Git**。只有 `publish` 需要用户提供自己的 Git 远程仓库。
70
+ > 所有命令**全部无需登录、无需 Git**,直接通过 HTTPS 下载 ZIP 包并本地解压。
79
71
 
80
72
  ```bash
81
73
  getskill search <关键词>
@@ -169,29 +161,6 @@ getskill uninstall <技能名称> --keep-cache
169
161
  getskill inspect <技能名称>
170
162
  ```
171
163
 
172
- ### 发布技能目录
173
-
174
- `publish` 将本地技能目录提交并推送到**你自己的 Git 远程仓库**(如 GitHub):
175
-
176
- ```bash
177
- getskill publish <目录> --repo <git-url>
178
- ```
179
-
180
- 默认行为:
181
-
182
- 1. 检查目录中是否存在 `SKILL.md`
183
- 2. 严格校验 `SKILL.md` 是否包含合法 front matter 和必要章节
184
- 3. 初始化/提交本地 Git 仓库,并推送到指定远程
185
-
186
- 可选参数:
187
-
188
- - `--repo <git-url>`: 远程仓库地址(必填)
189
- - `--branch <name>`: 发布分支(默认 `main`)
190
- - `--message <text>`: 自定义提交信息
191
-
192
- > 如果 `SKILL.md` 缺失,或不符合规范(缺少 front matter、`metadata`、`## 指令` 等关键结构),发布会被直接阻止。
193
- > 官方索引(getskill.work)当前不接受自助发布,收录请联系站点维护者。
194
-
195
164
  ### 列出本地技能
196
165
 
197
166
  ```bash
@@ -324,7 +293,6 @@ pdf-extract/
324
293
 
325
294
  - Node.js >= 12(运行 CLI)
326
295
  - Node.js 18+(开发与测试工具)
327
- - Git 命令行工具(仅 `publish` 命令需要;搜索/安装/更新均不依赖 Git)
328
296
 
329
297
  ## 开发与质量保障
330
298
 
@@ -1,4 +1,4 @@
1
- import type { DownloadOptions, DownloadResult, PublishOptions, PublishResult, RemoveInstalledSkillResult, SkillIndexEntry, UpdateAllResult } from './types';
1
+ import type { DownloadOptions, DownloadResult, RemoveInstalledSkillResult, SkillIndexEntry, UpdateAllResult } from './types';
2
2
  export interface FetchSkillToCacheResult {
3
3
  repoPath: string;
4
4
  cachePath: string;
@@ -13,4 +13,3 @@ export declare function updateAllSkills(): Promise<UpdateAllResult[]>;
13
13
  export declare function uninstallSkill(skillName: string, options?: {
14
14
  removeCache?: boolean;
15
15
  }): Promise<RemoveInstalledSkillResult>;
16
- export declare function publishSkill(skillPath: string, options?: PublishOptions): Promise<PublishResult>;
@@ -10,14 +10,12 @@ exports.downloadSkill = downloadSkill;
10
10
  exports.updateSkill = updateSkill;
11
11
  exports.updateAllSkills = updateAllSkills;
12
12
  exports.uninstallSkill = uninstallSkill;
13
- exports.publishSkill = publishSkill;
14
13
  const fs_1 = __importDefault(require("fs"));
15
14
  const path_1 = __importDefault(require("path"));
16
15
  const config_1 = require("./config");
17
16
  const logger_1 = __importDefault(require("./logger"));
18
17
  const network_1 = require("./network");
19
18
  const state_1 = require("./state");
20
- const skill_validator_1 = require("./skill-validator");
21
19
  const system_1 = require("./system");
22
20
  const unzip_1 = require("./unzip");
23
21
  function assertVersionAvailable(entry, requestedVersion) {
@@ -157,112 +155,3 @@ async function uninstallSkill(skillName, options = {}) {
157
155
  }
158
156
  return result;
159
157
  }
160
- function quoteShellArg(value) {
161
- return value.replace(/"/g, '\\"');
162
- }
163
- async function ensureLocalGitIdentity(repoPath, username, email) {
164
- if (username) {
165
- try {
166
- const { stdout } = await (0, system_1.executeCommand)('git config user.name', repoPath);
167
- if (!stdout.trim()) {
168
- throw new Error('missing user.name');
169
- }
170
- }
171
- catch {
172
- await (0, system_1.executeCommand)(`git config user.name "${quoteShellArg(username)}"`, repoPath);
173
- }
174
- }
175
- if (email) {
176
- try {
177
- const { stdout } = await (0, system_1.executeCommand)('git config user.email', repoPath);
178
- if (!stdout.trim()) {
179
- throw new Error('missing user.email');
180
- }
181
- }
182
- catch {
183
- await (0, system_1.executeCommand)(`git config user.email "${quoteShellArg(email)}"`, repoPath);
184
- }
185
- }
186
- }
187
- function resolvePublishRepoName(skillPath, options, skillNameFromManifest) {
188
- const candidate = options.repoName?.trim() ||
189
- skillNameFromManifest ||
190
- path_1.default.basename(skillPath);
191
- const repoName = (0, skill_validator_1.sanitizeRepositoryName)(candidate);
192
- if (!repoName) {
193
- throw new Error('无法确定仓库名称,请通过 --name 指定有效仓库名');
194
- }
195
- return repoName;
196
- }
197
- async function publishSkill(skillPath, options = {}) {
198
- await (0, system_1.ensureGitInstalled)();
199
- const resolvedSkillPath = path_1.default.resolve(skillPath);
200
- if (!fs_1.default.existsSync(resolvedSkillPath)) {
201
- throw new Error(`技能目录不存在: ${resolvedSkillPath}`);
202
- }
203
- const validation = (0, skill_validator_1.validateSkillDirectory)(resolvedSkillPath);
204
- if (!validation.valid) {
205
- throw new Error(`SKILL.md 校验失败:\n- ${validation.errors.join('\n- ')}`);
206
- }
207
- logger_1.default.info('SKILL.md 校验通过,允许继续发布。');
208
- const repoName = resolvePublishRepoName(resolvedSkillPath, options, validation.metadata.name);
209
- const gitDirPath = path_1.default.join(resolvedSkillPath, '.git');
210
- if (!fs_1.default.existsSync(gitDirPath)) {
211
- logger_1.default.info('未检测到 Git 仓库,正在初始化...');
212
- await (0, system_1.executeCommand)('git init', resolvedSkillPath);
213
- }
214
- const branch = options.branch?.trim() || 'main';
215
- const commitMessage = options.message?.trim() || 'chore: publish skill via getskill';
216
- let currentRemoteUrl = '';
217
- if (options.repoUrl?.trim()) {
218
- currentRemoteUrl = options.repoUrl.trim();
219
- }
220
- else {
221
- try {
222
- const { stdout } = await (0, system_1.executeCommand)('git remote get-url origin', resolvedSkillPath);
223
- currentRemoteUrl = stdout.trim();
224
- }
225
- catch {
226
- currentRemoteUrl = '';
227
- }
228
- }
229
- if (!currentRemoteUrl) {
230
- throw new Error('getskill.work 已迁移为 Cloudflare 静态托管,官方技能库不再支持通过 CLI 注册/推送。\n' +
231
- '请使用 --repo <git-url> 发布到你自己的 Git 仓库(如 GitHub),\n' +
232
- '或将技能提交到 https://github.com/work-skills 组织下的技能仓库以收录进官方站点。');
233
- }
234
- try {
235
- await (0, system_1.executeCommand)(`git remote set-url origin "${quoteShellArg(currentRemoteUrl)}"`, resolvedSkillPath);
236
- }
237
- catch {
238
- await (0, system_1.executeCommand)(`git remote add origin "${quoteShellArg(currentRemoteUrl)}"`, resolvedSkillPath);
239
- }
240
- await (0, system_1.executeCommand)(`git checkout -B "${quoteShellArg(branch)}"`, resolvedSkillPath);
241
- await ensureLocalGitIdentity(resolvedSkillPath, options.username, options.email || null);
242
- await (0, system_1.executeCommand)('git add .', resolvedSkillPath);
243
- let committed = false;
244
- try {
245
- await (0, system_1.executeCommand)(`git commit -m "${quoteShellArg(commitMessage)}"`, resolvedSkillPath);
246
- committed = true;
247
- }
248
- catch (error) {
249
- const message = error instanceof Error ? error.message : String(error);
250
- const normalizedMessage = message.toLowerCase();
251
- if (normalizedMessage.includes('nothing to commit') ||
252
- normalizedMessage.includes('nothing added to commit')) {
253
- committed = false;
254
- }
255
- else {
256
- throw error;
257
- }
258
- }
259
- await (0, system_1.executeCommand)(`git push -u origin "${quoteShellArg(branch)}"`, resolvedSkillPath);
260
- logger_1.default.info(`已发布技能目录: ${resolvedSkillPath}`);
261
- return {
262
- skillPath: resolvedSkillPath,
263
- remoteUrl: currentRemoteUrl,
264
- branch,
265
- committed,
266
- repositoryName: repoName
267
- };
268
- }
@@ -3,15 +3,9 @@ export declare function ensureDirectoryExists(dirPath: string): void;
3
3
  export declare function executeCommand(command: string, cwd?: string, options?: {
4
4
  env?: NodeJS.ProcessEnv;
5
5
  }): Promise<CommandOutput>;
6
- export declare function checkGitInstalled(): Promise<boolean>;
7
- export declare function getGitDownloadUrl(): string | null;
8
- export declare function downloadFile(url: string, destPath: string): Promise<string>;
9
- export declare function installGit(): Promise<void>;
10
- export declare function ensureGitInstalled(): Promise<true>;
11
6
  export declare function isInteractiveTerminal(): boolean;
12
7
  export declare function promptForInput(question: string, options?: {
13
8
  defaultValue?: string;
14
9
  required?: boolean;
15
10
  secret?: boolean;
16
11
  }): Promise<string>;
17
- export declare function getGitCommitHash(repoPath: string): Promise<string | null>;
@@ -5,21 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ensureDirectoryExists = ensureDirectoryExists;
7
7
  exports.executeCommand = executeCommand;
8
- exports.checkGitInstalled = checkGitInstalled;
9
- exports.getGitDownloadUrl = getGitDownloadUrl;
10
- exports.downloadFile = downloadFile;
11
- exports.installGit = installGit;
12
- exports.ensureGitInstalled = ensureGitInstalled;
13
8
  exports.isInteractiveTerminal = isInteractiveTerminal;
14
9
  exports.promptForInput = promptForInput;
15
- exports.getGitCommitHash = getGitCommitHash;
16
10
  const fs_1 = __importDefault(require("fs"));
17
- const os_1 = __importDefault(require("os"));
18
- const path_1 = __importDefault(require("path"));
19
11
  const readline_1 = __importDefault(require("readline"));
20
12
  const child_process_1 = require("child_process");
21
- const http_1 = __importDefault(require("http"));
22
- const https_1 = __importDefault(require("https"));
23
13
  function ensureDirectoryExists(dirPath) {
24
14
  if (!fs_1.default.existsSync(dirPath)) {
25
15
  fs_1.default.mkdirSync(dirPath, { recursive: true });
@@ -106,146 +96,6 @@ function executeCommand(command, cwd, options = {}) {
106
96
  });
107
97
  });
108
98
  }
109
- async function checkGitInstalled() {
110
- try {
111
- await executeCommand('git --version');
112
- return true;
113
- }
114
- catch {
115
- return false;
116
- }
117
- }
118
- function getGitDownloadUrl() {
119
- const platform = os_1.default.platform();
120
- const arch = os_1.default.arch();
121
- switch (platform) {
122
- case 'win32':
123
- return arch === 'x64'
124
- ? 'https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/Git-2.44.0-64-bit.exe'
125
- : 'https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/Git-2.44.0-32-bit.exe';
126
- case 'darwin':
127
- return 'homebrew';
128
- case 'linux':
129
- return 'package-manager';
130
- default:
131
- return null;
132
- }
133
- }
134
- function cleanupFile(filePath) {
135
- if (fs_1.default.existsSync(filePath)) {
136
- fs_1.default.unlinkSync(filePath);
137
- }
138
- }
139
- function downloadFile(url, destPath) {
140
- return new Promise((resolve, reject) => {
141
- const urlObj = new URL(url);
142
- const protocol = urlObj.protocol === 'https:' ? https_1.default : http_1.default;
143
- const file = fs_1.default.createWriteStream(destPath);
144
- protocol
145
- .get(url, (response) => {
146
- if (response.statusCode === 301 ||
147
- response.statusCode === 302) {
148
- const locationHeader = response.headers.location;
149
- const redirectLocation = Array.isArray(locationHeader)
150
- ? locationHeader[0]
151
- : locationHeader;
152
- file.close();
153
- cleanupFile(destPath);
154
- if (!redirectLocation) {
155
- reject(new Error('下载重定向缺少 location 头'));
156
- return;
157
- }
158
- downloadFile(redirectLocation, destPath)
159
- .then(resolve)
160
- .catch(reject);
161
- return;
162
- }
163
- if (response.statusCode !== 200) {
164
- file.close();
165
- cleanupFile(destPath);
166
- reject(new Error(`下载失败,状态码: ${response.statusCode}`));
167
- return;
168
- }
169
- const totalSize = Number.parseInt(response.headers['content-length'] || '0', 10);
170
- let downloadedSize = 0;
171
- response.on('data', (chunk) => {
172
- downloadedSize += chunk.length;
173
- if (totalSize > 0) {
174
- const percent = ((downloadedSize / totalSize) *
175
- 100).toFixed(2);
176
- process.stdout.write(`\r下载进度: ${percent}%`);
177
- }
178
- });
179
- response.pipe(file);
180
- file.on('finish', () => {
181
- file.close();
182
- console.log('\n下载完成!');
183
- resolve(destPath);
184
- });
185
- })
186
- .on('error', (error) => {
187
- file.close();
188
- cleanupFile(destPath);
189
- reject(error);
190
- });
191
- });
192
- }
193
- async function installGit() {
194
- const platform = os_1.default.platform();
195
- const downloadUrl = getGitDownloadUrl();
196
- console.log('检测到系统未安装 Git,正在准备安装...\n');
197
- if (downloadUrl === 'homebrew') {
198
- console.log('macOS 系统检测到未安装 Git');
199
- console.log('请使用以下命令安装 Git:\n');
200
- console.log(' brew install git');
201
- console.log('\n如果未安装 Homebrew,请访问: https://brew.sh/');
202
- throw new Error('请先安装 Git 后再运行此命令');
203
- }
204
- if (downloadUrl === 'package-manager') {
205
- console.log('Linux 系统检测到未安装 Git');
206
- console.log('请使用系统包管理器安装 Git:\n');
207
- console.log(' Ubuntu/Debian: sudo apt-get install git');
208
- console.log(' CentOS/RHEL: sudo yum install git');
209
- console.log(' Fedora: sudo dnf install git');
210
- console.log(' Arch: sudo pacman -S git');
211
- throw new Error('请先安装 Git 后再运行此命令');
212
- }
213
- if (platform === 'win32' && downloadUrl) {
214
- console.log('Windows 系统检测到未安装 Git');
215
- console.log('正在下载 Git 安装程序...\n');
216
- const installerPath = path_1.default.join(os_1.default.tmpdir(), 'git-installer.exe');
217
- try {
218
- await downloadFile(downloadUrl, installerPath);
219
- console.log(`\nGit 安装程序已下载到: ${installerPath}`);
220
- console.log('\n正在启动安装程序,请按照提示完成安装...');
221
- console.log('安装完成后,请重新运行此命令。\n');
222
- const child = (0, child_process_1.spawn)(installerPath, [], {
223
- detached: true,
224
- stdio: 'ignore',
225
- windowsHide: false
226
- });
227
- child.on('error', (error) => {
228
- console.error('启动安装程序失败:', error.message);
229
- });
230
- child.unref();
231
- throw new Error('请完成 Git 安装后重新运行此命令');
232
- }
233
- catch (error) {
234
- const message = error instanceof Error ? error.message : String(error);
235
- console.error('\n下载 Git 安装程序失败:', message);
236
- console.log('\n您可以手动访问以下网址下载 Git:');
237
- console.log('https://git-scm.com/download/win');
238
- throw new Error('请先安装 Git 后再运行此命令');
239
- }
240
- }
241
- }
242
- async function ensureGitInstalled() {
243
- const installed = await checkGitInstalled();
244
- if (!installed) {
245
- await installGit();
246
- }
247
- return true;
248
- }
249
99
  function isInteractiveTerminal() {
250
100
  return Boolean(process.stdin.isTTY && process.stdout.isTTY);
251
101
  }
@@ -296,12 +146,3 @@ function promptForInput(question, options = {}) {
296
146
  });
297
147
  });
298
148
  }
299
- async function getGitCommitHash(repoPath) {
300
- try {
301
- const { stdout } = await executeCommand('git rev-parse HEAD', repoPath);
302
- return stdout.trim();
303
- }
304
- catch {
305
- return null;
306
- }
307
- }
@@ -101,31 +101,3 @@ export interface RemoveInstalledSkillResult {
101
101
  skillDir: string;
102
102
  repoPath: string;
103
103
  }
104
- export interface PublishOptions {
105
- repoUrl?: string;
106
- repoName?: string;
107
- branch?: string;
108
- message?: string;
109
- username?: string;
110
- email?: string;
111
- }
112
- export interface SkillValidationResult {
113
- valid: boolean;
114
- errors: string[];
115
- metadata: {
116
- name?: string;
117
- description?: string;
118
- license?: string;
119
- compatibility?: string;
120
- author?: string;
121
- version?: string;
122
- category?: string;
123
- };
124
- }
125
- export interface PublishResult {
126
- skillPath: string;
127
- remoteUrl: string;
128
- branch: string;
129
- committed: boolean;
130
- repositoryName?: string;
131
- }
package/dist/main.d.ts CHANGED
@@ -2,9 +2,8 @@
2
2
  import { getBaseUrl, getSkillsCacheDirectory, getSkillsDirectory, setBaseUrl } from './lib/config';
3
3
  import { repositoryHasSkillFile, searchSkills } from './lib/network';
4
4
  import { copySkillFiles, getInstalledSkillInfo, listLocalSkills } from './lib/state';
5
- import { checkGitInstalled, ensureGitInstalled } from './lib/system';
6
- import { cloneOrUpdateRepo, downloadSkill, publishSkill, uninstallSkill, updateAllSkills, updateSkill } from './lib/skill-manager';
5
+ import { cloneOrUpdateRepo, downloadSkill, uninstallSkill, updateAllSkills, updateSkill } from './lib/skill-manager';
7
6
  export declare function printHelp(): void;
8
7
  export declare function getCliVersion(): string;
9
8
  export declare function cli(): Promise<void>;
10
- export { searchSkills, downloadSkill, updateSkill, updateAllSkills, publishSkill, uninstallSkill, listLocalSkills, getInstalledSkillInfo, getSkillsDirectory, getSkillsCacheDirectory, cloneOrUpdateRepo, copySkillFiles, repositoryHasSkillFile, checkGitInstalled, ensureGitInstalled, setBaseUrl, getBaseUrl };
9
+ export { searchSkills, downloadSkill, updateSkill, updateAllSkills, uninstallSkill, listLocalSkills, getInstalledSkillInfo, getSkillsDirectory, getSkillsCacheDirectory, cloneOrUpdateRepo, copySkillFiles, repositoryHasSkillFile, setBaseUrl, getBaseUrl };
package/dist/main.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getBaseUrl = exports.setBaseUrl = exports.ensureGitInstalled = exports.checkGitInstalled = exports.repositoryHasSkillFile = exports.copySkillFiles = exports.cloneOrUpdateRepo = exports.getSkillsCacheDirectory = exports.getSkillsDirectory = exports.getInstalledSkillInfo = exports.listLocalSkills = exports.uninstallSkill = exports.publishSkill = exports.updateAllSkills = exports.updateSkill = exports.downloadSkill = exports.searchSkills = void 0;
7
+ exports.getBaseUrl = exports.setBaseUrl = exports.repositoryHasSkillFile = exports.copySkillFiles = exports.cloneOrUpdateRepo = exports.getSkillsCacheDirectory = exports.getSkillsDirectory = exports.getInstalledSkillInfo = exports.listLocalSkills = exports.uninstallSkill = exports.updateAllSkills = exports.updateSkill = exports.downloadSkill = exports.searchSkills = void 0;
8
8
  exports.printHelp = printHelp;
9
9
  exports.getCliVersion = getCliVersion;
10
10
  exports.cli = cli;
@@ -23,13 +23,9 @@ const state_1 = require("./lib/state");
23
23
  Object.defineProperty(exports, "copySkillFiles", { enumerable: true, get: function () { return state_1.copySkillFiles; } });
24
24
  Object.defineProperty(exports, "getInstalledSkillInfo", { enumerable: true, get: function () { return state_1.getInstalledSkillInfo; } });
25
25
  Object.defineProperty(exports, "listLocalSkills", { enumerable: true, get: function () { return state_1.listLocalSkills; } });
26
- const system_1 = require("./lib/system");
27
- Object.defineProperty(exports, "checkGitInstalled", { enumerable: true, get: function () { return system_1.checkGitInstalled; } });
28
- Object.defineProperty(exports, "ensureGitInstalled", { enumerable: true, get: function () { return system_1.ensureGitInstalled; } });
29
26
  const skill_manager_1 = require("./lib/skill-manager");
30
27
  Object.defineProperty(exports, "cloneOrUpdateRepo", { enumerable: true, get: function () { return skill_manager_1.cloneOrUpdateRepo; } });
31
28
  Object.defineProperty(exports, "downloadSkill", { enumerable: true, get: function () { return skill_manager_1.downloadSkill; } });
32
- Object.defineProperty(exports, "publishSkill", { enumerable: true, get: function () { return skill_manager_1.publishSkill; } });
33
29
  Object.defineProperty(exports, "uninstallSkill", { enumerable: true, get: function () { return skill_manager_1.uninstallSkill; } });
34
30
  Object.defineProperty(exports, "updateAllSkills", { enumerable: true, get: function () { return skill_manager_1.updateAllSkills; } });
35
31
  Object.defineProperty(exports, "updateSkill", { enumerable: true, get: function () { return skill_manager_1.updateSkill; } });
@@ -87,8 +83,6 @@ function printHelp() {
87
83
  console.log(' getskill update <技能名称> - 检查在线版本并更新技能');
88
84
  console.log(' getskill update <技能名称> --version <tag> - 更新到指定版本');
89
85
  console.log(' getskill update --all - 批量更新所有已安装技能');
90
- console.log(' getskill publish <目录> [--repo <git-url>] - 发布技能到你自己的 Git 仓库');
91
- console.log(' getskill publish <目录> --name <repo-name> - 指定仓库名(需配合 --repo)');
92
86
  console.log(' getskill uninstall <技能名称> - 卸载本地技能');
93
87
  console.log(' getskill inspect <技能名称> - 查看本地安装与缓存状态');
94
88
  console.log(' getskill list - 列出本地技能');
@@ -103,7 +97,6 @@ function printHelp() {
103
97
  console.log(' getskill search pdf --json');
104
98
  console.log(' getskill update ab-testing');
105
99
  console.log(' getskill update --all');
106
- console.log(' getskill publish ./my-skill --repo https://github.com/yourname/my-skill.git');
107
100
  console.log(' getskill inspect ab-testing');
108
101
  console.log('');
109
102
  console.log(`当前站点: ${(0, config_1.getBaseUrl)()}`);
@@ -251,44 +244,6 @@ async function cli() {
251
244
  }
252
245
  break;
253
246
  }
254
- case 'publish': {
255
- const { positionals, options } = parseCommandOptions(args.slice(1));
256
- const skillPath = positionals[0];
257
- const repoUrl = typeof options.repo === 'string' ? options.repo : undefined;
258
- const repoName = typeof options.name === 'string' ? options.name : undefined;
259
- const branch = typeof options.branch === 'string'
260
- ? options.branch
261
- : undefined;
262
- const message = typeof options.message === 'string'
263
- ? options.message
264
- : undefined;
265
- const username = typeof options.username === 'string'
266
- ? options.username
267
- : undefined;
268
- const email = typeof options.email === 'string'
269
- ? options.email
270
- : undefined;
271
- if (!skillPath) {
272
- console.error('请提供技能目录路径');
273
- console.log('用法: getskill publish <目录> [--repo <git-url>] [--name repo-name] [--branch main] [--message "..."]');
274
- process.exit(1);
275
- }
276
- const result = await (0, skill_manager_1.publishSkill)(skillPath, {
277
- repoUrl,
278
- repoName,
279
- branch,
280
- message,
281
- username,
282
- email
283
- });
284
- console.log('\n发布完成:');
285
- console.log(` 目录: ${result.skillPath}`);
286
- console.log(` 仓库: ${result.repositoryName || 'unknown'}`);
287
- console.log(` 远程: ${result.remoteUrl}`);
288
- console.log(` 分支: ${result.branch}`);
289
- console.log(` 本次是否提交新变更: ${result.committed ? '是' : '否'}`);
290
- break;
291
- }
292
247
  case 'uninstall': {
293
248
  if (!args[1]) {
294
249
  console.error('请提供技能名称');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workskills/getskill",
3
- "version": "1.2.0",
4
3
  "description": "A skill management tool for OpenClaw that enables searching, downloading, and updating skill files from the getskill.work repository",
4
+ "version": "2.0.0",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",
7
7
  "bin": {
@@ -39,7 +39,6 @@
39
39
  "search",
40
40
  "install",
41
41
  "update",
42
- "git",
43
42
  "cli",
44
43
  "claude",
45
44
  "ai",
@@ -1,4 +0,0 @@
1
- import type { SkillValidationResult } from './types';
2
- export declare function sanitizeRepositoryName(input: string): string;
3
- export declare function validateSkillMarkdownContent(content: string): SkillValidationResult;
4
- export declare function validateSkillDirectory(skillPath: string): SkillValidationResult;
@@ -1,107 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.sanitizeRepositoryName = sanitizeRepositoryName;
7
- exports.validateSkillMarkdownContent = validateSkillMarkdownContent;
8
- exports.validateSkillDirectory = validateSkillDirectory;
9
- const fs_1 = __importDefault(require("fs"));
10
- const path_1 = __importDefault(require("path"));
11
- const REQUIRED_FRONTMATTER_KEYS = [
12
- 'name',
13
- 'description',
14
- 'license',
15
- 'compatibility'
16
- ];
17
- const REQUIRED_METADATA_KEYS = ['author', 'version', 'category'];
18
- const REQUIRED_SECTIONS = ['## 何时使用此 Skill', '## 指令'];
19
- function cleanYamlValue(value) {
20
- if (!value) {
21
- return undefined;
22
- }
23
- return value.trim().replace(/^['"]|['"]$/g, '');
24
- }
25
- function extractFrontMatter(content) {
26
- const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
27
- if (!match) {
28
- return null;
29
- }
30
- return {
31
- frontMatter: match[1],
32
- body: match[2]
33
- };
34
- }
35
- function readTopLevelValue(frontMatter, key) {
36
- const match = frontMatter.match(new RegExp(`^${key}:\\s*(.+)$`, 'm'));
37
- return cleanYamlValue(match?.[1]);
38
- }
39
- function readMetadataValue(frontMatter, key) {
40
- const match = frontMatter.match(new RegExp(`^\\s+${key}:\\s*(.+)$`, 'm'));
41
- return cleanYamlValue(match?.[1]);
42
- }
43
- function sanitizeRepositoryName(input) {
44
- return input
45
- .trim()
46
- .replace(/\.git$/i, '')
47
- .replace(/[^a-zA-Z0-9._-]+/g, '-')
48
- .replace(/-{2,}/g, '-')
49
- .replace(/^-+|-+$/g, '')
50
- .toLowerCase();
51
- }
52
- function validateSkillMarkdownContent(content) {
53
- const errors = [];
54
- const metadata = {};
55
- const parsed = extractFrontMatter(content);
56
- if (!parsed) {
57
- return {
58
- valid: false,
59
- errors: ['SKILL.md 必须包含 YAML front matter(使用 --- 包裹)'],
60
- metadata
61
- };
62
- }
63
- for (const key of REQUIRED_FRONTMATTER_KEYS) {
64
- const value = readTopLevelValue(parsed.frontMatter, key);
65
- if (!value) {
66
- errors.push(`front matter 缺少必填字段: ${key}`);
67
- continue;
68
- }
69
- metadata[key] = value;
70
- }
71
- if (!/^metadata:\s*$/m.test(parsed.frontMatter)) {
72
- errors.push('front matter 缺少 metadata 区块');
73
- }
74
- for (const key of REQUIRED_METADATA_KEYS) {
75
- const value = readMetadataValue(parsed.frontMatter, key);
76
- if (!value) {
77
- errors.push(`metadata 缺少必填字段: ${key}`);
78
- continue;
79
- }
80
- metadata[key] = value;
81
- }
82
- if (!/^#\s+.+$/m.test(parsed.body)) {
83
- errors.push('正文缺少一级标题(例如 # My Skill)');
84
- }
85
- for (const section of REQUIRED_SECTIONS) {
86
- if (!parsed.body.includes(section)) {
87
- errors.push(`正文缺少必填章节: ${section}`);
88
- }
89
- }
90
- return {
91
- valid: errors.length === 0,
92
- errors,
93
- metadata
94
- };
95
- }
96
- function validateSkillDirectory(skillPath) {
97
- const skillFilePath = path_1.default.join(skillPath, 'SKILL.md');
98
- if (!fs_1.default.existsSync(skillFilePath)) {
99
- return {
100
- valid: false,
101
- errors: ['publish 目录中缺少 SKILL.md'],
102
- metadata: {}
103
- };
104
- }
105
- const content = fs_1.default.readFileSync(skillFilePath, 'utf8');
106
- return validateSkillMarkdownContent(content);
107
- }