@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
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Open Skills Hub CLI - Get Command
3
+ */
4
+
5
+ import { Command } from 'commander';
6
+ import chalk from 'chalk';
7
+ import ora from 'ora';
8
+ import * as fs from 'fs';
9
+ import * as path from 'path';
10
+ import {
11
+ getStorage,
12
+ getConfig,
13
+ parseSkillFullName,
14
+ buildSkillFullName,
15
+ generateUUID,
16
+ now,
17
+ } from '@open-skills-hub/core';
18
+
19
+ export const getCommand = new Command('get')
20
+ .description('Get skill content')
21
+ .argument('<name>', 'Skill name (e.g., code-reviewer or @scope/skill-name)')
22
+ .option('-v, --version <version>', 'Specific version')
23
+ .option('-o, --output <file>', 'Output to file')
24
+ .option('--json', 'Output as JSON')
25
+ .option('--no-cache', 'Skip cache')
26
+ .action(async (name, options) => {
27
+ const spinner = ora(`Fetching ${name}...`).start();
28
+
29
+ try {
30
+ const storage = await getStorage();
31
+ await storage.initialize();
32
+ const config = getConfig();
33
+
34
+ // Parse name
35
+ const { scope, name: skillName } = parseSkillFullName(name);
36
+ const fullName = buildSkillFullName(skillName, scope);
37
+
38
+ // Get skill
39
+ const skill = await storage.getSkillByName(fullName);
40
+ if (!skill) {
41
+ spinner.fail(`Skill '${fullName}' not found`);
42
+ process.exit(1);
43
+ }
44
+
45
+ // Get version
46
+ let version;
47
+ if (options.version) {
48
+ version = await storage.getVersion(skill.id, options.version);
49
+ if (!version) {
50
+ spinner.fail(`Version '${options.version}' not found for '${fullName}'`);
51
+ process.exit(1);
52
+ }
53
+ } else {
54
+ version = await storage.getLatestVersion(skill.id);
55
+ if (!version) {
56
+ spinner.fail(`No versions found for '${fullName}'`);
57
+ process.exit(1);
58
+ }
59
+ }
60
+
61
+ // Record use
62
+ await storage.incrementSkillUses(skill.id);
63
+ await storage.incrementVersionUses(version.id);
64
+
65
+ const useRecord = {
66
+ id: generateUUID(),
67
+ skillId: skill.id,
68
+ versionId: version.id,
69
+ source: 'cli' as const,
70
+ cacheHit: false,
71
+ ip: '127.0.0.1', // Local
72
+ createdAt: now(),
73
+ };
74
+ await storage.createUseRecord(useRecord);
75
+
76
+ spinner.succeed(`Fetched ${fullName}@${version.version}`);
77
+
78
+ // Output result
79
+ const content = version.content;
80
+
81
+ if (options.json) {
82
+ console.log(JSON.stringify({
83
+ skill: {
84
+ name: skill.fullName,
85
+ displayName: skill.displayName,
86
+ description: skill.description,
87
+ securityLevel: skill.securityLevel,
88
+ },
89
+ version: version.version,
90
+ content,
91
+ }, null, 2));
92
+ } else if (options.output) {
93
+ // Write to file
94
+ const outputPath = path.resolve(options.output);
95
+ const outputContent = `---
96
+ name: ${content.frontmatter.name}
97
+ ${content.frontmatter.description ? `description: ${content.frontmatter.description}` : ''}
98
+ ${content.frontmatter.allowedTools ? `allowedTools:\n${content.frontmatter.allowedTools.map(t => ` - ${t}`).join('\n')}` : ''}
99
+ ---
100
+
101
+ ${content.markdown}`;
102
+
103
+ fs.writeFileSync(outputPath, outputContent, 'utf-8');
104
+ console.log(chalk.green(`\nSaved to ${outputPath}`));
105
+ } else {
106
+ // Print to console
107
+ console.log('\n' + chalk.bold.blue('─'.repeat(60)));
108
+ console.log(chalk.bold.white(`${skill.displayName ?? skill.fullName}`));
109
+ console.log(chalk.gray(`v${version.version} • ${skill.description}`));
110
+ console.log(chalk.bold.blue('─'.repeat(60)) + '\n');
111
+
112
+ // Security info
113
+ const securityColor = {
114
+ safe: chalk.green,
115
+ low: chalk.blue,
116
+ medium: chalk.yellow,
117
+ high: chalk.red,
118
+ }[skill.securityLevel ?? 'safe'] ?? chalk.white;
119
+ console.log(chalk.gray('Security:'), securityColor(`${skill.securityLevel ?? 'unknown'} (score: ${skill.securityScore ?? 'N/A'})`));
120
+
121
+ // Stats
122
+ console.log(chalk.gray('Uses:'), chalk.white(skill.stats.totalUses.toString()));
123
+ console.log(chalk.gray('Rating:'), chalk.white(`${skill.rating.average}/5 (${skill.rating.count} reviews)`));
124
+ console.log();
125
+
126
+ // Frontmatter
127
+ if (content.frontmatter.allowedTools?.length) {
128
+ console.log(chalk.cyan('Allowed Tools:'), content.frontmatter.allowedTools.join(', '));
129
+ }
130
+
131
+ // Content
132
+ console.log(chalk.bold('\nContent:\n'));
133
+ console.log(content.markdown);
134
+ }
135
+
136
+ await storage.close();
137
+ } catch (error) {
138
+ spinner.fail('Failed to get skill');
139
+ throw error;
140
+ }
141
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Open Skills Hub CLI - Commands Export
3
+ */
4
+
5
+ export { searchCommand } from './search.js';
6
+ export { getCommand } from './get.js';
7
+ export { publishCommand } from './publish.js';
8
+ export { validateCommand } from './validate.js';
9
+ export { createCommand } from './create.js';
10
+ export { scanCommand } from './scan.js';
11
+ export { feedbackCommand } from './feedback.js';
12
+ export { cacheCommand } from './cache.js';
13
+ export { configCommand } from './config.js';