prpm 0.0.7 → 0.0.9

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.
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ /**
3
+ * Config command implementation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createConfigCommand = createConfigCommand;
7
+ const commander_1 = require("commander");
8
+ const user_config_1 = require("../core/user-config");
9
+ /**
10
+ * Get a config value
11
+ */
12
+ async function handleConfigGet(key) {
13
+ try {
14
+ const config = await (0, user_config_1.getConfig)();
15
+ const value = config[key];
16
+ if (value === undefined) {
17
+ console.error(`❌ Config key "${key}" not found`);
18
+ console.log('\nAvailable keys: registryUrl, telemetryEnabled, token, username');
19
+ process.exit(1);
20
+ }
21
+ console.log(value);
22
+ }
23
+ catch (error) {
24
+ console.error(`❌ Failed to get config: ${error instanceof Error ? error.message : String(error)}`);
25
+ process.exit(1);
26
+ }
27
+ }
28
+ /**
29
+ * Set a config value
30
+ */
31
+ async function handleConfigSet(key, value) {
32
+ try {
33
+ const config = await (0, user_config_1.getConfig)();
34
+ // Validate key
35
+ const validKeys = ['registryUrl', 'telemetryEnabled'];
36
+ if (!validKeys.includes(key)) {
37
+ console.error(`❌ Cannot set config key "${key}"`);
38
+ console.log('\nSettable keys: registryUrl, telemetryEnabled');
39
+ console.log('Note: token and username are set via "prpm login"');
40
+ process.exit(1);
41
+ }
42
+ // Parse boolean values
43
+ let parsedValue = value;
44
+ if (key === 'telemetryEnabled') {
45
+ if (value === 'true' || value === '1' || value === 'yes') {
46
+ parsedValue = true;
47
+ }
48
+ else if (value === 'false' || value === '0' || value === 'no') {
49
+ parsedValue = false;
50
+ }
51
+ else {
52
+ console.error(`❌ Invalid boolean value "${value}". Use: true, false, yes, no, 1, or 0`);
53
+ process.exit(1);
54
+ }
55
+ }
56
+ // Update config
57
+ config[key] = parsedValue;
58
+ await (0, user_config_1.saveConfig)(config);
59
+ console.log(`✅ Set ${key} = ${parsedValue}`);
60
+ }
61
+ catch (error) {
62
+ console.error(`❌ Failed to set config: ${error instanceof Error ? error.message : String(error)}`);
63
+ process.exit(1);
64
+ }
65
+ }
66
+ /**
67
+ * List all config values
68
+ */
69
+ async function handleConfigList() {
70
+ try {
71
+ const config = await (0, user_config_1.getConfig)();
72
+ console.log('📋 Current configuration:\n');
73
+ console.log(` Registry URL: ${config.registryUrl}`);
74
+ console.log(` Telemetry: ${config.telemetryEnabled ? 'enabled' : 'disabled'}`);
75
+ console.log(` Username: ${config.username || '(not logged in)'}`);
76
+ console.log(` Token: ${config.token ? '(set)' : '(not set)'}`);
77
+ console.log('');
78
+ const configPath = process.platform === 'win32'
79
+ ? `${process.env.USERPROFILE}\\.prpmrc`
80
+ : `${process.env.HOME}/.prpmrc`;
81
+ console.log(`Config file: ${configPath}`);
82
+ }
83
+ catch (error) {
84
+ console.error(`❌ Failed to list config: ${error instanceof Error ? error.message : String(error)}`);
85
+ process.exit(1);
86
+ }
87
+ }
88
+ /**
89
+ * Delete a config value (reset to default)
90
+ */
91
+ async function handleConfigDelete(key) {
92
+ try {
93
+ const config = await (0, user_config_1.getConfig)();
94
+ // Validate key
95
+ const deletableKeys = ['registryUrl', 'telemetryEnabled', 'token', 'username'];
96
+ if (!deletableKeys.includes(key)) {
97
+ console.error(`❌ Cannot delete config key "${key}"`);
98
+ process.exit(1);
99
+ }
100
+ // Reset to defaults
101
+ if (key === 'registryUrl') {
102
+ config.registryUrl = 'https://registry.prpm.dev';
103
+ }
104
+ else if (key === 'telemetryEnabled') {
105
+ config.telemetryEnabled = true;
106
+ }
107
+ else if (key === 'token') {
108
+ config.token = undefined;
109
+ }
110
+ else if (key === 'username') {
111
+ config.username = undefined;
112
+ }
113
+ await (0, user_config_1.saveConfig)(config);
114
+ console.log(`✅ Reset ${key} to default value`);
115
+ }
116
+ catch (error) {
117
+ console.error(`❌ Failed to delete config: ${error instanceof Error ? error.message : String(error)}`);
118
+ process.exit(1);
119
+ }
120
+ }
121
+ /**
122
+ * Create the config command
123
+ */
124
+ function createConfigCommand() {
125
+ const command = new commander_1.Command('config')
126
+ .description('Manage CLI configuration');
127
+ // config list
128
+ command
129
+ .command('list')
130
+ .alias('ls')
131
+ .description('List all configuration values')
132
+ .action(async () => {
133
+ await handleConfigList();
134
+ process.exit(0);
135
+ });
136
+ // config get <key>
137
+ command
138
+ .command('get <key>')
139
+ .description('Get a configuration value')
140
+ .action(async (key) => {
141
+ await handleConfigGet(key);
142
+ process.exit(0);
143
+ });
144
+ // config set <key> <value>
145
+ command
146
+ .command('set <key> <value>')
147
+ .description('Set a configuration value')
148
+ .action(async (key, value) => {
149
+ await handleConfigSet(key, value);
150
+ process.exit(0);
151
+ });
152
+ // config delete <key>
153
+ command
154
+ .command('delete <key>')
155
+ .alias('rm')
156
+ .description('Reset a configuration value to default')
157
+ .action(async (key) => {
158
+ await handleConfigDelete(key);
159
+ process.exit(0);
160
+ });
161
+ // Default action (show list if no subcommand)
162
+ command.action(async () => {
163
+ await handleConfigList();
164
+ process.exit(0);
165
+ });
166
+ return command;
167
+ }
@@ -17,7 +17,7 @@ const filesystem_1 = require("../core/filesystem");
17
17
  * Scan directory for files and return file information
