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