@botskill/cli 1.0.6 → 1.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botskill/cli",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "CLI tool for BotSkill - AI agent skills platform",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -29,8 +29,12 @@ packCommand
29
29
  }
30
30
 
31
31
  if (options.dryRun) {
32
+ const { getConfigFromDir } = await import('../lib/packSkill.js');
33
+ const { name, version } = await getConfigFromDir(dirPath).catch(() => ({ name: 'skill', version: '1.0.0' }));
34
+ const toSafe = (s) => String(s || 'skill').toLowerCase().replace(/[^a-z0-9.-]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '') || 'skill';
35
+ const defaultOutput = path.join(dirPath, `${toSafe(name)}-${String(version || '1.0.0').replace(/[^a-zA-Z0-9.-]/g, '-')}.zip`);
32
36
  console.log('[DRY RUN] Would pack:', dirPath);
33
- console.log('[DRY RUN] Output:', options.output || path.join(dirPath, 'skill.zip'));
37
+ console.log('[DRY RUN] Output:', options.output || defaultOutput);
34
38
  return;
35
39
  }
36
40
 
@@ -24,7 +24,7 @@ function createExcludeFilter(exclude = DEFAULT_EXCLUDE) {
24
24
  /**
25
25
  * Get name and version from skill.config.json in directory
26
26
  */
27
- async function getConfigFromDir(dirPath) {
27
+ export async function getConfigFromDir(dirPath) {
28
28
  const configPath = path.join(dirPath, 'skill.config.json');
29
29
  const defaultValue = { name: 'skill', version: '1.0.0' };
30
30
  if (!(await fs.pathExists(configPath))) return defaultValue;
@@ -72,18 +72,20 @@ export async function packDirectory(dirPath, opts = {}) {
72
72
  throw new Error('NO_SKILL_MD');
73
73
  }
74
74
 
75
+ const { name, version } = await getConfigFromDir(resolved);
76
+ const safeName = toSafeId(opts.name ?? name);
77
+ const safeVersion = String(opts.version ?? version).replace(/[^a-zA-Z0-9.-]/g, '-');
78
+ const defaultFilename = `${safeName}-${safeVersion}.zip`;
79
+
75
80
  let outputPath;
76
81
  if (opts.output) {
77
82
  outputPath = path.resolve(opts.output);
78
83
  } else if (opts.useTempDir) {
79
- const { name, version } = await getConfigFromDir(resolved);
80
- const safeName = toSafeId(opts.name ?? name);
81
- const safeVersion = String(opts.version ?? version).replace(/[^a-zA-Z0-9.-]/g, '-');
82
84
  const tmpDir = path.join(os.tmpdir(), `skm-pack-${Date.now()}-${Math.random().toString(36).slice(2)}`);
83
85
  await fs.ensureDir(tmpDir);
84
- outputPath = path.join(tmpDir, `${safeName}-${safeVersion}.zip`);
86
+ outputPath = path.join(tmpDir, defaultFilename);
85
87
  } else {
86
- outputPath = path.join(resolved, 'skill.zip');
88
+ outputPath = path.join(resolved, defaultFilename);
87
89
  }
88
90
  const excludeFilter = createExcludeFilter(opts.exclude);
89
91
 
@@ -6,7 +6,7 @@ const validCategories = ['ai', 'data', 'web', 'devops', 'security', 'tools'];
6
6
 
7
7
  /**
8
8
  * Find uploadable file in cwd
9
- * Priority: SKILL.md, skill.zip, skill.tar.gz, dist.zip
9
+ * Priority: SKILL.md, skill.zip, skill.tar.gz, dist.zip, {name}-{version}.zip
10
10
  */
11
11
  export async function findUploadFile(cwd = process.cwd()) {
12
12
  const candidates = [
@@ -21,6 +21,16 @@ export async function findUploadFile(cwd = process.cwd()) {
21
21
  if (stat.isFile()) return p;
22
22
  }
23
23
  }
24
+ // 查找 {name}-{version}.zip 格式的打包文件
25
+ try {
26
+ const files = await fs.readdir(cwd);
27
+ const zipMatch = files.find((f) => /-\d+\.\d+\.\d+\.zip$/i.test(f));
28
+ if (zipMatch) {
29
+ const p = path.join(cwd, zipMatch);
30
+ const stat = await fs.stat(p);
31
+ if (stat.isFile()) return p;
32
+ }
33
+ } catch (_) {}
24
34
  return null;
25
35
  }
26
36