eskill 1.0.28 → 1.0.30
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/cli.js +1 -1
- package/lib/installer.js +42 -18
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ const program = new Command();
|
|
|
13
13
|
program
|
|
14
14
|
.name('eskill')
|
|
15
15
|
.description('Unified AI Agent Skills Management - Install skills from Git URLs')
|
|
16
|
-
.version('1.0.
|
|
16
|
+
.version('1.0.30')
|
|
17
17
|
.option('-g, --global', '使用全局技能目录(~/.eskill/skills/),否则使用当前目录(./.claude/skills/)', false);
|
|
18
18
|
|
|
19
19
|
// 安装命令
|
package/lib/installer.js
CHANGED
|
@@ -58,10 +58,10 @@ function getEskillPackageDir() {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
* @param {boolean} global -
|
|
61
|
+
* 获取技能目录
|
|
62
|
+
* @param {boolean} global - 是否使用全局目录
|
|
63
63
|
*/
|
|
64
|
-
function
|
|
64
|
+
function getSkillsDir(global = false) {
|
|
65
65
|
if (global) {
|
|
66
66
|
// 全局模式:使用 ~/.eskill/skills/
|
|
67
67
|
return join(homedir(), '.eskill', 'skills');
|
|
@@ -71,6 +71,20 @@ function getSkillsStorageDir(global = false) {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* 获取技能存储目录(用于元数据)
|
|
76
|
+
* @param {boolean} global - 是否使用全局目录
|
|
77
|
+
*/
|
|
78
|
+
function getSkillsStorageDir(global = false) {
|
|
79
|
+
if (global) {
|
|
80
|
+
// 全局模式:使用 ~/.eskill/skills/
|
|
81
|
+
return join(homedir(), '.eskill', 'skills');
|
|
82
|
+
} else {
|
|
83
|
+
// 本地模式:使用当前目录(项目根目录)
|
|
84
|
+
return process.cwd();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
74
88
|
/**
|
|
75
89
|
* 迁移旧位置的技能到新位置
|
|
76
90
|
* @param {boolean} global - 是否全局模式
|
|
@@ -305,6 +319,16 @@ function confirmAction(message) {
|
|
|
305
319
|
export async function installFromGitUrl(gitUrl, options = {}) {
|
|
306
320
|
const { agent = 'claude', link = false, force = false, global = false } = options;
|
|
307
321
|
|
|
322
|
+
// 本地模式:询问是否在当前目录安装
|
|
323
|
+
if (!global) {
|
|
324
|
+
const currentDir = process.cwd();
|
|
325
|
+
const confirmed = await confirmAction(`是否在【${currentDir}】下安装此技能?`);
|
|
326
|
+
if (!confirmed) {
|
|
327
|
+
console.log('\n已取消安装\n');
|
|
328
|
+
return { success: false, cancelled: true };
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
308
332
|
// 检测并处理 name@author 格式
|
|
309
333
|
let actualUrl = await handleSkillAtAuthorFormat(gitUrl);
|
|
310
334
|
|
|
@@ -326,17 +350,17 @@ export async function installFromGitUrl(gitUrl, options = {}) {
|
|
|
326
350
|
console.log(`路径: ${parsed.path}`);
|
|
327
351
|
}
|
|
328
352
|
|
|
329
|
-
//
|
|
330
|
-
const
|
|
353
|
+
// 获取技能目录(技能文件存放位置)
|
|
354
|
+
const skillsDir = getSkillsDir(global);
|
|
331
355
|
|
|
332
356
|
// 确保技能目录存在
|
|
333
|
-
if (!existsSync(
|
|
334
|
-
mkdirSync(
|
|
357
|
+
if (!existsSync(skillsDir)) {
|
|
358
|
+
mkdirSync(skillsDir, { recursive: true });
|
|
335
359
|
}
|
|
336
360
|
|
|
337
361
|
// 确定技能名称
|
|
338
362
|
const skillName = parsed.path ? basename(parsed.path) : parsed.repo;
|
|
339
|
-
const targetPath = join(
|
|
363
|
+
const targetPath = join(skillsDir, skillName);
|
|
340
364
|
|
|
341
365
|
// 检查是否已存在
|
|
342
366
|
if (existsSync(targetPath)) {
|
|
@@ -389,8 +413,9 @@ export async function installFromGitUrl(gitUrl, options = {}) {
|
|
|
389
413
|
}
|
|
390
414
|
|
|
391
415
|
console.log(`\n✓ 技能已安装到: ${targetPath}`);
|
|
392
|
-
|
|
393
|
-
console.log(`
|
|
416
|
+
const metaLocation = global ? '~/.eskill/skills/.eskill-meta.json' : './.eskill-meta.json';
|
|
417
|
+
console.log(` 元数据位置: ${metaLocation}`);
|
|
418
|
+
console.log(` 说明: 技能永久保存,可提交到 Git`);
|
|
394
419
|
|
|
395
420
|
// 获取 git 版本信息
|
|
396
421
|
const commitHash = getGitCommitHash(sourcePath);
|
|
@@ -427,7 +452,7 @@ export function listSkills(agent = 'claude', global = false) {
|
|
|
427
452
|
// 自动迁移旧位置的技能
|
|
428
453
|
migrateOldSkills(global);
|
|
429
454
|
|
|
430
|
-
const skillDir =
|
|
455
|
+
const skillDir = getSkillsDir(global);
|
|
431
456
|
|
|
432
457
|
if (!existsSync(skillDir)) {
|
|
433
458
|
return [];
|
|
@@ -459,7 +484,7 @@ export function listSkills(agent = 'claude', global = false) {
|
|
|
459
484
|
* 删除技能
|
|
460
485
|
*/
|
|
461
486
|
export function removeSkill(skillName, agent = 'claude', global = false) {
|
|
462
|
-
const skillDir =
|
|
487
|
+
const skillDir = getSkillsDir(global);
|
|
463
488
|
const targetPath = join(skillDir, skillName);
|
|
464
489
|
|
|
465
490
|
if (!existsSync(targetPath)) {
|
|
@@ -475,7 +500,7 @@ export function removeSkill(skillName, agent = 'claude', global = false) {
|
|
|
475
500
|
* 清理所有技能(用于卸载)
|
|
476
501
|
*/
|
|
477
502
|
export function cleanupAllSkills(global = false) {
|
|
478
|
-
const skillDir =
|
|
503
|
+
const skillDir = getSkillsDir(global);
|
|
479
504
|
|
|
480
505
|
if (!existsSync(skillDir)) {
|
|
481
506
|
console.log('没有需要清理的技能');
|
|
@@ -513,10 +538,9 @@ export function cleanupAll() {
|
|
|
513
538
|
|
|
514
539
|
/**
|
|
515
540
|
* 获取技能存储目录路径
|
|
541
|
+
* 导出内部的 getSkillsDir 函数
|
|
516
542
|
*/
|
|
517
|
-
export
|
|
518
|
-
return getSkillsStorageDir(global);
|
|
519
|
-
}
|
|
543
|
+
export { getSkillsDir };
|
|
520
544
|
|
|
521
545
|
/**
|
|
522
546
|
* 获取远程仓库的 commit hash(不克隆)
|
|
@@ -540,7 +564,7 @@ function getRemoteCommitHash(gitUrl, branch) {
|
|
|
540
564
|
*/
|
|
541
565
|
export async function updateSkill(skillName, options = {}) {
|
|
542
566
|
const { force = false, global = false } = options;
|
|
543
|
-
const skillDir =
|
|
567
|
+
const skillDir = getSkillsDir(global);
|
|
544
568
|
const targetPath = join(skillDir, skillName);
|
|
545
569
|
|
|
546
570
|
// 检查技能是否存在
|
|
@@ -648,7 +672,7 @@ export async function updateAllSkills(options = {}) {
|
|
|
648
672
|
// 自动迁移旧位置的技能
|
|
649
673
|
migrateOldSkills(global);
|
|
650
674
|
|
|
651
|
-
const skillDir =
|
|
675
|
+
const skillDir = getSkillsDir(global);
|
|
652
676
|
|
|
653
677
|
if (!existsSync(skillDir)) {
|
|
654
678
|
console.log('未安装任何技能');
|