@workskills/getskill 1.2.0 → 2.1.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 +98 -72
- package/README.md +167 -200
- package/dist/lib/config.d.ts +81 -4
- package/dist/lib/config.js +473 -21
- package/dist/lib/skill-manager.d.ts +7 -4
- package/dist/lib/skill-manager.js +55 -118
- package/dist/lib/state.d.ts +11 -0
- package/dist/lib/state.js +126 -14
- package/dist/lib/system.d.ts +0 -6
- package/dist/lib/system.js +0 -159
- package/dist/lib/types.d.ts +14 -28
- package/dist/main.d.ts +9 -5
- package/dist/main.js +280 -89
- package/package.json +9 -4
- package/dist/lib/skill-validator.d.ts +0 -4
- package/dist/lib/skill-validator.js +0 -107
package/dist/lib/types.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ export interface SkillStateRecord {
|
|
|
63
63
|
gitCommitHash: string | null;
|
|
64
64
|
requestedVersion?: string | null;
|
|
65
65
|
version?: string | null;
|
|
66
|
+
agent?: string | null;
|
|
67
|
+
skillsDir?: string | null;
|
|
66
68
|
}
|
|
67
69
|
export interface InstallState {
|
|
68
70
|
skills: Record<string, SkillStateRecord>;
|
|
@@ -78,9 +80,15 @@ export interface DownloadResult {
|
|
|
78
80
|
export interface DownloadOptions {
|
|
79
81
|
version?: string;
|
|
80
82
|
}
|
|
83
|
+
export interface UpdateAllOptions {
|
|
84
|
+
/** 同时清理索引中已不存在的历史安装记录。 */
|
|
85
|
+
prune?: boolean;
|
|
86
|
+
}
|
|
81
87
|
export interface UpdateAllResult {
|
|
82
88
|
skillName: string;
|
|
83
89
|
ok: boolean;
|
|
90
|
+
/** 索引中已不存在该技能(历史记录失效),非失败。 */
|
|
91
|
+
skipped?: boolean;
|
|
84
92
|
result?: DownloadResult;
|
|
85
93
|
error?: string;
|
|
86
94
|
}
|
|
@@ -90,7 +98,13 @@ export interface InstalledSkillInfo {
|
|
|
90
98
|
installed: boolean;
|
|
91
99
|
cached: boolean;
|
|
92
100
|
skillDir: string;
|
|
101
|
+
/** 解压缓存目录(ZIP 解压根目录)。 */
|
|
93
102
|
repoPath: string;
|
|
103
|
+
/** 缓存根目录下的技能目录,可能不存在。 */
|
|
104
|
+
cacheDir: string;
|
|
105
|
+
skillsDir: string;
|
|
106
|
+
agent: string;
|
|
107
|
+
agentLabel: string;
|
|
94
108
|
state: SkillStateRecord | null;
|
|
95
109
|
}
|
|
96
110
|
export interface RemoveInstalledSkillResult {
|
|
@@ -101,31 +115,3 @@ export interface RemoveInstalledSkillResult {
|
|
|
101
115
|
skillDir: string;
|
|
102
116
|
repoPath: string;
|
|
103
117
|
}
|
|
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
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { getBaseUrl, getSkillsCacheDirectory, getSkillsDirectory, setBaseUrl } from './lib/config';
|
|
2
|
+
import { getAgentLabel, getAgentName, getBaseUrl, getConfigFilePath, getConfigSummary, getSkillsCacheDirectory, getSkillsDirectory, getStateFilePath, listAgents, setAgent, setBaseUrl, setCacheDir, setConfigValue, setSkillsDir, unsetConfigValue } from './lib/config';
|
|
3
3
|
import { repositoryHasSkillFile, searchSkills } from './lib/network';
|
|
4
|
-
import { copySkillFiles, getInstalledSkillInfo, listLocalSkills } from './lib/state';
|
|
5
|
-
import {
|
|
6
|
-
import { cloneOrUpdateRepo, downloadSkill, publishSkill, uninstallSkill, updateAllSkills, updateSkill } from './lib/skill-manager';
|
|
4
|
+
import { copySkillFiles, getInstalledSkillInfo, listLocalSkills, pruneInstallState } from './lib/state';
|
|
5
|
+
import { cloneOrUpdateRepo, downloadSkill, restartAgentGateway, uninstallSkill, updateAllSkills, updateSkill } from './lib/skill-manager';
|
|
7
6
|
export declare function printHelp(): void;
|
|
8
7
|
export declare function getCliVersion(): string;
|
|
8
|
+
export declare function printConfigUsage(): void;
|
|
9
|
+
export declare function printConfigValues(key?: string): void;
|
|
10
|
+
export declare function printAgents(): void;
|
|
11
|
+
export declare function printPaths(): void;
|
|
12
|
+
export declare function handleConfigCommand(args: string[]): void;
|
|
9
13
|
export declare function cli(): Promise<void>;
|
|
10
|
-
export { searchSkills, downloadSkill, updateSkill, updateAllSkills,
|
|
14
|
+
export { searchSkills, downloadSkill, updateSkill, updateAllSkills, uninstallSkill, listLocalSkills, getInstalledSkillInfo, pruneInstallState, restartAgentGateway, getSkillsDirectory, getSkillsCacheDirectory, getConfigSummary, getConfigFilePath, getStateFilePath, listAgents, getAgentName, getAgentLabel, setConfigValue, unsetConfigValue, setBaseUrl, setAgent, setSkillsDir, setCacheDir, getBaseUrl, cloneOrUpdateRepo, copySkillFiles, repositoryHasSkillFile };
|
package/dist/main.js
CHANGED
|
@@ -4,17 +4,33 @@ 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.
|
|
7
|
+
exports.repositoryHasSkillFile = exports.copySkillFiles = exports.cloneOrUpdateRepo = exports.getBaseUrl = exports.setCacheDir = exports.setSkillsDir = exports.setAgent = exports.setBaseUrl = exports.unsetConfigValue = exports.setConfigValue = exports.getAgentLabel = exports.getAgentName = exports.listAgents = exports.getStateFilePath = exports.getConfigFilePath = exports.getConfigSummary = exports.getSkillsCacheDirectory = exports.getSkillsDirectory = exports.restartAgentGateway = exports.pruneInstallState = 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
|
+
exports.printConfigUsage = printConfigUsage;
|
|
11
|
+
exports.printConfigValues = printConfigValues;
|
|
12
|
+
exports.printAgents = printAgents;
|
|
13
|
+
exports.printPaths = printPaths;
|
|
14
|
+
exports.handleConfigCommand = handleConfigCommand;
|
|
10
15
|
exports.cli = cli;
|
|
11
16
|
const fs_1 = __importDefault(require("fs"));
|
|
12
17
|
const path_1 = __importDefault(require("path"));
|
|
13
18
|
const config_1 = require("./lib/config");
|
|
19
|
+
Object.defineProperty(exports, "getAgentLabel", { enumerable: true, get: function () { return config_1.getAgentLabel; } });
|
|
20
|
+
Object.defineProperty(exports, "getAgentName", { enumerable: true, get: function () { return config_1.getAgentName; } });
|
|
14
21
|
Object.defineProperty(exports, "getBaseUrl", { enumerable: true, get: function () { return config_1.getBaseUrl; } });
|
|
22
|
+
Object.defineProperty(exports, "getConfigFilePath", { enumerable: true, get: function () { return config_1.getConfigFilePath; } });
|
|
23
|
+
Object.defineProperty(exports, "getConfigSummary", { enumerable: true, get: function () { return config_1.getConfigSummary; } });
|
|
15
24
|
Object.defineProperty(exports, "getSkillsCacheDirectory", { enumerable: true, get: function () { return config_1.getSkillsCacheDirectory; } });
|
|
16
25
|
Object.defineProperty(exports, "getSkillsDirectory", { enumerable: true, get: function () { return config_1.getSkillsDirectory; } });
|
|
26
|
+
Object.defineProperty(exports, "getStateFilePath", { enumerable: true, get: function () { return config_1.getStateFilePath; } });
|
|
27
|
+
Object.defineProperty(exports, "listAgents", { enumerable: true, get: function () { return config_1.listAgents; } });
|
|
28
|
+
Object.defineProperty(exports, "setAgent", { enumerable: true, get: function () { return config_1.setAgent; } });
|
|
17
29
|
Object.defineProperty(exports, "setBaseUrl", { enumerable: true, get: function () { return config_1.setBaseUrl; } });
|
|
30
|
+
Object.defineProperty(exports, "setCacheDir", { enumerable: true, get: function () { return config_1.setCacheDir; } });
|
|
31
|
+
Object.defineProperty(exports, "setConfigValue", { enumerable: true, get: function () { return config_1.setConfigValue; } });
|
|
32
|
+
Object.defineProperty(exports, "setSkillsDir", { enumerable: true, get: function () { return config_1.setSkillsDir; } });
|
|
33
|
+
Object.defineProperty(exports, "unsetConfigValue", { enumerable: true, get: function () { return config_1.unsetConfigValue; } });
|
|
18
34
|
const logger_1 = __importDefault(require("./lib/logger"));
|
|
19
35
|
const network_1 = require("./lib/network");
|
|
20
36
|
Object.defineProperty(exports, "repositoryHasSkillFile", { enumerable: true, get: function () { return network_1.repositoryHasSkillFile; } });
|
|
@@ -23,13 +39,11 @@ const state_1 = require("./lib/state");
|
|
|
23
39
|
Object.defineProperty(exports, "copySkillFiles", { enumerable: true, get: function () { return state_1.copySkillFiles; } });
|
|
24
40
|
Object.defineProperty(exports, "getInstalledSkillInfo", { enumerable: true, get: function () { return state_1.getInstalledSkillInfo; } });
|
|
25
41
|
Object.defineProperty(exports, "listLocalSkills", { enumerable: true, get: function () { return state_1.listLocalSkills; } });
|
|
26
|
-
|
|
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; } });
|
|
42
|
+
Object.defineProperty(exports, "pruneInstallState", { enumerable: true, get: function () { return state_1.pruneInstallState; } });
|
|
29
43
|
const skill_manager_1 = require("./lib/skill-manager");
|
|
30
44
|
Object.defineProperty(exports, "cloneOrUpdateRepo", { enumerable: true, get: function () { return skill_manager_1.cloneOrUpdateRepo; } });
|
|
31
45
|
Object.defineProperty(exports, "downloadSkill", { enumerable: true, get: function () { return skill_manager_1.downloadSkill; } });
|
|
32
|
-
Object.defineProperty(exports, "
|
|
46
|
+
Object.defineProperty(exports, "restartAgentGateway", { enumerable: true, get: function () { return skill_manager_1.restartAgentGateway; } });
|
|
33
47
|
Object.defineProperty(exports, "uninstallSkill", { enumerable: true, get: function () { return skill_manager_1.uninstallSkill; } });
|
|
34
48
|
Object.defineProperty(exports, "updateAllSkills", { enumerable: true, get: function () { return skill_manager_1.updateAllSkills; } });
|
|
35
49
|
Object.defineProperty(exports, "updateSkill", { enumerable: true, get: function () { return skill_manager_1.updateSkill; } });
|
|
@@ -75,7 +89,7 @@ function parseCommandOptions(rawArgs) {
|
|
|
75
89
|
return { positionals, options };
|
|
76
90
|
}
|
|
77
91
|
function printHelp() {
|
|
78
|
-
console.log('GetSkill -
|
|
92
|
+
console.log('GetSkill - AI Agent 技能管理工具 (getskill.work · Cloudflare 静态托管)');
|
|
79
93
|
console.log('');
|
|
80
94
|
console.log('用法:');
|
|
81
95
|
console.log(' getskill --help - 显示帮助信息');
|
|
@@ -87,29 +101,42 @@ function printHelp() {
|
|
|
87
101
|
console.log(' getskill update <技能名称> - 检查在线版本并更新技能');
|
|
88
102
|
console.log(' getskill update <技能名称> --version <tag> - 更新到指定版本');
|
|
89
103
|
console.log(' getskill update --all - 批量更新所有已安装技能');
|
|
90
|
-
console.log(' getskill
|
|
91
|
-
console.log(' getskill publish <目录> --name <repo-name> - 指定仓库名(需配合 --repo)');
|
|
104
|
+
console.log(' getskill update --all --prune - 批量更新并清理索引中已下架技能的本地记录');
|
|
92
105
|
console.log(' getskill uninstall <技能名称> - 卸载本地技能');
|
|
93
106
|
console.log(' getskill inspect <技能名称> - 查看本地安装与缓存状态');
|
|
94
107
|
console.log(' getskill list - 列出本地技能');
|
|
95
|
-
console.log(' getskill path -
|
|
96
|
-
console.log(' getskill
|
|
97
|
-
console.log(' getskill config get
|
|
108
|
+
console.log(' getskill path - 显示 Agent 与目录/配置文件路径');
|
|
109
|
+
console.log(' getskill agents - 列出支持的 Agent 及当前生效项');
|
|
110
|
+
console.log(' getskill config get [key] - 查看配置 (base-url / agent / skills-dir / cache-dir)');
|
|
111
|
+
console.log(' getskill config set <key> <value> - 持久化保存配置项');
|
|
112
|
+
console.log(' getskill config unset <key> - 删除配置项,恢复自动识别/默认值');
|
|
98
113
|
console.log(' getskill clean - 清理下载缓存');
|
|
99
114
|
console.log('');
|
|
115
|
+
console.log('全局参数(仅对本次执行生效,不写入配置文件):');
|
|
116
|
+
console.log(` --agent <name> 指定目标 Agent: auto, ${config_1.AGENT_PRESETS.map((preset) => preset.name).join(', ')}`);
|
|
117
|
+
console.log(' --skills-dir <path> 指定任意 Agent 的技能目录');
|
|
118
|
+
console.log(' --cache-dir <path> 指定下载/解压缓存目录');
|
|
119
|
+
console.log(' --base-url <url> 指定技能索引站点地址');
|
|
120
|
+
console.log('');
|
|
121
|
+
console.log('环境变量:');
|
|
122
|
+
console.log(' GETSKILL_AGENT, GETSKILL_SKILLS_DIR, GETSKILL_CACHE_DIR');
|
|
123
|
+
console.log(' GETSKILL_BASE_URL, GETSKILL_HOME, GETSKILL_RESTART_CMD, GETSKILL_LOG_LEVEL');
|
|
124
|
+
console.log('');
|
|
100
125
|
console.log('示例:');
|
|
101
|
-
console.log(' getskill install ab-testing');
|
|
102
|
-
console.log(' getskill install ab-testing --version 2.0.7');
|
|
103
126
|
console.log(' getskill search pdf --json');
|
|
104
|
-
console.log(' getskill
|
|
127
|
+
console.log(' getskill install pdf-toolkit');
|
|
105
128
|
console.log(' getskill update --all');
|
|
106
|
-
console.log(' getskill
|
|
107
|
-
console.log(' getskill
|
|
129
|
+
console.log(' getskill inspect pdf-toolkit');
|
|
130
|
+
console.log(' getskill config set agent claude');
|
|
131
|
+
console.log(' getskill config set skills-dir ~/.my-agent/skills');
|
|
132
|
+
console.log(' getskill --agent cursor install pdf-toolkit');
|
|
108
133
|
console.log('');
|
|
109
134
|
console.log(`当前站点: ${(0, config_1.getBaseUrl)()}`);
|
|
110
135
|
console.log(`技能索引: ${(0, config_1.getBaseUrl)()}/data/skills.json`);
|
|
136
|
+
console.log(`当前 Agent: ${(0, config_1.getAgentName)()} (${(0, config_1.getAgentLabel)()})`);
|
|
111
137
|
console.log(`技能目录: ${(0, config_1.getSkillsDirectory)()}`);
|
|
112
138
|
console.log(`缓存目录: ${(0, config_1.getSkillsCacheDirectory)()}`);
|
|
139
|
+
console.log(`配置文件: ${(0, config_1.getConfigFilePath)()}`);
|
|
113
140
|
}
|
|
114
141
|
function getCliVersion() {
|
|
115
142
|
const candidatePaths = [
|
|
@@ -130,9 +157,196 @@ function getCliVersion() {
|
|
|
130
157
|
return 'unknown';
|
|
131
158
|
}
|
|
132
159
|
}
|
|
160
|
+
function asStringValue(value) {
|
|
161
|
+
return typeof value === 'string' && value.trim() !== ''
|
|
162
|
+
? value.trim()
|
|
163
|
+
: undefined;
|
|
164
|
+
}
|
|
165
|
+
const CONFIG_SOURCE_LABELS = {
|
|
166
|
+
cli: '命令行参数',
|
|
167
|
+
env: '环境变量',
|
|
168
|
+
file: '配置文件',
|
|
169
|
+
detect: '自动识别',
|
|
170
|
+
default: '默认值'
|
|
171
|
+
};
|
|
172
|
+
function getConfigRows() {
|
|
173
|
+
const config = (0, config_1.getConfigSummary)();
|
|
174
|
+
const persisted = (0, config_1.readConfigFile)();
|
|
175
|
+
return [
|
|
176
|
+
{
|
|
177
|
+
key: 'base-url',
|
|
178
|
+
value: config.baseUrl,
|
|
179
|
+
source: config.sources.baseUrl,
|
|
180
|
+
savedHint: persisted.baseUrl
|
|
181
|
+
? `已保存: ${persisted.baseUrl}`
|
|
182
|
+
: '未保存,使用默认站点'
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: 'agent',
|
|
186
|
+
value: `${config.agent} (${config.agentLabel})`,
|
|
187
|
+
source: config.sources.agent,
|
|
188
|
+
savedHint: persisted.agent
|
|
189
|
+
? `已保存: ${persisted.agent}`
|
|
190
|
+
: '未保存,自动识别本机 Agent'
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
key: 'skills-dir',
|
|
194
|
+
value: config.skillsDir,
|
|
195
|
+
source: config.sources.skillsDir,
|
|
196
|
+
savedHint: persisted.skillsDir
|
|
197
|
+
? `已保存: ${persisted.skillsDir}`
|
|
198
|
+
: '未单独保存,由 agent 推导'
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: 'cache-dir',
|
|
202
|
+
value: config.cacheDir,
|
|
203
|
+
source: config.sources.cacheDir,
|
|
204
|
+
savedHint: persisted.cacheDir
|
|
205
|
+
? `已保存: ${persisted.cacheDir}`
|
|
206
|
+
: '未保存,使用默认缓存目录'
|
|
207
|
+
}
|
|
208
|
+
];
|
|
209
|
+
}
|
|
210
|
+
function printConfigRow(row) {
|
|
211
|
+
const source = CONFIG_SOURCE_LABELS[row.source] || row.source;
|
|
212
|
+
console.log(`${row.key}: ${row.value}`);
|
|
213
|
+
console.log(` 来源: ${source},${row.savedHint}`);
|
|
214
|
+
}
|
|
215
|
+
function printConfigUsage() {
|
|
216
|
+
console.log('用法:');
|
|
217
|
+
console.log(' getskill config get [key] - 查看全部或指定配置项');
|
|
218
|
+
console.log(' getskill config set <key> <value> - 保存配置项到配置文件');
|
|
219
|
+
console.log(' getskill config unset <key> - 删除已保存的配置项');
|
|
220
|
+
console.log(' getskill config path - 显示配置文件路径');
|
|
221
|
+
console.log(' getskill config agents - 列出支持的 Agent');
|
|
222
|
+
console.log('');
|
|
223
|
+
console.log('可用配置项: base-url, agent, skills-dir, cache-dir');
|
|
224
|
+
console.log('示例:');
|
|
225
|
+
console.log(' getskill config set base-url https://custom-index.example.com');
|
|
226
|
+
console.log(' getskill config set agent claude');
|
|
227
|
+
console.log(' getskill config set skills-dir ~/.my-agent/skills');
|
|
228
|
+
console.log(' getskill config unset agent');
|
|
229
|
+
}
|
|
230
|
+
function printConfigValues(key) {
|
|
231
|
+
const rows = getConfigRows();
|
|
232
|
+
if (key) {
|
|
233
|
+
const normalizedKey = (0, config_1.normalizeConfigKey)(key);
|
|
234
|
+
const targetKey = normalizedKey
|
|
235
|
+
.replace(/([A-Z])/g, '-$1')
|
|
236
|
+
.toLowerCase();
|
|
237
|
+
const row = rows.find((item) => item.key === targetKey);
|
|
238
|
+
if (!row) {
|
|
239
|
+
throw new Error(`未知配置项: ${key}`);
|
|
240
|
+
}
|
|
241
|
+
printConfigRow(row);
|
|
242
|
+
console.log(`配置文件: ${(0, config_1.getConfigFilePath)()}`);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
rows.forEach(printConfigRow);
|
|
246
|
+
console.log(`配置文件: ${(0, config_1.getConfigFilePath)()}`);
|
|
247
|
+
console.log(`状态文件: ${(0, config_1.getStateFilePath)()}`);
|
|
248
|
+
}
|
|
249
|
+
function printAgents() {
|
|
250
|
+
const config = (0, config_1.getConfigSummary)();
|
|
251
|
+
console.log(`当前 Agent: ${config.agent} (${config.agentLabel})`);
|
|
252
|
+
console.log(`技能目录: ${config.skillsDir}`);
|
|
253
|
+
console.log(`目录来源: ${CONFIG_SOURCE_LABELS[config.sources.skillsDir] ||
|
|
254
|
+
config.sources.skillsDir}`);
|
|
255
|
+
console.log('');
|
|
256
|
+
console.log('内置 Agent 预设 (* 表示当前生效):');
|
|
257
|
+
(0, config_1.listAgents)().forEach((agent) => {
|
|
258
|
+
const mark = agent.active ? '*' : ' ';
|
|
259
|
+
const exists = agent.exists ? '目录已存在' : '目录未创建';
|
|
260
|
+
console.log(` ${mark} ${agent.name.padEnd(10)} ${agent.label.padEnd(20)} ${agent.skillsDir} (${exists})`);
|
|
261
|
+
});
|
|
262
|
+
console.log('');
|
|
263
|
+
console.log('其他 Agent / 自定义目录(任选一种方式):');
|
|
264
|
+
console.log(' getskill config set skills-dir <path>');
|
|
265
|
+
console.log(' getskill --skills-dir <path> install <技能名称>');
|
|
266
|
+
console.log(' GETSKILL_SKILLS_DIR=<path> getskill install <技能名称>');
|
|
267
|
+
}
|
|
268
|
+
function printPaths() {
|
|
269
|
+
const config = (0, config_1.getConfigSummary)();
|
|
270
|
+
console.log(`Agent: ${config.agent} (${config.agentLabel})`);
|
|
271
|
+
console.log(`技能目录: ${config.skillsDir}`);
|
|
272
|
+
console.log(`缓存目录: ${config.cacheDir}`);
|
|
273
|
+
console.log(`配置文件: ${config.configFile}`);
|
|
274
|
+
console.log(`状态文件: ${config.stateFile}`);
|
|
275
|
+
console.log(`站点地址: ${config.baseUrl}`);
|
|
276
|
+
console.log(`重载命令: ${config.restartCommand ||
|
|
277
|
+
'(未配置,可通过 GETSKILL_RESTART_CMD 指定)'}`);
|
|
278
|
+
}
|
|
279
|
+
function handleConfigCommand(args) {
|
|
280
|
+
const [action, ...rest] = args;
|
|
281
|
+
switch ((action || 'get').toLowerCase()) {
|
|
282
|
+
case 'get':
|
|
283
|
+
case 'list':
|
|
284
|
+
case 'show':
|
|
285
|
+
printConfigValues(rest[0]);
|
|
286
|
+
break;
|
|
287
|
+
case 'set': {
|
|
288
|
+
if (rest.length === 0) {
|
|
289
|
+
printConfigUsage();
|
|
290
|
+
process.exit(1);
|
|
291
|
+
}
|
|
292
|
+
if (rest.length === 1) {
|
|
293
|
+
const rawUrl = rest[0];
|
|
294
|
+
if (!/^https?:\/\//i.test(rawUrl.trim())) {
|
|
295
|
+
throw new Error(`config set <URL> 只接受 http(s) 地址(收到: ${rawUrl})。设置 Agent 请用: getskill config set agent <name>`);
|
|
296
|
+
}
|
|
297
|
+
(0, config_1.setConfigValue)('base-url', rawUrl);
|
|
298
|
+
printConfigValues('base-url');
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
const [key, ...valueParts] = rest;
|
|
302
|
+
(0, config_1.setConfigValue)(key, valueParts.join(' '));
|
|
303
|
+
printConfigValues(key);
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
case 'unset':
|
|
307
|
+
case 'delete':
|
|
308
|
+
case 'remove':
|
|
309
|
+
case 'reset': {
|
|
310
|
+
if (!rest[0]) {
|
|
311
|
+
printConfigUsage();
|
|
312
|
+
process.exit(1);
|
|
313
|
+
}
|
|
314
|
+
(0, config_1.unsetConfigValue)(rest[0]);
|
|
315
|
+
console.log(`已删除配置项: ${rest[0]}`);
|
|
316
|
+
printConfigValues(rest[0]);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
case 'path':
|
|
320
|
+
console.log((0, config_1.getConfigFilePath)());
|
|
321
|
+
break;
|
|
322
|
+
case 'agents':
|
|
323
|
+
printAgents();
|
|
324
|
+
break;
|
|
325
|
+
default:
|
|
326
|
+
printConfigUsage();
|
|
327
|
+
process.exit(1);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
133
330
|
async function cli() {
|
|
134
331
|
const args = process.argv.slice(2);
|
|
135
|
-
|
|
332
|
+
// 全局参数只影响本次执行,不会写入配置文件;
|
|
333
|
+
// 同时过滤掉参数本身,使 `getskill --agent cursor path` 这类写法生效。
|
|
334
|
+
const { positionals, options } = parseCommandOptions(args);
|
|
335
|
+
(0, config_1.applyRuntimeOverrides)({
|
|
336
|
+
agent: asStringValue(options.agent),
|
|
337
|
+
skillsDir: asStringValue(options['skills-dir']),
|
|
338
|
+
cacheDir: asStringValue(options['cache-dir']),
|
|
339
|
+
baseUrl: asStringValue(options['base-url'])
|
|
340
|
+
});
|
|
341
|
+
const restArgs = positionals.slice(1);
|
|
342
|
+
let command = positionals[0];
|
|
343
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
344
|
+
command = '--help';
|
|
345
|
+
}
|
|
346
|
+
else if (!command &&
|
|
347
|
+
(args.includes('--version') || args.includes('-v'))) {
|
|
348
|
+
command = '--version';
|
|
349
|
+
}
|
|
136
350
|
try {
|
|
137
351
|
switch (command) {
|
|
138
352
|
case '--help':
|
|
@@ -146,8 +360,7 @@ async function cli() {
|
|
|
146
360
|
console.log(getCliVersion());
|
|
147
361
|
break;
|
|
148
362
|
case 'search': {
|
|
149
|
-
const
|
|
150
|
-
const keyword = positionals[0];
|
|
363
|
+
const keyword = restArgs[0];
|
|
151
364
|
if (!keyword) {
|
|
152
365
|
console.error('请提供搜索关键词');
|
|
153
366
|
console.log('用法: getskill search <关键词>');
|
|
@@ -186,21 +399,21 @@ async function cli() {
|
|
|
186
399
|
case 'install':
|
|
187
400
|
case 'get':
|
|
188
401
|
case 'download': {
|
|
189
|
-
const
|
|
190
|
-
const skillName = positionals[0];
|
|
402
|
+
const skillName = restArgs[0];
|
|
191
403
|
const requestedVersion = typeof options.version === 'string'
|
|
192
404
|
? options.version
|
|
193
405
|
: undefined;
|
|
194
406
|
if (!skillName) {
|
|
195
407
|
console.error('请提供技能ID或名称');
|
|
196
408
|
console.log('用法: getskill install <技能名称>');
|
|
197
|
-
console.log('示例: getskill install pdf-
|
|
409
|
+
console.log('示例: getskill install pdf-toolkit');
|
|
198
410
|
process.exit(1);
|
|
199
411
|
}
|
|
200
412
|
const result = await (0, skill_manager_1.downloadSkill)(skillName, {
|
|
201
413
|
version: requestedVersion
|
|
202
414
|
});
|
|
203
|
-
console.log(
|
|
415
|
+
console.log(`\n目标 Agent: ${(0, config_1.getAgentName)()} (${(0, config_1.getAgentLabel)()})`);
|
|
416
|
+
console.log('技能已安装到 skills 目录:');
|
|
204
417
|
result.files.forEach((file) => console.log(` - ${file}`));
|
|
205
418
|
console.log(`\n本地缓存: ${result.repoPath}`);
|
|
206
419
|
if (result.version) {
|
|
@@ -209,16 +422,28 @@ async function cli() {
|
|
|
209
422
|
break;
|
|
210
423
|
}
|
|
211
424
|
case 'update': {
|
|
212
|
-
const { positionals, options } = parseCommandOptions(args.slice(1));
|
|
213
425
|
if (options.all) {
|
|
214
|
-
const results = await (0, skill_manager_1.updateAllSkills)(
|
|
426
|
+
const results = await (0, skill_manager_1.updateAllSkills)({
|
|
427
|
+
prune: options.prune === true
|
|
428
|
+
});
|
|
215
429
|
if (results.length === 0) {
|
|
216
430
|
console.log('当前没有记录到可批量更新的技能。');
|
|
431
|
+
console.log(`技能目录: ${(0, config_1.getSkillsDirectory)()}(可用 getskill path 查看,或用 --agent/--skills-dir 切换)`);
|
|
217
432
|
break;
|
|
218
433
|
}
|
|
219
434
|
const successCount = results.filter((item) => item.ok).length;
|
|
220
|
-
const
|
|
435
|
+
const skipped = results.filter((item) => item.skipped);
|
|
436
|
+
const failed = results.filter((item) => !item.ok && !item.skipped);
|
|
221
437
|
console.log(`批量更新完成:${successCount}/${results.length} 个技能成功。`);
|
|
438
|
+
if (skipped.length > 0) {
|
|
439
|
+
console.log('以下技能在索引中已不存在,已跳过(非失败):');
|
|
440
|
+
skipped.forEach((item) => {
|
|
441
|
+
console.log(` - ${item.skillName}: ${item.error}`);
|
|
442
|
+
});
|
|
443
|
+
if (options.prune !== true) {
|
|
444
|
+
console.log('提示: 执行 getskill update --all --prune 可清理这些失效的本地记录。');
|
|
445
|
+
}
|
|
446
|
+
}
|
|
222
447
|
if (failed.length > 0) {
|
|
223
448
|
console.log('以下技能更新失败:');
|
|
224
449
|
failed.forEach((item) => {
|
|
@@ -227,14 +452,14 @@ async function cli() {
|
|
|
227
452
|
}
|
|
228
453
|
break;
|
|
229
454
|
}
|
|
230
|
-
const skillName =
|
|
455
|
+
const skillName = restArgs[0];
|
|
231
456
|
const requestedVersion = typeof options.version === 'string'
|
|
232
457
|
? options.version
|
|
233
458
|
: undefined;
|
|
234
459
|
if (!skillName) {
|
|
235
460
|
console.error('请提供技能名称');
|
|
236
461
|
console.log('用法: getskill update <技能名称>');
|
|
237
|
-
console.log('示例: getskill update pdf-
|
|
462
|
+
console.log('示例: getskill update pdf-toolkit');
|
|
238
463
|
process.exit(1);
|
|
239
464
|
}
|
|
240
465
|
const result = await (0, skill_manager_1.updateSkill)(skillName, {
|
|
@@ -244,59 +469,22 @@ async function cli() {
|
|
|
244
469
|
console.log(`\n技能已是最新版本 (v${result.version || 'unknown'}),无需更新。`);
|
|
245
470
|
break;
|
|
246
471
|
}
|
|
247
|
-
console.log(
|
|
472
|
+
console.log(`\n目标 Agent: ${(0, config_1.getAgentName)()} (${(0, config_1.getAgentLabel)()})`);
|
|
473
|
+
console.log('技能已更新到 skills 目录:');
|
|
248
474
|
result.files.forEach((file) => console.log(` - ${file}`));
|
|
249
475
|
if (result.version) {
|
|
250
476
|
console.log(`当前版本: ${result.version}`);
|
|
251
477
|
}
|
|
252
478
|
break;
|
|
253
479
|
}
|
|
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
480
|
case 'uninstall': {
|
|
293
|
-
if (!
|
|
481
|
+
if (!restArgs[0]) {
|
|
294
482
|
console.error('请提供技能名称');
|
|
295
483
|
console.log('用法: getskill uninstall <技能名称> [--keep-cache]');
|
|
296
484
|
process.exit(1);
|
|
297
485
|
}
|
|
298
|
-
const result = await (0, skill_manager_1.uninstallSkill)(
|
|
299
|
-
removeCache:
|
|
486
|
+
const result = await (0, skill_manager_1.uninstallSkill)(restArgs[0], {
|
|
487
|
+
removeCache: options['keep-cache'] !== true
|
|
300
488
|
});
|
|
301
489
|
console.log('\n卸载结果:');
|
|
302
490
|
console.log(` 技能目录: ${result.removedInstall ? '已删除' : '不存在'}`);
|
|
@@ -304,18 +492,21 @@ async function cli() {
|
|
|
304
492
|
break;
|
|
305
493
|
}
|
|
306
494
|
case 'inspect': {
|
|
307
|
-
if (!
|
|
495
|
+
if (!restArgs[0]) {
|
|
308
496
|
console.error('请提供技能名称');
|
|
309
497
|
console.log('用法: getskill inspect <技能名称>');
|
|
310
498
|
process.exit(1);
|
|
311
499
|
}
|
|
312
|
-
const info = (0, state_1.getInstalledSkillInfo)(
|
|
500
|
+
const info = (0, state_1.getInstalledSkillInfo)(restArgs[0]);
|
|
313
501
|
console.log(`技能名称: ${info.skillName}`);
|
|
314
502
|
console.log(`本地目录: ${info.localSkillName}`);
|
|
503
|
+
console.log(`目标 Agent: ${info.agent} (${info.agentLabel})`);
|
|
315
504
|
console.log(`已安装: ${info.installed ? '是' : '否'}`);
|
|
316
505
|
console.log(`已缓存: ${info.cached ? '是' : '否'}`);
|
|
317
506
|
console.log(`技能路径: ${info.skillDir}`);
|
|
318
|
-
console.log(
|
|
507
|
+
console.log(`技能目录: ${info.skillsDir}`);
|
|
508
|
+
console.log(`缓存目录: ${info.cacheDir}`);
|
|
509
|
+
console.log(`解压路径: ${info.repoPath}`);
|
|
319
510
|
if (info.state) {
|
|
320
511
|
console.log(`最后动作: ${info.state.lastAction || 'unknown'}`);
|
|
321
512
|
console.log(`安装时间: ${info.state.installedAt || 'unknown'}`);
|
|
@@ -329,37 +520,37 @@ async function cli() {
|
|
|
329
520
|
}
|
|
330
521
|
case 'list': {
|
|
331
522
|
const skills = (0, state_1.listLocalSkills)();
|
|
332
|
-
console.log(`本地已安装的技能 (${skills.length})
|
|
523
|
+
console.log(`本地已安装的技能 (${skills.length}) · Agent: ${(0, config_1.getAgentName)()} · 目录: ${(0, config_1.getSkillsDirectory)()}`);
|
|
333
524
|
skills.forEach((skill, index) => {
|
|
334
525
|
console.log(`${index + 1}. ${skill}`);
|
|
335
526
|
});
|
|
336
527
|
break;
|
|
337
528
|
}
|
|
529
|
+
case 'agents':
|
|
530
|
+
printAgents();
|
|
531
|
+
break;
|
|
338
532
|
case 'path':
|
|
339
|
-
|
|
340
|
-
console.log(`缓存目录: ${(0, config_1.getSkillsCacheDirectory)()}`);
|
|
533
|
+
printPaths();
|
|
341
534
|
break;
|
|
342
535
|
case 'config':
|
|
343
|
-
|
|
344
|
-
const newBaseUrl = (0, config_1.setBaseUrl)(args[2]);
|
|
345
|
-
console.log(`BASE_URL 已设置为: ${newBaseUrl}`);
|
|
346
|
-
}
|
|
347
|
-
else if (args[1] === 'get') {
|
|
348
|
-
console.log(`当前 BASE_URL: ${(0, config_1.getBaseUrl)()}`);
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
console.log('用法:');
|
|
352
|
-
console.log(' getskill config set <URL> - 设置自定义 API 地址');
|
|
353
|
-
console.log(' getskill config get - 查看当前 API 地址');
|
|
354
|
-
}
|
|
536
|
+
handleConfigCommand(restArgs);
|
|
355
537
|
break;
|
|
356
538
|
case 'clean': {
|
|
357
539
|
const cacheDir = (0, config_1.getSkillsCacheDirectory)();
|
|
540
|
+
let cleaned = false;
|
|
358
541
|
if (fs_1.default.existsSync(cacheDir)) {
|
|
359
542
|
fs_1.default.rmSync(cacheDir, { recursive: true, force: true });
|
|
360
543
|
console.log(`已清理缓存目录: ${cacheDir}`);
|
|
544
|
+
cleaned = true;
|
|
361
545
|
}
|
|
362
|
-
|
|
546
|
+
(0, config_1.getLegacyCacheDirectories)().forEach((legacyDir) => {
|
|
547
|
+
if (fs_1.default.existsSync(legacyDir)) {
|
|
548
|
+
fs_1.default.rmSync(legacyDir, { recursive: true, force: true });
|
|
549
|
+
console.log(`已清理历史缓存目录: ${legacyDir}`);
|
|
550
|
+
cleaned = true;
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
if (!cleaned) {
|
|
363
554
|
console.log('缓存目录不存在');
|
|
364
555
|
}
|
|
365
556
|
break;
|