18
18
  * Recursively scans subdirectories for Claude skills/agents
19
19
  */
20
- async function scanDirectory(dirPath, type) {
20
+ async function scanDirectory(dirPath, format, subtype) {
21
21
  try {
22
22
  const files = await fs_1.promises.readdir(dirPath, { withFileTypes: true });
23
23
  const results = [];
@@ -34,8 +34,8 @@ async function scanDirectory(dirPath, type) {
34
34
  }
35
35
  else if (file.isDirectory()) {
36
36
  // For Claude/Cursor skills/agents, scan subdirectories for structured packages
37
- const isClaudeType = type === 'claude-skill' || type === 'claude-agent' || type === 'claude';
38
- const isCursorAgent = type === 'cursor-agent';
37
+ const isClaudeType = format === 'claude';
38
+ const isCursorAgent = format === 'cursor' && subtype === 'agent';
39
39
  if (isClaudeType || isCursorAgent) {
40
40
  try {
41
41
  const subFiles = await fs_1.promises.readdir(fullPath, { withFileTypes: true });
@@ -88,22 +88,22 @@ async function handleIndex(options = {}) {
88
88
  let totalFound = 0;
89
89
  let totalAdded = 0;
90
90
  const summary = [];
91
- // Define directories to scan with their types
91
+ // Define directories to scan with their format and subtype
92
92
  const dirsToScan = [
93
- { path: '.cursor/rules', type: 'cursor', label: 'Cursor Rules' },
94
- { path: '.cursor/agents', type: 'cursor-agent', label: 'Cursor Agents' },
95
- { path: '.cursor/commands', type: 'cursor-slash-command', label: 'Cursor Slash Commands' },
96
- { path: '.claude/agents', type: 'claude-agent', label: 'Claude Agents' },
97
- { path: '.claude/skills', type: 'claude-skill', label: 'Claude Skills' },
98
- { path: '.claude/commands', type: 'claude-slash-command', label: 'Claude Slash Commands' },
99
- { path: '.continue/rules', type: 'continue', label: 'Continue Rules' },
100
- { path: '.windsurf/rules', type: 'windsurf', label: 'Windsurf Rules' },
101
- { path: '.prompts', type: 'generic', label: 'Generic Prompts' },
102
- { path: '.mcp', type: 'mcp', label: 'MCP Servers' },
93
+ { path: '.cursor/rules', format: 'cursor', subtype: 'rule', label: 'Cursor Rules' },
94
+ { path: '.cursor/agents', format: 'cursor', subtype: 'agent', label: 'Cursor Agents' },
95
+ { path: '.cursor/commands', format: 'cursor', subtype: 'slash-command', label: 'Cursor Slash Commands' },
96
+ { path: '.claude/agents', format: 'claude', subtype: 'agent', label: 'Claude Agents' },
97
+ { path: '.claude/skills', format: 'claude', subtype: 'skill', label: 'Claude Skills' },
98
+ { path: '.claude/commands', format: 'claude', subtype: 'slash-command', label: 'Claude Slash Commands' },
99
+ { path: '.continue/rules', format: 'continue', subtype: 'rule', label: 'Continue Rules' },
100
+ { path: '.windsurf/rules', format: 'windsurf', subtype: 'rule', label: 'Windsurf Rules' },
101
+ { path: '.prompts', format: 'generic', subtype: 'prompt', label: 'Generic Prompts' },
102
+ { path: '.mcp', format: 'mcp', subtype: 'tool', label: 'MCP Servers' },
103
103
  ];
104
104
  // Scan each directory
105
105
  for (const dir of dirsToScan) {
106
- const files = await scanDirectory(dir.path, dir.type);
106
+ const files = await scanDirectory(dir.path, dir.format, dir.subtype);
107
107
  if (files.length === 0) {
108
108
  if (options.verbose) {
109
109
  console.log(`📁 ${dir.path}/ - No files found`);
@@ -119,8 +119,8 @@ async function handleIndex(options = {}) {
119
119
  id: file.id,
120
120
  version: '0.0.0', // Local files don't have versions
121
121
  tarballUrl: `file://${path_1.default.resolve(file.filePath)}`,
122
- type: dir.type,
123
- format: dir.type,
122
+ format: dir.format,
123
+ subtype: dir.subtype,
124
124
  });
125
125
  if (options.verbose) {
126
126
  console.log(` ✅ Added: ${file.filename} (${file.id})`);
@@ -40,7 +40,7 @@ async function handleInfo(packageName) {
40
40
  console.log(`\n🏷️ Tags: ${pkg.tags.join(', ')}`);
41
41
  }
42
42
  // Type
43
- console.log(`\n📂 Type: ${pkg.type}`);
43
+ console.log(`\n📂 Type: ${`${pkg.format || 'unknown'} ${pkg.subtype || 'unknown'}`}`);
44
44
  // Installation
45
45
  console.log('\n💻 Installation:');
46
46
  console.log(` prpm install ${pkg.name}`);
@@ -77,6 +77,7 @@ function createInfoCommand() {
77
77
  .argument('<package>', 'Package ID to get information about')
78
78
  .action(async (packageId) => {
79
79
  await handleInfo(packageId);
80
+ process.exit(0);
80
81
  });
81
82
  return command;
82
83
  }