@workskills/getskill 1.1.10 → 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/dist/lib/state.js CHANGED
@@ -91,11 +91,10 @@ function writeInstallState(state) {
91
91
  (0, system_1.ensureDirectoryExists)(path_1.default.dirname(stateFilePath));
92
92
  fs_1.default.writeFileSync(stateFilePath, JSON.stringify(state, null, 2), 'utf8');
93
93
  }
94
- async function updateInstallState(skillName, repoPath, installDir, action, requestedVersion) {
94
+ async function updateInstallState(skillName, repoPath, installDir, action, requestedVersion, version) {
95
95
  const localSkillName = normalizeSkillName(skillName);
96
96
  const remoteSkillPath = getRemoteSkillPath(skillName);
97
97
  const now = new Date().toISOString();
98
- const commitHash = await (0, system_1.getGitCommitHash)(repoPath);
99
98
  const state = readInstallState();
100
99
  const previous = state.skills[localSkillName];
101
100
  state.skills[localSkillName] = {
@@ -107,8 +106,9 @@ async function updateInstallState(skillName, repoPath, installDir, action, reque
107
106
  lastAction: action,
108
107
  installedAt: previous?.installedAt || now,
109
108
  updatedAt: now,
110
- gitCommitHash: commitHash || previous?.gitCommitHash || null,
111
- requestedVersion: requestedVersion ?? previous?.requestedVersion ?? null
109
+ gitCommitHash: previous?.gitCommitHash || null,
110
+ requestedVersion: requestedVersion ?? previous?.requestedVersion ?? null,
111
+ version: version ?? previous?.version ?? null
112
112
  };
113
113
  writeInstallState(state);
114
114
  }
@@ -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
- }
@@ -22,6 +22,22 @@ export interface SearchOptions {
22
22
  page?: number;
23
23
  limit?: number;
24
24
  }
25
+ export interface SkillIndexEntry {
26
+ id: string;
27
+ name: string;
28
+ description: string;
29
+ category?: string;
30
+ tags?: string[];
31
+ version: string;
32
+ author?: string;
33
+ updated?: string;
34
+ file: string;
35
+ size?: number;
36
+ source?: string;
37
+ }
38
+ export interface SkillsIndexPayload {
39
+ skills?: SkillIndexEntry[];
40
+ }
25
41
  export interface SearchSkill {
26
42
  name: string;
27
43
  full_name: string;
@@ -29,27 +45,11 @@ export interface SearchSkill {
29
45
  html_url: string;
30
46
  git_url: string;
31
47
  clone_url: string;
32
- }
33
- export interface RepositoryCandidate {
34
- name?: string;
35
- full_name?: string;
36
- description?: string;
37
- html_url?: string;
38
- clone_url?: string;
39
- private?: boolean;
40
- empty?: boolean;
41
- archived?: boolean;
42
- template?: boolean;
43
- fork?: boolean;
44
- }
45
- export interface SearchApiItem {
46
- repository?: RepositoryCandidate;
47
- [key: string]: unknown;
48
- }
49
- export interface SearchApiPayload {
50
- ok?: boolean;
51
- message?: string;
52
- data?: Array<RepositoryCandidate | SearchApiItem>;
48
+ download_url: string;
49
+ version: string;
50
+ category: string;
51
+ author: string;
52
+ size: number;
53
53
  }
54
54
  export interface SkillStateRecord {
55
55
  inputSkillName: string;
@@ -62,6 +62,7 @@ export interface SkillStateRecord {
62
62
  updatedAt: string;
63
63
  gitCommitHash: string | null;
64
64
  requestedVersion?: string | null;
65
+ version?: string | null;
65
66
  }
66
67
  export interface InstallState {
67
68
  skills: Record<string, SkillStateRecord>;
@@ -71,6 +72,8 @@ export interface DownloadResult {
71
72
  repoPath: string;
72
73
  files: string[];
73
74
  requestedVersion?: string | null;
75
+ version?: string | null;
76
+ upToDate?: boolean;
74
77
  }
75
78
  export interface DownloadOptions {
76
79
  version?: string;
@@ -98,53 +101,3 @@ export interface RemoveInstalledSkillResult {
98
101
  skillDir: string;
99
102
  repoPath: string;
100
103
  }
101
- export interface PublishOptions {
102
- repoUrl?: string;
103
- repoName?: string;
104
- branch?: string;
105
- message?: string;
106
- username?: string;
107
- email?: string;
108
- password?: string;
109
- visibility?: 'public' | 'private';
110
- }
111
- export interface AuthSession {
112
- username: string;
113
- email?: string | null;
114
- token: string;
115
- }
116
- export interface EnsureAuthResult extends AuthSession {
117
- mode: 'stored-token' | 'login' | 'register';
118
- }
119
- export interface RegistryUser {
120
- username: string;
121
- email?: string | null;
122
- }
123
- export interface RepoCreationResult {
124
- name: string;
125
- cloneUrl: string;
126
- htmlUrl?: string;
127
- existed: boolean;
128
- }
129
- export interface SkillValidationResult {
130
- valid: boolean;
131
- errors: string[];
132
- metadata: {
133
- name?: string;
134
- description?: string;
135
- license?: string;
136
- compatibility?: string;
137
- author?: string;
138
- version?: string;
139
- category?: string;
140
- };
141
- }
142
- export interface PublishResult {
143
- skillPath: string;
144
- remoteUrl: string;
145
- branch: string;
146
- committed: boolean;
147
- repositoryName?: string;
148
- createdRemoteRepo?: boolean;
149
- authMode?: 'stored-token' | 'login' | 'register' | 'not-required';
150
- }
@@ -0,0 +1,3 @@
1
+ export declare function sanitizeZipEntryName(entryName: string): string;
2
+ export declare function extractZip(zipPath: string, destDir: string): string[];
3
+ export declare function resolveSkillRoot(dir: string, maxDepth?: number): string;
@@ -0,0 +1,122 @@
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.sanitizeZipEntryName = sanitizeZipEntryName;
7
+ exports.extractZip = extractZip;
8
+ exports.resolveSkillRoot = resolveSkillRoot;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const zlib_1 = __importDefault(require("zlib"));
12
+ const EOCD_SIGNATURE = 0x06054b50;
13
+ const CENTRAL_DIRECTORY_SIGNATURE = 0x02014b50;
14
+ const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50;
15
+ const EOCD_MIN_SIZE = 22;
16
+ const EOCD_MAX_COMMENT_SIZE = 0xffff;
17
+ function sanitizeZipEntryName(entryName) {
18
+ const normalized = entryName.replace(/\\/g, '/');
19
+ if (path_1.default.isAbsolute(normalized) || /^[a-zA-Z]:/.test(normalized)) {
20
+ throw new Error(`zip 条目包含非法绝对路径: ${entryName}`);
21
+ }
22
+ const segments = normalized
23
+ .split('/')
24
+ .filter((segment) => segment && segment !== '.')
25
+ .filter((segment) => segment !== '');
26
+ for (const segment of segments) {
27
+ if (segment === '..') {
28
+ throw new Error(`zip 条目包含非法上级路径: ${entryName}`);
29
+ }
30
+ }
31
+ return segments.join(path_1.default.sep);
32
+ }
33
+ function findEndOfCentralDirectory(buffer) {
34
+ const searchStart = Math.max(0, buffer.length - EOCD_MIN_SIZE - EOCD_MAX_COMMENT_SIZE);
35
+ for (let offset = buffer.length - EOCD_MIN_SIZE; offset >= searchStart; offset -= 1) {
36
+ if (buffer.readUInt32LE(offset) === EOCD_SIGNATURE) {
37
+ return offset;
38
+ }
39
+ }
40
+ return -1;
41
+ }
42
+ function extractZip(zipPath, destDir) {
43
+ if (!fs_1.default.existsSync(zipPath)) {
44
+ throw new Error(`zip 文件不存在: ${zipPath}`);
45
+ }
46
+ const buffer = fs_1.default.readFileSync(zipPath);
47
+ const eocdOffset = findEndOfCentralDirectory(buffer);
48
+ if (eocdOffset < 0) {
49
+ throw new Error('解压失败: 无效的 zip 文件(未找到中央目录记录)');
50
+ }
51
+ const entryCount = buffer.readUInt16LE(eocdOffset + 10);
52
+ let cursor = buffer.readUInt32LE(eocdOffset + 16);
53
+ const extractedFiles = [];
54
+ for (let index = 0; index < entryCount; index += 1) {
55
+ if (cursor + 46 > buffer.length ||
56
+ buffer.readUInt32LE(cursor) !== CENTRAL_DIRECTORY_SIGNATURE) {
57
+ throw new Error('解压失败: 中央目录记录损坏');
58
+ }
59
+ const method = buffer.readUInt16LE(cursor + 10);
60
+ const compressedSize = buffer.readUInt32LE(cursor + 20);
61
+ const fileNameLength = buffer.readUInt16LE(cursor + 28);
62
+ const extraFieldLength = buffer.readUInt16LE(cursor + 30);
63
+ const commentLength = buffer.readUInt16LE(cursor + 32);
64
+ const localHeaderOffset = buffer.readUInt32LE(cursor + 42);
65
+ const rawName = buffer.subarray(cursor + 46, cursor + 46 + fileNameLength);
66
+ const entryName = rawName.toString('utf8');
67
+ cursor += 46 + fileNameLength + extraFieldLength + commentLength;
68
+ const isDirectory = entryName.endsWith('/');
69
+ const safeName = sanitizeZipEntryName(entryName);
70
+ if (!safeName) {
71
+ continue;
72
+ }
73
+ const targetPath = path_1.default.join(destDir, safeName);
74
+ if (isDirectory) {
75
+ fs_1.default.mkdirSync(targetPath, { recursive: true });
76
+ continue;
77
+ }
78
+ if (localHeaderOffset + 30 > buffer.length ||
79
+ buffer.readUInt32LE(localHeaderOffset) !==
80
+ LOCAL_FILE_HEADER_SIGNATURE) {
81
+ throw new Error(`解压失败: 本地文件头损坏 (${entryName})`);
82
+ }
83
+ const localNameLength = buffer.readUInt16LE(localHeaderOffset + 26);
84
+ const localExtraLength = buffer.readUInt16LE(localHeaderOffset + 28);
85
+ const dataStart = localHeaderOffset + 30 + localNameLength + localExtraLength;
86
+ const dataEnd = dataStart + compressedSize;
87
+ if (dataEnd > buffer.length) {
88
+ throw new Error(`解压失败: 文件数据不完整 (${entryName})`);
89
+ }
90
+ const compressedData = buffer.subarray(dataStart, dataEnd);
91
+ let fileData;
92
+ if (method === 0) {
93
+ fileData = Buffer.from(compressedData);
94
+ }
95
+ else if (method === 8) {
96
+ fileData = zlib_1.default.inflateRawSync(compressedData);
97
+ }
98
+ else {
99
+ throw new Error(`解压失败: 不支持的压缩算法 ${method} (${entryName})`);
100
+ }
101
+ fs_1.default.mkdirSync(path_1.default.dirname(targetPath), { recursive: true });
102
+ fs_1.default.writeFileSync(targetPath, fileData);
103
+ extractedFiles.push(safeName);
104
+ }
105
+ return extractedFiles;
106
+ }
107
+ function resolveSkillRoot(dir, maxDepth = 5) {
108
+ let current = dir;
109
+ for (let depth = 0; depth < maxDepth; depth += 1) {
110
+ if (!fs_1.default.existsSync(current)) {
111
+ break;
112
+ }
113
+ const entries = fs_1.default.readdirSync(current, { withFileTypes: true });
114
+ const directories = entries.filter((entry) => entry.isDirectory());
115
+ const files = entries.filter((entry) => entry.isFile());
116
+ if (directories.length !== 1 || files.length !== 0) {
117
+ break;
118
+ }
119
+ current = path_1.default.join(current, directories[0].name);
120
+ }
121
+ return current;
122
+ }
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; } });
@@ -75,40 +71,36 @@ function parseCommandOptions(rawArgs) {
75
71
  return { positionals, options };
76
72
  }
77
73
  function printHelp() {
78
- console.log('GetSkill - OpenClaw 技能管理工具');
74
+ console.log('GetSkill - OpenClaw 技能管理工具 (getskill.work · Cloudflare 静态托管)');
79
75
  console.log('');
80
76
  console.log('用法:');
81
77
  console.log(' getskill --help - 显示帮助信息');
82
78
  console.log(' getskill --version - 显示版本号');
83
- console.log(' getskill search <关键词> - 从 API 搜索技能');
79
+ console.log(' getskill search <关键词> - 从技能索引搜索技能');
84
80
  console.log(' getskill search <关键词> --json - JSON 格式输出搜索结果');
85
- console.log(' getskill install <技能名称> - 通过 git clone 安装技能');
86
- console.log(' getskill install <技能名称> --version <tag> - 安装指定版本');
87
- console.log(' getskill update <技能名称> - 通过 git pull 更新技能');
88
- console.log(' getskill update <技能名称> --version <tag> - 切换到指定版本');
81
+ console.log(' getskill install <技能名称> - 通过 HTTPS 下载 zip 包安装技能');
82
+ console.log(' getskill install <技能名称> --version <tag> - 安装指定版本(需与站点当前版本一致)');
83
+ console.log(' getskill update <技能名称> - 检查在线版本并更新技能');
84
+ console.log(' getskill update <技能名称> --version <tag> - 更新到指定版本');
89
85
  console.log(' getskill update --all - 批量更新所有已安装技能');
90
- console.log(' getskill publish <目录> [--repo <git-url>] - 自动注册/登录并发布技能');
91
- console.log(' getskill publish <目录> --name <repo-name> - 自动创建远程仓库并提交');
92
86
  console.log(' getskill uninstall <技能名称> - 卸载本地技能');
93
87
  console.log(' getskill inspect <技能名称> - 查看本地安装与缓存状态');
94
88
  console.log(' getskill list - 列出本地技能');
95
89
  console.log(' getskill path - 显示目录路径');
96
- console.log(' getskill config set <URL> - 设置自定义 API 地址');
97
- console.log(' getskill config get - 查看当前 API 地址');
98
- console.log(' getskill clean - 清理 git 缓存');
90
+ console.log(' getskill config set <URL> - 设置自定义站点地址');
91
+ console.log(' getskill config get - 查看当前站点地址');
92
+ console.log(' getskill clean - 清理下载缓存');
99
93
  console.log('');
100
94
  console.log('示例:');
101
- console.log(' getskill install pdf-extract');
102
- console.log(' getskill install skills/xejrax_pdf-extract');
103
- console.log(' getskill install pdf-extract --version v1.0.0');
95
+ console.log(' getskill install ab-testing');
96
+ console.log(' getskill install ab-testing --version 2.0.7');
104
97
  console.log(' getskill search pdf --json');
105
- console.log(' getskill update pdf-extract');
98
+ console.log(' getskill update ab-testing');
106
99
  console.log(' getskill update --all');
107
- console.log(' getskill publish ./my-skill --name my-skill');
108
- console.log(' getskill publish ./my-skill --repo https://getskill.work/user/my-skill.git');
109
- console.log(' getskill inspect pdf-extract');
100
+ console.log(' getskill inspect ab-testing');
110
101
  console.log('');
111
- console.log(`当前 API: ${(0, config_1.getBaseUrl)()}`);
102
+ console.log(`当前站点: ${(0, config_1.getBaseUrl)()}`);
103
+ console.log(`技能索引: ${(0, config_1.getBaseUrl)()}/data/skills.json`);
112
104
  console.log(`技能目录: ${(0, config_1.getSkillsDirectory)()}`);
113
105
  console.log(`缓存目录: ${(0, config_1.getSkillsCacheDirectory)()}`);
114
106
  }
@@ -170,12 +162,15 @@ async function cli() {
170
162
  }
171
163
  console.log(`找到 ${results.length} 个技能:\n`);
172
164
  results.forEach((skill, index) => {
173
- console.log(`${index + 1}. ${skill.full_name}`);
165
+ console.log(`${index + 1}. ${skill.full_name} (v${skill.version})`);
174
166
  if (skill.description) {
175
167
  console.log(` 描述: ${skill.description}`);
176
168
  }
177
- if (skill.git_url) {
178
- console.log(` Git: ${skill.git_url}`);
169
+ if (skill.category) {
170
+ console.log(` 分类: ${skill.category}`);
171
+ }
172
+ if (skill.download_url) {
173
+ console.log(` 下载: ${skill.download_url}`);
179
174
  }
180
175
  console.log('');
181
176
  });
@@ -200,9 +195,9 @@ async function cli() {
200
195
  });
201
196
  console.log('\n技能已安装到 skills 目录:');
202
197
  result.files.forEach((file) => console.log(` - ${file}`));
203
- console.log(`\nGit 仓库缓存: ${result.repoPath}`);
204
- if (result.requestedVersion) {
205
- console.log(`已安装版本: ${result.requestedVersion}`);
198
+ console.log(`\n本地缓存: ${result.repoPath}`);
199
+ if (result.version) {
200
+ console.log(`已安装版本: ${result.version}`);
206
201
  }
207
202
  break;
208
203
  }
@@ -238,57 +233,15 @@ async function cli() {
238
233
  const result = await (0, skill_manager_1.updateSkill)(skillName, {
239
234
  version: requestedVersion
240
235
  });
236
+ if (result.upToDate) {
237
+ console.log(`\n技能已是最新版本 (v${result.version || 'unknown'}),无需更新。`);
238
+ break;
239
+ }
241
240
  console.log('\n技能已更新到 skills 目录:');
242
241
  result.files.forEach((file) => console.log(` - ${file}`));
243
- if (result.requestedVersion) {
244
- console.log(`已切换到版本: ${result.requestedVersion}`);
245
- }
246
- break;
247
- }
248
- case 'publish': {
249
- const { positionals, options } = parseCommandOptions(args.slice(1));
250
- const skillPath = positionals[0];
251
- const repoUrl = typeof options.repo === 'string' ? options.repo : undefined;
252
- const repoName = typeof options.name === 'string' ? options.name : undefined;
253
- const branch = typeof options.branch === 'string'
254
- ? options.branch
255
- : undefined;
256
- const message = typeof options.message === 'string'
257
- ? options.message
258
- : undefined;
259
- const username = typeof options.username === 'string'
260
- ? options.username
261
- : undefined;
262
- const email = typeof options.email === 'string'
263
- ? options.email
264
- : undefined;
265
- const password = typeof options.password === 'string'
266
- ? options.password
267
- : undefined;
268
- const visibility = options.private ? 'private' : 'public';
269
- if (!skillPath) {
270
- console.error('请提供技能目录路径');
271
- console.log('用法: getskill publish <目录> [--repo <git-url>] [--name repo-name] [--branch main] [--message "..."]');
272
- process.exit(1);
242
+ if (result.version) {
243
+ console.log(`当前版本: ${result.version}`);
273
244
  }
274
- const result = await (0, skill_manager_1.publishSkill)(skillPath, {
275
- repoUrl,
276
- repoName,
277
- branch,
278
- message,
279
- username,
280
- email,
281
- password,
282
- visibility
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.authMode || 'unknown'}`);
290
- console.log(` 本次是否自动创建远程仓库: ${result.createdRemoteRepo ? '是' : '否'}`);
291
- console.log(` 本次是否提交新变更: ${result.committed ? '是' : '否'}`);
292
245
  break;
293
246
  }
294
247
  case 'uninstall': {
@@ -322,7 +275,7 @@ async function cli() {
322
275
  console.log(`最后动作: ${info.state.lastAction || 'unknown'}`);
323
276
  console.log(`安装时间: ${info.state.installedAt || 'unknown'}`);
324
277
  console.log(`更新时间: ${info.state.updatedAt || 'unknown'}`);
325
- console.log(`Commit: ${info.state.gitCommitHash || 'unknown'}`);
278
+ console.log(`版本: ${info.state.version || info.state.gitCommitHash || 'unknown'}`);
326
279
  }
327
280
  else {
328
281
  console.log('状态文件中暂无该技能记录。');