@botskill/cli 1.0.3 → 1.0.4

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/README.md CHANGED
@@ -1,160 +1,160 @@
1
- # BotSkill CLI (skm)
2
-
3
- The official command-line interface for BotSkill, a platform for managing and sharing AI agent skills.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install -g @botskill/cli
9
- ```
10
-
11
- Or use without installing:
12
-
13
- ```bash
14
- npx @botskill/cli [command]
15
- ```
16
-
17
- ## Commands
18
-
19
- ### init
20
- Initialize a new skill project (creates skill.config.json):
21
- ```bash
22
- skm init --name my-skill --description "A new AI skill"
23
- skm init -y # Use defaults without prompting
24
- ```
25
-
26
- ### login
27
- Login to BotSkill platform:
28
- ```bash
29
- skm login --token YOUR_TOKEN
30
- ```
31
-
32
- ### config
33
- Manage CLI configuration:
34
- ```bash
35
- # List all configurations
36
- skm config --list
37
-
38
- # Get specific configuration
39
- skm config --get apiUrl
40
-
41
- # Set configuration
42
- skm config --set apiUrl=https://api.botskill.ai
43
- ```
44
-
45
- ### get
46
- Download a skill from BotSkill and extract to directory (default: current directory). Use `name@version` for a specific version, or `name` for latest. API URL from config (optional):
47
- ```bash
48
- skm get pdf-processing
49
- skm get pdf-processing@1.0.0
50
- skm get pdf-processing -o ./my-skills
51
- skm get pdf-processing --dry-run
52
- ```
53
-
54
- ### push / publish
55
- Upload/push or publish a skill to BotSkill (requires login, publisher or admin role):
56
- ```bash
57
- # From a directory with skill.config.json
58
- skm push
59
-
60
- # Or use publish (alias)
61
- skm publish
62
-
63
- # With options
64
- skm push --name my-skill --description "My AI skill" --category ai
65
- skm push --dry-run # Validate without uploading
66
- ```
67
-
68
- ### list
69
- List skills from BotSkill (fetches from API):
70
- ```bash
71
- skm list
72
- skm list --category ai --limit 10
73
- skm list --search translator
74
- skm list --mine # Your skills (requires login)
75
- ```
76
-
77
- ### search
78
- Search skills by name or description:
79
- ```bash
80
- skm search pdf
81
- skm search translator --category ai
82
- skm search "data analysis" --limit 10
83
- ```
84
-
85
- ### info
86
- Show skill details (without downloading):
87
- ```bash
88
- skm info pdf-processing
89
- skm info pdf-processing@1.0.0
90
- ```
91
-
92
- ## Configuration
93
-
94
- 安装后会在用户主目录下自动创建 `~/.skm/` 目录及默认配置:
95
- - **macOS / Linux**: `~/.skm/config.json`
96
- - **Windows**: `%USERPROFILE%\.skm\config.json`
97
-
98
- 使用 `skm config` 管理配置,`skm config --path` 查看配置文件路径。
99
-
100
- ### 默认配置
101
- - `apiUrl`: API 地址,优先级:环境变量 `BOTSKILL_API_URL` > 配置文件 > 构建时默认值
102
- - `token` / `refreshToken`: 登录后自动保存
103
-
104
- ### 环境变量
105
- - **BOTSKILL_API_URL**:运行时覆盖 API 地址(不修改配置文件)
106
-
107
- ### 发布时指定默认 API 和作者
108
- ```bash
109
- # 开发/本地默认 localhost
110
- npm run build
111
-
112
- # 生产环境
113
- BOTSKILL_API_URL=https://api.botskill.ai npm run build
114
- BOTSKILL_API_URL=https://api.botskill.ai npm publish
115
- ```
116
-
117
- ## Usage Examples
118
-
119
- ### Creating a new skill
120
- ```bash
121
- # Initialize a new skill project
122
- skm init --name my-translator --description "AI translation skill"
123
-
124
- # Edit skill.config.json (add tags, URLs, etc.)
125
- # Login to BotSkill
126
- skm login
127
-
128
- # Push or publish to BotSkill
129
- skm push
130
- # or
131
- skm publish
132
- ```
133
-
134
- ### Using an existing skill
135
- ```bash
136
- # Search for skills
137
- skm list --search translator --category ai
138
-
139
- # Download a skill (latest version)
140
- skm get pdf-processing
141
- skm get pdf-processing@1.0.0 -o ./skills
142
- ```
143
-
144
- ## Development
145
-
146
- To run the CLI locally during development:
147
-
148
- ```bash
149
- cd skm-cli
150
- npm install
151
- node src/index.js [command]
152
- ```
153
-
154
- ## Contributing
155
-
156
- See our contributing guide for more information on how to contribute to the BotSkill CLI.
157
-
158
- ## License
159
-
1
+ # BotSkill CLI (skm)
2
+
3
+ The official command-line interface for BotSkill, a platform for managing and sharing AI agent skills.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @botskill/cli
9
+ ```
10
+
11
+ Or use without installing:
12
+
13
+ ```bash
14
+ npx @botskill/cli [command]
15
+ ```
16
+
17
+ ## Commands
18
+
19
+ ### init
20
+ Initialize a new skill project (creates skill.config.json):
21
+ ```bash
22
+ skm init --name my-skill --description "A new AI skill"
23
+ skm init -y # Use defaults without prompting
24
+ ```
25
+
26
+ ### login
27
+ Login to BotSkill platform:
28
+ ```bash
29
+ skm login --token YOUR_TOKEN
30
+ ```
31
+
32
+ ### config
33
+ Manage CLI configuration:
34
+ ```bash
35
+ # List all configurations
36
+ skm config --list
37
+
38
+ # Get specific configuration
39
+ skm config --get apiUrl
40
+
41
+ # Set configuration
42
+ skm config --set apiUrl=https://api.botskill.ai
43
+ ```
44
+
45
+ ### get
46
+ Download a skill from BotSkill and extract to directory (default: current directory). Use `name@version` for a specific version, or `name` for latest. API URL from config (optional):
47
+ ```bash
48
+ skm get pdf-processing
49
+ skm get pdf-processing@1.0.0
50
+ skm get pdf-processing -o ./my-skills
51
+ skm get pdf-processing --dry-run
52
+ ```
53
+
54
+ ### push / publish
55
+ Upload/push or publish a skill to BotSkill (requires login, publisher or admin role):
56
+ ```bash
57
+ # From a directory with skill.config.json
58
+ skm push
59
+
60
+ # Or use publish (alias)
61
+ skm publish
62
+
63
+ # With options
64
+ skm push --name my-skill --description "My AI skill" --category ai
65
+ skm push --dry-run # Validate without uploading
66
+ ```
67
+
68
+ ### list
69
+ List skills from BotSkill (fetches from API):
70
+ ```bash
71
+ skm list
72
+ skm list --category ai --limit 10
73
+ skm list --search translator
74
+ skm list --mine # Your skills (requires login)
75
+ ```
76
+
77
+ ### search
78
+ Search skills by name or description:
79
+ ```bash
80
+ skm search pdf
81
+ skm search translator --category ai
82
+ skm search "data analysis" --limit 10
83
+ ```
84
+
85
+ ### info
86
+ Show skill details (without downloading):
87
+ ```bash
88
+ skm info pdf-processing
89
+ skm info pdf-processing@1.0.0
90
+ ```
91
+
92
+ ## Configuration
93
+
94
+ 安装后会在用户主目录下自动创建 `~/.skm/` 目录及默认配置:
95
+ - **macOS / Linux**: `~/.skm/config.json`
96
+ - **Windows**: `%USERPROFILE%\.skm\config.json`
97
+
98
+ 使用 `skm config` 管理配置,`skm config --path` 查看配置文件路径。
99
+
100
+ ### 默认配置
101
+ - `apiUrl`: API 地址,优先级:环境变量 `BOTSKILL_API_URL` > 配置文件 > 构建时默认值
102
+ - `token` / `refreshToken`: 登录后自动保存
103
+
104
+ ### 环境变量
105
+ - **BOTSKILL_API_URL**:运行时覆盖 API 地址(不修改配置文件)
106
+
107
+ ### 发布时指定默认 API 和作者
108
+ ```bash
109
+ # 开发/本地默认 localhost
110
+ npm run build
111
+
112
+ # 生产环境
113
+ BOTSKILL_API_URL=https://api.botskill.ai npm run build
114
+ BOTSKILL_API_URL=https://api.botskill.ai npm publish
115
+ ```
116
+
117
+ ## Usage Examples
118
+
119
+ ### Creating a new skill
120
+ ```bash
121
+ # Initialize a new skill project
122
+ skm init --name my-translator --description "AI translation skill"
123
+
124
+ # Edit skill.config.json (add tags, URLs, etc.)
125
+ # Login to BotSkill
126
+ skm login
127
+
128
+ # Push or publish to BotSkill
129
+ skm push
130
+ # or
131
+ skm publish
132
+ ```
133
+
134
+ ### Using an existing skill
135
+ ```bash
136
+ # Search for skills
137
+ skm list --search translator --category ai
138
+
139
+ # Download a skill (latest version)
140
+ skm get pdf-processing
141
+ skm get pdf-processing@1.0.0 -o ./skills
142
+ ```
143
+
144
+ ## Development
145
+
146
+ To run the CLI locally during development:
147
+
148
+ ```bash
149
+ cd skm-cli
150
+ npm install
151
+ node src/index.js [command]
152
+ ```
153
+
154
+ ## Contributing
155
+
156
+ See our contributing guide for more information on how to contribute to the BotSkill CLI.
157
+
158
+ ## License
159
+
160
160
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botskill/cli",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "CLI tool for BotSkill - AI agent skills platform",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/scripts/build.js CHANGED
@@ -1,35 +1,35 @@
1
- #!/usr/bin/env node
2
- /**
3
- * 构建脚本:根据环境变量注入默认配置
4
- * 用法:
5
- * npm run build # 使用 localhost(开发)
6
- * BOTSKILL_API_URL=https://api.botskill.ai npm run build # 生产 API
7
- * npm run build:restore # 发布后恢复占位符,便于继续开发
8
- */
9
- import fs from 'fs';
10
- import path from 'path';
11
- import { fileURLToPath } from 'url';
12
-
13
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
- const constantsPath = path.join(__dirname, '../src/lib/constants.js');
15
-
16
- const isRestore = process.argv.includes('--restore');
17
-
18
- if (isRestore) {
19
- let content = fs.readFileSync(constantsPath, 'utf8');
20
- content = content.replace(
21
- /export const DEFAULT_API_URL = .+;/,
22
- "export const DEFAULT_API_URL = '__DEFAULT_API_URL__';"
23
- );
24
- fs.writeFileSync(constantsPath, content);
25
- console.log('Build: restored placeholder');
26
- } else {
27
- const apiUrl = process.env.BOTSKILL_API_URL || 'http://localhost:3001/api';
28
- let content = fs.readFileSync(constantsPath, 'utf8');
29
- content = content.replace(
30
- /export const DEFAULT_API_URL = .+;/,
31
- `export const DEFAULT_API_URL = ${JSON.stringify(apiUrl)};`
32
- );
33
- fs.writeFileSync(constantsPath, content);
34
- console.log(`Build: DEFAULT_API_URL = ${apiUrl}`);
35
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 构建脚本:根据环境变量注入默认配置
4
+ * 用法:
5
+ * npm run build # 使用 localhost(开发)
6
+ * BOTSKILL_API_URL=https://api.botskill.ai npm run build # 生产 API
7
+ * npm run build:restore # 发布后恢复占位符,便于继续开发
8
+ */
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
+ const constantsPath = path.join(__dirname, '../src/lib/constants.js');
15
+
16
+ const isRestore = process.argv.includes('--restore');
17
+
18
+ if (isRestore) {
19
+ let content = fs.readFileSync(constantsPath, 'utf8');
20
+ content = content.replace(
21
+ /export const DEFAULT_API_URL = .+;/,
22
+ "export const DEFAULT_API_URL = '__DEFAULT_API_URL__';"
23
+ );
24
+ fs.writeFileSync(constantsPath, content);
25
+ console.log('Build: restored placeholder');
26
+ } else {
27
+ const apiUrl = process.env.BOTSKILL_API_URL || 'http://localhost:3001/api';
28
+ let content = fs.readFileSync(constantsPath, 'utf8');
29
+ content = content.replace(
30
+ /export const DEFAULT_API_URL = .+;/,
31
+ `export const DEFAULT_API_URL = ${JSON.stringify(apiUrl)};`
32
+ );
33
+ fs.writeFileSync(constantsPath, content);
34
+ console.log(`Build: DEFAULT_API_URL = ${apiUrl}`);
35
+ }
@@ -1,25 +1,25 @@
1
- #!/usr/bin/env node
2
- /**
3
- * postinstall: 在用户目录下创建默认配置文件
4
- * 路径: ~/.skm/config.json
5
- * 默认 API 来自构建时 BOTSKILL_API_URL,未构建时用 localhost
6
- */
7
- import path from 'path';
8
- import os from 'os';
9
- import fs from 'fs';
10
- import Configstore from 'configstore';
11
- import { getDefaultApiUrl } from '../src/lib/constants.js';
12
-
13
- const CONFIG_PATH = path.join(os.homedir(), '.skm', 'config.json');
14
- const defaultUrl = getDefaultApiUrl();
15
-
16
- try {
17
- const config = new Configstore('botskill-cli', { apiUrl: defaultUrl }, {
18
- configPath: CONFIG_PATH,
19
- });
20
- if (!fs.existsSync(config.path)) {
21
- config.set('apiUrl', defaultUrl);
22
- }
23
- } catch {
24
- // 静默失败,首次运行 skm 时 Configstore 会创建
25
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * postinstall: 在用户目录下创建默认配置文件
4
+ * 路径: ~/.skm/config.json
5
+ * 默认 API 来自构建时 BOTSKILL_API_URL,未构建时用 localhost
6
+ */
7
+ import path from 'path';
8
+ import os from 'os';
9
+ import fs from 'fs';
10
+ import Configstore from 'configstore';
11
+ import { getDefaultApiUrl } from '../src/lib/constants.js';
12
+
13
+ const CONFIG_PATH = path.join(os.homedir(), '.skm', 'config.json');
14
+ const defaultUrl = getDefaultApiUrl();
15
+
16
+ try {
17
+ const config = new Configstore('botskill-cli', { apiUrl: defaultUrl }, {
18
+ configPath: CONFIG_PATH,
19
+ });
20
+ if (!fs.existsSync(config.path)) {
21
+ config.set('apiUrl', defaultUrl);
22
+ }
23
+ } catch {
24
+ // 静默失败,首次运行 skm 时 Configstore 会创建
25
+ }
@@ -1,81 +1,81 @@
1
- #!/usr/bin/env node
2
- /**
3
- * 发布脚本:自动增加版本号并发布
4
- * 用法:
5
- * npm run release # patch 版本 (1.0.2 -> 1.0.3),默认使用 https://botskill.ai
6
- * npm run release:minor # minor 版本 (1.0.2 -> 1.1.0)
7
- * npm run release:major # major 版本 (1.0.2 -> 2.0.0)
8
- * npm run release -- --dry-run # 预览版本号变化,不实际发布
9
- * BOTSKILL_API_URL=其他URL npm run release # 使用自定义 API URL
10
- */
11
- import { execSync } from 'child_process';
12
- import { readFileSync, writeFileSync } from 'fs';
13
- import { fileURLToPath } from 'url';
14
- import { dirname, join } from 'path';
15
-
16
- const __dirname = dirname(fileURLToPath(import.meta.url));
17
- const packageJsonPath = join(__dirname, '../package.json');
18
-
19
- // 解析命令行参数
20
- const args = process.argv.slice(2);
21
- const isDryRun = args.includes('--dry-run');
22
- const versionType = args.find(arg => ['patch', 'minor', 'major'].includes(arg)) || 'patch';
23
-
24
- // 读取当前版本
25
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
26
- const currentVersion = packageJson.version;
27
- console.log(`当前版本: ${currentVersion}`);
28
-
29
- // 计算新版本号
30
- const [major, minor, patch] = currentVersion.split('.').map(Number);
31
- let newVersion;
32
- switch (versionType) {
33
- case 'major':
34
- newVersion = `${major + 1}.0.0`;
35
- break;
36
- case 'minor':
37
- newVersion = `${major}.${minor + 1}.0`;
38
- break;
39
- case 'patch':
40
- default:
41
- newVersion = `${major}.${minor}.${patch + 1}`;
42
- break;
43
- }
44
-
45
- console.log(`新版本: ${newVersion}`);
46
-
47
- // 获取 API URL(发布时默认使用生产环境)
48
- const apiUrl = process.env.BOTSKILL_API_URL || 'https://botskill.ai';
49
- console.log(`使用 API URL: ${apiUrl}`);
50
-
51
- if (isDryRun) {
52
- console.log('\n[DRY RUN] 预览模式,不会实际修改版本号或发布');
53
- process.exit(0);
54
- }
55
-
56
- // 更新 package.json 中的版本号
57
- packageJson.version = newVersion;
58
- writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
59
- console.log(`✓ 已更新 package.json 版本号为 ${newVersion}`);
60
-
61
- try {
62
- // 构建
63
- console.log('\n开始构建...');
64
- execSync(`npm run build`, { stdio: 'inherit', env: { ...process.env, BOTSKILL_API_URL: apiUrl } });
65
-
66
- // 发布
67
- console.log('\n开始发布到 npm...');
68
- execSync(`npm publish`, { stdio: 'inherit' });
69
-
70
- // 恢复构建文件
71
- console.log('\n恢复构建文件...');
72
- execSync(`npm run build:restore`, { stdio: 'inherit' });
73
-
74
- console.log(`\n✓ 成功发布 ${newVersion} 版本!`);
75
- } catch (error) {
76
- console.error('\n✗ 发布失败,正在恢复版本号...');
77
- // 恢复版本号
78
- packageJson.version = currentVersion;
79
- writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
80
- process.exit(1);
81
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 发布脚本:自动增加版本号并发布
4
+ * 用法:
5
+ * npm run release # patch 版本 (1.0.2 -> 1.0.3),默认使用 https://botskill.ai
6
+ * npm run release:minor # minor 版本 (1.0.2 -> 1.1.0)
7
+ * npm run release:major # major 版本 (1.0.2 -> 2.0.0)
8
+ * npm run release -- --dry-run # 预览版本号变化,不实际发布
9
+ * BOTSKILL_API_URL=其他URL npm run release # 使用自定义 API URL
10
+ */
11
+ import { execSync } from 'child_process';
12
+ import { readFileSync, writeFileSync } from 'fs';
13
+ import { fileURLToPath } from 'url';
14
+ import { dirname, join } from 'path';
15
+
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
17
+ const packageJsonPath = join(__dirname, '../package.json');
18
+
19
+ // 解析命令行参数
20
+ const args = process.argv.slice(2);
21
+ const isDryRun = args.includes('--dry-run');
22
+ const versionType = args.find(arg => ['patch', 'minor', 'major'].includes(arg)) || 'patch';
23
+
24
+ // 读取当前版本
25
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
26
+ const currentVersion = packageJson.version;
27
+ console.log(`当前版本: ${currentVersion}`);
28
+
29
+ // 计算新版本号
30
+ const [major, minor, patch] = currentVersion.split('.').map(Number);
31
+ let newVersion;
32
+ switch (versionType) {
33
+ case 'major':
34
+ newVersion = `${major + 1}.0.0`;
35
+ break;
36
+ case 'minor':
37
+ newVersion = `${major}.${minor + 1}.0`;
38
+ break;
39
+ case 'patch':
40
+ default:
41
+ newVersion = `${major}.${minor}.${patch + 1}`;
42
+ break;
43
+ }
44
+
45
+ console.log(`新版本: ${newVersion}`);
46
+
47
+ // 获取 API URL(发布时默认使用生产环境)
48
+ const apiUrl = process.env.BOTSKILL_API_URL || 'https://botskill.ai';
49
+ console.log(`使用 API URL: ${apiUrl}`);
50
+
51
+ if (isDryRun) {
52
+ console.log('\n[DRY RUN] 预览模式,不会实际修改版本号或发布');
53
+ process.exit(0);
54
+ }
55
+
56
+ // 更新 package.json 中的版本号
57
+ packageJson.version = newVersion;
58
+ writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
59
+ console.log(`✓ 已更新 package.json 版本号为 ${newVersion}`);
60
+
61
+ try {
62
+ // 构建
63
+ console.log('\n开始构建...');
64
+ execSync(`npm run build`, { stdio: 'inherit', env: { ...process.env, BOTSKILL_API_URL: apiUrl } });
65
+
66
+ // 发布
67
+ console.log('\n开始发布到 npm...');
68
+ execSync(`npm publish`, { stdio: 'inherit' });
69
+
70
+ // 恢复构建文件
71
+ console.log('\n恢复构建文件...');
72
+ execSync(`npm run build:restore`, { stdio: 'inherit' });
73
+
74
+ console.log(`\n✓ 成功发布 ${newVersion} 版本!`);
75
+ } catch (error) {
76
+ console.error('\n✗ 发布失败,正在恢复版本号...');
77
+ // 恢复版本号
78
+ packageJson.version = currentVersion;
79
+ writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
80
+ process.exit(1);
81
+ }