@open-skills-hub/cli 1.0.0
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/dist/commands/cache.d.ts +6 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +145 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/config.d.ts +6 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +128 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/create.d.ts +7 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +449 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/feedback.d.ts +6 -0
- package/dist/commands/feedback.d.ts.map +1 -0
- package/dist/commands/feedback.js +137 -0
- package/dist/commands/feedback.js.map +1 -0
- package/dist/commands/get.d.ts +6 -0
- package/dist/commands/get.d.ts.map +1 -0
- package/dist/commands/get.js +122 -0
- package/dist/commands/get.js.map +1 -0
- package/dist/commands/index.d.ts +13 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +13 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/publish.d.ts +7 -0
- package/dist/commands/publish.d.ts.map +1 -0
- package/dist/commands/publish.js +593 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/scan.d.ts +6 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +165 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/search.d.ts +6 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +80 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/validate.d.ts +7 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +328 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
- package/src/commands/cache.ts +166 -0
- package/src/commands/config.ts +142 -0
- package/src/commands/create.ts +490 -0
- package/src/commands/feedback.ts +161 -0
- package/src/commands/get.ts +141 -0
- package/src/commands/index.ts +13 -0
- package/src/commands/publish.ts +688 -0
- package/src/commands/scan.ts +190 -0
- package/src/commands/search.ts +92 -0
- package/src/commands/validate.ts +391 -0
- package/src/index.ts +118 -0
- package/tsconfig.json +13 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Open Skills Hub CLI - Entry Point
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { initConfig, logger } from '@open-skills-hub/core';
|
|
9
|
+
|
|
10
|
+
import { searchCommand } from './commands/search.js';
|
|
11
|
+
import { getCommand } from './commands/get.js';
|
|
12
|
+
import { publishCommand } from './commands/publish.js';
|
|
13
|
+
import { validateCommand } from './commands/validate.js';
|
|
14
|
+
import { createCommand } from './commands/create.js';
|
|
15
|
+
import { scanCommand } from './commands/scan.js';
|
|
16
|
+
import { feedbackCommand } from './commands/feedback.js';
|
|
17
|
+
import { cacheCommand } from './commands/cache.js';
|
|
18
|
+
import { configCommand } from './commands/config.js';
|
|
19
|
+
|
|
20
|
+
// Package info
|
|
21
|
+
const VERSION = '1.0.0';
|
|
22
|
+
const DESCRIPTION = 'Open Skills Hub CLI - AI 时代的 npm + Docker Hub';
|
|
23
|
+
|
|
24
|
+
// Create the CLI program
|
|
25
|
+
const program = new Command();
|
|
26
|
+
|
|
27
|
+
program
|
|
28
|
+
.name('skills')
|
|
29
|
+
.version(VERSION)
|
|
30
|
+
.description(DESCRIPTION)
|
|
31
|
+
.option('-v, --verbose', 'Enable verbose output')
|
|
32
|
+
.option('-q, --quiet', 'Suppress output')
|
|
33
|
+
.option('--config <path>', 'Path to configuration file')
|
|
34
|
+
.hook('preAction', async (thisCommand) => {
|
|
35
|
+
// Initialize configuration
|
|
36
|
+
const options = thisCommand.opts();
|
|
37
|
+
const config = initConfig(options['config']);
|
|
38
|
+
await config.load();
|
|
39
|
+
|
|
40
|
+
// Set log level based on flags
|
|
41
|
+
if (options['verbose']) {
|
|
42
|
+
config.setValue('logLevel', 'debug');
|
|
43
|
+
} else if (options['quiet']) {
|
|
44
|
+
config.setValue('logLevel', 'error');
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Register commands
|
|
49
|
+
program.addCommand(searchCommand);
|
|
50
|
+
program.addCommand(getCommand);
|
|
51
|
+
program.addCommand(createCommand);
|
|
52
|
+
program.addCommand(validateCommand);
|
|
53
|
+
program.addCommand(publishCommand);
|
|
54
|
+
program.addCommand(scanCommand);
|
|
55
|
+
program.addCommand(feedbackCommand);
|
|
56
|
+
program.addCommand(cacheCommand);
|
|
57
|
+
program.addCommand(configCommand);
|
|
58
|
+
|
|
59
|
+
// Help text customization
|
|
60
|
+
program.configureHelp({
|
|
61
|
+
sortSubcommands: true,
|
|
62
|
+
subcommandTerm: (cmd) => cmd.name(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Custom help
|
|
66
|
+
program.addHelpText('after', `
|
|
67
|
+
${chalk.bold('Examples:')}
|
|
68
|
+
${chalk.gray('# Create a new skill')}
|
|
69
|
+
$ skills create my-skill
|
|
70
|
+
|
|
71
|
+
${chalk.gray('# Validate a skill')}
|
|
72
|
+
$ skills validate ./my-skill
|
|
73
|
+
|
|
74
|
+
${chalk.gray('# Publish a skill directory')}
|
|
75
|
+
$ skills publish ./my-skill
|
|
76
|
+
|
|
77
|
+
${chalk.gray('# Search for skills')}
|
|
78
|
+
$ skills search "code review"
|
|
79
|
+
|
|
80
|
+
${chalk.gray('# Get skill content')}
|
|
81
|
+
$ skills get code-reviewer
|
|
82
|
+
|
|
83
|
+
${chalk.gray('# Scan content for security issues')}
|
|
84
|
+
$ skills scan ./my-skill.md
|
|
85
|
+
|
|
86
|
+
${chalk.bold('Documentation:')}
|
|
87
|
+
https://github.com/OpenSkillsHub/open-skills-hub
|
|
88
|
+
`);
|
|
89
|
+
|
|
90
|
+
// Error handling
|
|
91
|
+
program.exitOverride();
|
|
92
|
+
|
|
93
|
+
// Run the CLI
|
|
94
|
+
async function main(): Promise<void> {
|
|
95
|
+
try {
|
|
96
|
+
await program.parseAsync(process.argv);
|
|
97
|
+
// Explicitly exit after successful command execution
|
|
98
|
+
// This ensures the process doesn't hang waiting for async operations
|
|
99
|
+
process.exit(0);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error instanceof Error) {
|
|
102
|
+
// Commander's exit override throws errors for help/version
|
|
103
|
+
if (error.message.includes('(commander.helpDisplayed)') ||
|
|
104
|
+
error.message.includes('(commander.version)')) {
|
|
105
|
+
process.exit(0);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
console.error(chalk.red('\nError:'), error.message);
|
|
109
|
+
|
|
110
|
+
if (process.env['DEBUG']) {
|
|
111
|
+
console.error(chalk.gray(error.stack));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
main();
|
package/tsconfig.json
ADDED