eskill 1.0.7 → 1.0.10

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.
Files changed (3) hide show
  1. package/cli.js +1 -1
  2. package/lib/installer.js +19 -14
  3. 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.0');
16
+ .version('1.0.10');
17
17
 
18
18
  // 安装命令
19
19
  program
package/lib/installer.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { execSync } from 'child_process';
2
2
  import { existsSync, mkdirSync, symlinkSync, rmSync, readdirSync } from 'fs';
3
- import { join, basename, dirname } from 'path';
3
+ import { join, basename, dirname, tmpdir } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { parseGitUrl } from './git-url-parser.js';
6
6
  import { AGENTS, expandHomePath } from './agent-config.js';
@@ -59,15 +59,15 @@ export async function installFromGitUrl(gitUrl, options = {}) {
59
59
  rmSync(targetPath, { recursive: true, force: true });
60
60
  }
61
61
 
62
- // 创建临时目录
63
- const tempDir = `/tmp/eskill-${Date.now()}`;
62
+ // 创建临时目录(使用系统临时目录,跨平台兼容)
63
+ const tempDir = join(tmpdir(), `eskill-${Date.now()}`);
64
64
 
65
65
  try {
66
66
  // 克隆仓库
67
67
  console.log(`\n克隆仓库...`);
68
68
  const cloneUrl = parsed.cloneUrl;
69
69
  execSync(
70
- `git clone --depth 1 --branch ${parsed.branch} --single-branch ${cloneUrl} ${tempDir}`,
70
+ `git clone --depth 1 --branch ${parsed.branch} --single-branch "${cloneUrl}" "${tempDir}"`,
71
71
  { stdio: 'inherit' }
72
72
  );
73
73
 
@@ -79,15 +79,25 @@ export async function installFromGitUrl(gitUrl, options = {}) {
79
79
  throw new Error(`路径不存在: ${sourcePath}`);
80
80
  }
81
81
 
82
+ // 检查 SKILL.md 是否存在
83
+ const skillManifestPath = join(sourcePath, 'SKILL.md');
84
+ if (!existsSync(skillManifestPath)) {
85
+ throw new Error(`无效的技能包:未找到 SKILL.md 文件\n请确保该仓库是一个有效的 AI Agent 技能包`);
86
+ }
87
+
82
88
  // 安装技能
83
89
  if (link) {
84
90
  // 使用符号链接
85
91
  console.log(`\n创建符号链接: ${sourcePath} -> ${targetPath}`);
86
92
  symlinkSync(sourcePath, targetPath, 'dir');
87
93
  } else {
88
- // 复制文件
94
+ // 复制文件(Windows 使用 xcopy,Linux/Mac 使用 cp -r)
89
95
  console.log(`\n复制文件到: ${targetPath}`);
90
- execSync(`cp -r "${sourcePath}" "${targetPath}"`, { stdio: 'inherit' });
96
+ if (process.platform === 'win32') {
97
+ execSync(`xcopy "${sourcePath}" "${targetPath}" /E /I /H /Y`, { stdio: 'inherit' });
98
+ } else {
99
+ execSync(`cp -r "${sourcePath}" "${targetPath}"`, { stdio: 'inherit' });
100
+ }
91
101
  }
92
102
 
93
103
  console.log(`\n✓ 技能已安装到: ${targetPath}`);
@@ -95,15 +105,10 @@ export async function installFromGitUrl(gitUrl, options = {}) {
95
105
  console.log(` 说明: 卸载 eskill 时会自动删除所有技能`);
96
106
 
97
107
  return { success: true, path: targetPath };
98
- } catch (error) {
99
- // 清理临时目录
100
- if (existsSync(tempDir)) {
101
- rmSync(tempDir, { recursive: true, force: true });
102
- }
103
- throw error;
104
108
  } finally {
105
- // 清理临时目录(如果是符号链接则保留源)
106
- if (!link && existsSync(tempDir)) {
109
+ // 无论成功或失败,都清理临时目录
110
+ if (existsSync(tempDir)) {
111
+ console.log(`清理临时目录: ${tempDir}`);
107
112
  rmSync(tempDir, { recursive: true, force: true });
108
113
  }
109
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eskill",
3
- "version": "1.0.7",
3
+ "version": "1.0.10",
4
4
  "description": "Unified AI Agent Skills Management - Install skills from Git URLs",
5
5
  "main": "index.js",
6
6
  "type": "module",