@nacos-group/cli 0.0.5

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 ADDED
@@ -0,0 +1,328 @@
1
+ # Nacos CLI
2
+
3
+ A powerful command-line tool for managing Nacos configuration center and AI skills, written in Go.
4
+
5
+ ## Features
6
+
7
+ - 🚀 Fast and lightweight - single binary with no dependencies
8
+ - 💻 Interactive terminal mode with auto-completion
9
+ - 🎯 Skill management - upload, download, list, and sync AI skills
10
+ - 📝 Configuration management - list and get configurations
11
+ - 🔄 Real-time skill synchronization with Nacos
12
+ - 🌐 Namespace support for multi-environment management
13
+ - 📦 Batch operations - upload all skills at once
14
+
15
+ ## Installation
16
+
17
+ ### Download Binary
18
+
19
+ Download the latest release from [GitHub Releases](https://github.com/yourusername/nacos-cli/releases).
20
+
21
+ ### Build from Source
22
+
23
+ ```bash
24
+ # Clone the repository
25
+ git clone https://github.com/yourusername/nacos-cli.git
26
+ cd nacos-cli
27
+
28
+ # Build
29
+ go build -o nacos-cli
30
+
31
+ # Or use make
32
+ make build
33
+ ```
34
+
35
+ ## Quick Start
36
+
37
+ ### CLI Mode
38
+
39
+ Run commands directly:
40
+
41
+ ```bash
42
+ # List all skills
43
+ nacos-cli skill-list -s 127.0.0.1:8848 -u nacos -p nacos
44
+
45
+ # Get a skill
46
+ nacos-cli skill-get skill-creator -s 127.0.0.1:8848 -u nacos -p nacos
47
+
48
+ # Upload a skill
49
+ nacos-cli skill-upload /path/to/skill -s 127.0.0.1:8848 -u nacos -p nacos
50
+ ```
51
+
52
+ ### Interactive Terminal Mode
53
+
54
+ Start an interactive session:
55
+
56
+ ```bash
57
+ nacos-cli -s 127.0.0.1:8848 -u nacos -p nacos
58
+ ```
59
+
60
+ Once in terminal mode, you can run commands interactively:
61
+
62
+ ```
63
+ nacos> skill-list
64
+ nacos> skill-get skill-creator
65
+ nacos> config-list
66
+ nacos> help
67
+ ```
68
+
69
+ ## Commands
70
+
71
+ ### Skill Management
72
+
73
+ #### List Skills
74
+
75
+ ```bash
76
+ # CLI mode
77
+ nacos-cli skill-list -s 127.0.0.1:8848 -u nacos -p nacos
78
+
79
+ # With filters
80
+ nacos-cli skill-list --name skill-creator --page 1 --size 20
81
+
82
+ # Show skill description
83
+ nacos-cli skill-list --desc
84
+
85
+ # Terminal mode
86
+ nacos> skill-list
87
+ nacos> skill-list --name skill-creator --page 2
88
+ nacos> skill-list --desc
89
+ ```
90
+
91
+ #### Get/Download Skill
92
+
93
+ Download a skill to local directory (default: `~/.skills`):
94
+
95
+ ```bash
96
+ # CLI mode
97
+ nacos-cli skill-get skill-creator -s 127.0.0.1:8848 -u nacos -p nacos
98
+ nacos-cli skill-get skill-creator -o /custom/path
99
+
100
+ # Terminal mode
101
+ nacos> skill-get skill-creator
102
+ ```
103
+
104
+ #### Upload Skill
105
+
106
+ Upload a skill from local directory:
107
+
108
+ ```bash
109
+ # Upload single skill
110
+ nacos-cli skill-upload /path/to/skill -s 127.0.0.1:8848 -u nacos -p nacos
111
+
112
+ # Upload all skills in a directory
113
+ nacos-cli skill-upload --all /path/to/skills/folder
114
+
115
+ # Terminal mode
116
+ nacos> skill-upload /path/to/skill
117
+ nacos> skill-upload --all /path/to/skills
118
+ ```
119
+
120
+ #### Sync Skill
121
+
122
+ Real-time synchronization - automatically syncs local skills when they change in Nacos:
123
+
124
+ ```bash
125
+ # Sync single skill (CLI mode only)
126
+ nacos-cli skill-sync skill-creator -s 127.0.0.1:8848 -u nacos -p nacos
127
+
128
+ # Sync multiple skills
129
+ nacos-cli skill-sync skill-creator skill-analyzer
130
+
131
+ # Sync all skills
132
+ nacos-cli skill-sync --all
133
+
134
+ # Press Ctrl+C to stop synchronization
135
+ ```
136
+
137
+ **Note**: `skill-sync` is only available in CLI mode, not in terminal mode.
138
+
139
+ ### Configuration Management
140
+
141
+ #### List Configurations
142
+
143
+ ```bash
144
+ # CLI mode
145
+ nacos-cli config-list -s 127.0.0.1:8848 -u nacos -p nacos
146
+
147
+ # With filters
148
+ nacos-cli config-list --data-id myconfig --group DEFAULT_GROUP
149
+
150
+ # With pagination
151
+ nacos-cli config-list --page 1 --size 20
152
+
153
+ # Terminal mode
154
+ nacos> config-list
155
+ nacos> config-list --data-id myconfig --page 2
156
+ ```
157
+
158
+ #### Get Configuration
159
+
160
+ ```bash
161
+ # CLI mode
162
+ nacos-cli config-get myconfig DEFAULT_GROUP -s 127.0.0.1:8848 -u nacos -p nacos
163
+
164
+ # Terminal mode
165
+ nacos> config-get myconfig DEFAULT_GROUP
166
+ ```
167
+
168
+ ### Terminal Commands
169
+
170
+ When in interactive terminal mode:
171
+
172
+ ```bash
173
+ nacos> help # Show all available commands
174
+ nacos> server # Show server information
175
+ nacos> ns # Show current namespace
176
+ nacos> ns production # Switch to production namespace
177
+ nacos> clear # Clear screen
178
+ nacos> quit # Exit terminal
179
+ ```
180
+
181
+ ## Global Flags
182
+
183
+ | Flag | Short | Default | Description |
184
+ |------|-------|---------|-------------|
185
+ | --host | | 127.0.0.1 | Nacos server host |
186
+ | --port | | 8848 | Nacos server port |
187
+ | --server | -s | 127.0.0.1:8848 | Nacos server address (deprecated, use --host and --port) |
188
+ | --username | -u | nacos | Nacos username |
189
+ | --password | -p | nacos | Nacos password |
190
+ | --namespace | -n | (empty/public) | Nacos namespace ID |
191
+ | --config | -c | | Path to configuration file |
192
+ | --help | -h | | Show help information |
193
+
194
+ ## Configuration File
195
+
196
+ You can use a configuration file to avoid typing credentials every time:
197
+
198
+ ```bash
199
+ # Create a config file
200
+ cat > local.conf << EOF
201
+ host: 127.0.0.1
202
+ port: 8848
203
+ username: nacos
204
+ password: nacos
205
+ namespace: ""
206
+ EOF
207
+
208
+ # Use the config file
209
+ nacos-cli --config ./local.conf skill-list
210
+ ```
211
+
212
+ ### Configuration File Format
213
+
214
+ The configuration file uses YAML format:
215
+
216
+ ```yaml
217
+ # Nacos server host
218
+ host: 127.0.0.1
219
+
220
+ # Nacos server port
221
+ port: 8848
222
+
223
+ # Username for authentication
224
+ username: nacos
225
+
226
+ # Password for authentication
227
+ password: nacos
228
+
229
+ # Namespace ID (optional, leave empty for public namespace)
230
+ namespace: ""
231
+ ```
232
+
233
+ ### Configuration Priority
234
+
235
+ Configuration values are applied in the following priority order:
236
+ 1. **Command line arguments** (highest priority)
237
+ 2. **Configuration file**
238
+ 3. **Default values** (lowest priority)
239
+
240
+ For example:
241
+ - `nacos-cli --config ./local.conf --host 10.0.0.1` - Uses `10.0.0.1` from command line, other values from config file
242
+ - `nacos-cli --host 192.168.1.100 --port 8848` - Uses command line values, defaults for username/password
243
+ - `nacos-cli --config ./local.conf` - Uses all values from config file
244
+
245
+ ## Project Structure
246
+
247
+ ```
248
+ nacos-cli/
249
+ ├── cmd/ # CLI commands
250
+ │ ├── root.go # Root command
251
+ │ ├── list_skill.go # skill-list command
252
+ │ ├── get_skill.go # skill-get command
253
+ │ ├── upload_skill.go # skill-upload command
254
+ │ ├── sync_skill.go # skill-sync command
255
+ │ ├── list_config.go # config-list command
256
+ │ ├── get_config.go # config-get command
257
+ │ └── interactive.go # Interactive terminal
258
+ ├── internal/
259
+ │ ├── client/ # Nacos client
260
+ │ ├── skill/ # Skill service
261
+ │ ├── sync/ # Sync service
262
+ │ ├── listener/ # Config listener
263
+ │ ├── terminal/ # Terminal implementation
264
+ │ └── help/ # Help system
265
+ ├── main.go
266
+ ├── go.mod
267
+ └── README.md
268
+ ```
269
+
270
+ ## Development
271
+
272
+ ### Prerequisites
273
+
274
+ - Go 1.21 or higher
275
+ - Nacos server (2.x recommended)
276
+
277
+ ### Build
278
+
279
+ ```bash
280
+ # Build binary
281
+ make build
282
+
283
+ # Or manually
284
+ go build -o nacos-cli
285
+ ```
286
+
287
+ ### Run Tests
288
+
289
+ ```bash
290
+ # Run test script
291
+ ./test.sh
292
+
293
+ # Or test specific commands
294
+ go run main.go skill-list -s 127.0.0.1:8848 -u nacos -p nacos
295
+ ```
296
+
297
+ ## Contributing
298
+
299
+ Contributions are welcome! Please feel free to submit a Pull Request.
300
+
301
+ 1. Fork the repository
302
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
303
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
304
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
305
+ 5. Open a Pull Request
306
+
307
+ ## License
308
+
309
+ MIT License
310
+
311
+ ## Changelog
312
+
313
+ ### v0.2.0 (2026-01-28)
314
+
315
+ - Rewritten in Go for better performance and portability
316
+ - Added skill management commands (list, get, upload, sync)
317
+ - Added real-time skill synchronization with Nacos
318
+ - Added interactive terminal mode with auto-completion
319
+ - Added batch upload support for multiple skills
320
+ - Added configuration management commands
321
+ - Improved error handling and user experience
322
+ - Removed all emoji clutter from terminal output
323
+
324
+ ### v0.1.0 (2026-01-27)
325
+
326
+ - Initial Python version release
327
+ - Basic configuration management
328
+ - Basic service discovery
package/bin/cli.js ADDED
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+
8
+ // Get current version from package.json
9
+ const packageJson = require('../package.json');
10
+ const VERSION = packageJson.version;
11
+
12
+ // Detect platform and architecture
13
+ function getBinaryName() {
14
+ const platform = os.platform();
15
+ const arch = os.arch();
16
+
17
+ let platformName;
18
+ let archName;
19
+ let ext = '';
20
+
21
+ // Map Node.js platform to Go platform names
22
+ switch (platform) {
23
+ case 'darwin':
24
+ platformName = 'darwin';
25
+ break;
26
+ case 'linux':
27
+ platformName = 'linux';
28
+ break;
29
+ case 'win32':
30
+ platformName = 'windows';
31
+ ext = '.exe';
32
+ break;
33
+ default:
34
+ console.error(`Unsupported platform: ${platform}`);
35
+ process.exit(1);
36
+ }
37
+
38
+ // Map Node.js arch to Go arch names
39
+ switch (arch) {
40
+ case 'x64':
41
+ archName = 'amd64';
42
+ break;
43
+ case 'arm64':
44
+ archName = 'arm64';
45
+ break;
46
+ default:
47
+ console.error(`Unsupported architecture: ${arch}`);
48
+ process.exit(1);
49
+ }
50
+
51
+ return `nacos-cli-${VERSION}-${platformName}-${archName}${ext}`;
52
+ }
53
+
54
+ // Get binary path
55
+ function getBinaryPath() {
56
+ const binaryName = getBinaryName();
57
+ const binaryPath = path.join(__dirname, '..', 'build', binaryName);
58
+
59
+ if (!fs.existsSync(binaryPath)) {
60
+ console.error(`Binary not found: ${binaryPath}`);
61
+ console.error(`Please ensure the binary for your platform (${os.platform()}/${os.arch()}) is available.`);
62
+ process.exit(1);
63
+ }
64
+
65
+ return binaryPath;
66
+ }
67
+
68
+ // Main execution
69
+ function main() {
70
+ const binaryPath = getBinaryPath();
71
+ const args = process.argv.slice(2);
72
+
73
+ // Spawn the binary with all arguments
74
+ const child = spawn(binaryPath, args, {
75
+ stdio: 'inherit',
76
+ shell: false
77
+ });
78
+
79
+ child.on('error', (err) => {
80
+ console.error(`Failed to execute binary: ${err.message}`);
81
+ process.exit(1);
82
+ });
83
+
84
+ child.on('exit', (code) => {
85
+ process.exit(code || 0);
86
+ });
87
+ }
88
+
89
+ main();
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@nacos-group/cli",
3
+ "version": "0.0.5",
4
+ "description": "A command-line tool for managing Nacos configurations and AI skills",
5
+ "bin": {
6
+ "nacos": "./bin/cli.js"
7
+ },
8
+ "files": [
9
+ "bin",
10
+ "build/nacos-cli-*"
11
+ ],
12
+ "keywords": [
13
+ "nacos",
14
+ "cli",
15
+ "configuration",
16
+ "ai",
17
+ "skills"
18
+ ],
19
+ "author": "",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/nacos-group/nacos-cli.git"
24
+ },
25
+ "engines": {
26
+ "node": ">=14.0.0"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }