@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.
Files changed (57) hide show
  1. package/dist/commands/cache.d.ts +6 -0
  2. package/dist/commands/cache.d.ts.map +1 -0
  3. package/dist/commands/cache.js +145 -0
  4. package/dist/commands/cache.js.map +1 -0
  5. package/dist/commands/config.d.ts +6 -0
  6. package/dist/commands/config.d.ts.map +1 -0
  7. package/dist/commands/config.js +128 -0
  8. package/dist/commands/config.js.map +1 -0
  9. package/dist/commands/create.d.ts +7 -0
  10. package/dist/commands/create.d.ts.map +1 -0
  11. package/dist/commands/create.js +449 -0
  12. package/dist/commands/create.js.map +1 -0
  13. package/dist/commands/feedback.d.ts +6 -0
  14. package/dist/commands/feedback.d.ts.map +1 -0
  15. package/dist/commands/feedback.js +137 -0
  16. package/dist/commands/feedback.js.map +1 -0
  17. package/dist/commands/get.d.ts +6 -0
  18. package/dist/commands/get.d.ts.map +1 -0
  19. package/dist/commands/get.js +122 -0
  20. package/dist/commands/get.js.map +1 -0
  21. package/dist/commands/index.d.ts +13 -0
  22. package/dist/commands/index.d.ts.map +1 -0
  23. package/dist/commands/index.js +13 -0
  24. package/dist/commands/index.js.map +1 -0
  25. package/dist/commands/publish.d.ts +7 -0
  26. package/dist/commands/publish.d.ts.map +1 -0
  27. package/dist/commands/publish.js +593 -0
  28. package/dist/commands/publish.js.map +1 -0
  29. package/dist/commands/scan.d.ts +6 -0
  30. package/dist/commands/scan.d.ts.map +1 -0
  31. package/dist/commands/scan.js +165 -0
  32. package/dist/commands/scan.js.map +1 -0
  33. package/dist/commands/search.d.ts +6 -0
  34. package/dist/commands/search.d.ts.map +1 -0
  35. package/dist/commands/search.js +80 -0
  36. package/dist/commands/search.js.map +1 -0
  37. package/dist/commands/validate.d.ts +7 -0
  38. package/dist/commands/validate.d.ts.map +1 -0
  39. package/dist/commands/validate.js +328 -0
  40. package/dist/commands/validate.js.map +1 -0
  41. package/dist/index.d.ts +6 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +107 -0
  44. package/dist/index.js.map +1 -0
  45. package/package.json +51 -0
  46. package/src/commands/cache.ts +166 -0
  47. package/src/commands/config.ts +142 -0
  48. package/src/commands/create.ts +490 -0
  49. package/src/commands/feedback.ts +161 -0
  50. package/src/commands/get.ts +141 -0
  51. package/src/commands/index.ts +13 -0
  52. package/src/commands/publish.ts +688 -0
  53. package/src/commands/scan.ts +190 -0
  54. package/src/commands/search.ts +92 -0
  55. package/src/commands/validate.ts +391 -0
  56. package/src/index.ts +118 -0
  57. 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
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "composite": true
7
+ },
8
+ "include": ["src/**/*"],
9
+ "exclude": ["node_modules", "dist"],
10
+ "references": [
11
+ { "path": "../core" }
12
+ ]
13
+ }