ropilot 0.1.19 → 0.1.21

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/lib/config.js CHANGED
@@ -71,6 +71,22 @@ export function loadProjectConfig() {
71
71
  return null;
72
72
  }
73
73
 
74
+ /**
75
+ * Save project config
76
+ */
77
+ export function saveProjectConfig(config) {
78
+ writeFileSync(PROJECT_CONFIG_FILE, JSON.stringify(config, null, 2));
79
+ }
80
+
81
+ /**
82
+ * Set API key in project config
83
+ */
84
+ export function setProjectApiKey(apiKey) {
85
+ const config = loadProjectConfig() || {};
86
+ config.apiKey = apiKey;
87
+ saveProjectConfig(config);
88
+ }
89
+
74
90
  /**
75
91
  * Get the API key (project config overrides global)
76
92
  */
@@ -103,17 +119,32 @@ export async function showConfig() {
103
119
  console.log('Ropilot Configuration');
104
120
  console.log('=====================');
105
121
  console.log('');
106
- console.log('Global config (~/.ropilot/config.json):');
107
- console.log(` API Key: ${globalConfig.apiKey ? globalConfig.apiKey.slice(0, 20) + '...' : '(not set)'}`);
108
- console.log(` Prompts Version: ${globalConfig.promptsVersion || '(not downloaded)'}`);
109
- console.log(` Last Updated: ${globalConfig.lastUpdated || 'never'}`);
122
+
123
+ // Show which key is active
124
+ const activeKey = projectConfig?.apiKey || globalConfig.apiKey;
125
+ const activeSource = projectConfig?.apiKey ? '.ropilot.json (project)' : '~/.ropilot/config.json (global)';
126
+
127
+ console.log(`Active API Key: ${activeKey ? activeKey.slice(0, 20) + '...' : '(not set)'}`);
128
+ if (activeKey) {
129
+ console.log(` Source: ${activeSource}`);
130
+ }
110
131
  console.log('');
111
132
 
112
133
  if (projectConfig) {
113
134
  console.log('Project config (.ropilot.json):');
114
135
  console.log(` API Key: ${projectConfig.apiKey ? projectConfig.apiKey.slice(0, 20) + '...' : '(not set)'}`);
115
136
  console.log('');
137
+ } else {
138
+ console.log('Project config (.ropilot.json): not found');
139
+ console.log(' Run "npx ropilot init" to create one');
140
+ console.log('');
116
141
  }
117
142
 
143
+ console.log('Global config (~/.ropilot/config.json):');
144
+ console.log(` API Key: ${globalConfig.apiKey ? globalConfig.apiKey.slice(0, 20) + '...' : '(not set)'}`);
145
+ console.log(` Prompts Version: ${globalConfig.promptsVersion || '(not downloaded)'}`);
146
+ console.log(` Last Updated: ${globalConfig.lastUpdated || 'never'}`);
147
+ console.log('');
148
+
118
149
  console.log(`Edge Server: ${EDGE_URL}`);
119
150
  }
package/lib/proxy.js CHANGED
@@ -89,14 +89,16 @@ async function handleToolsCall(apiKey, request) {
89
89
  async function processRequest(apiKey, request) {
90
90
  const method = request.method;
91
91
 
92
+ // Notifications (methods starting with "notifications/") don't get responses
93
+ if (method.startsWith('notifications/')) {
94
+ // No response for notifications
95
+ return null;
96
+ }
97
+
92
98
  switch (method) {
93
99
  case 'initialize':
94
100
  return await handleInitialize(apiKey, request);
95
101
 
96
- case 'initialized':
97
- // Notification, no response needed
98
- return null;
99
-
100
102
  case 'tools/list':
101
103
  return await handleToolsList(apiKey, request);
102
104
 
package/lib/setup.js CHANGED
@@ -18,6 +18,8 @@ import {
18
18
  saveGlobalConfig,
19
19
  setApiKey,
20
20
  getApiKey,
21
+ setProjectApiKey,
22
+ loadProjectConfig,
21
23
  EDGE_URL
22
24
  } from './config.js';
23
25
 
@@ -370,28 +372,35 @@ export async function init(providedApiKey = null) {
370
372
  console.log('===================');
371
373
  console.log('');
372
374
 
373
- // Get API key
374
- let apiKey = providedApiKey || getApiKey();
375
+ // Always prompt for API key (per-project config)
376
+ const existingKey = loadProjectConfig()?.apiKey;
377
+ const defaultHint = existingKey ? ` [${existingKey.slice(0, 20)}...]` : '';
375
378
 
379
+ console.log('To use Ropilot, you need an API key.');
380
+ console.log('Get one at: https://ropilot.ai');
381
+ console.log('');
382
+
383
+ let apiKey = providedApiKey;
376
384
  if (!apiKey) {
377
- console.log('To use Ropilot, you need an API key.');
378
- console.log('Get one at: https://ropilot.ai');
379
- console.log('');
380
- apiKey = await prompt('Enter your API key (ropilot_...): ');
381
-
382
- if (!apiKey || !apiKey.startsWith('ropilot_')) {
383
- console.error('Invalid API key. Must start with "ropilot_"');
384
- process.exit(1);
385
+ apiKey = await prompt(`Enter your API key${defaultHint}: `);
386
+
387
+ // If empty and existing key, use existing
388
+ if (!apiKey && existingKey) {
389
+ apiKey = existingKey;
390
+ console.log(`Using existing key: ${apiKey.slice(0, 20)}...`);
385
391
  }
392
+ }
386
393
 
387
- setApiKey(apiKey);
388
- console.log('API key saved!');
389
- console.log('');
390
- } else {
391
- console.log(`Using API key: ${apiKey.slice(0, 20)}...`);
392
- console.log('');
394
+ if (!apiKey || !apiKey.startsWith('ropilot_')) {
395
+ console.error('Invalid API key. Must start with "ropilot_"');
396
+ process.exit(1);
393
397
  }
394
398
 
399
+ // Save to project config (.ropilot.json)
400
+ setProjectApiKey(apiKey);
401
+ console.log('API key saved to .ropilot.json');
402
+ console.log('');
403
+
395
404
 
396
405
  // Install Studio plugin
397
406
  await installPlugin();
@@ -425,13 +434,17 @@ export async function update() {
425
434
  console.log('===================');
426
435
  console.log('');
427
436
 
428
- const apiKey = getApiKey();
437
+ // Check project config first, then global
438
+ const projectConfig = loadProjectConfig();
439
+ const apiKey = projectConfig?.apiKey || getApiKey();
440
+
429
441
  if (!apiKey) {
430
442
  console.error('No API key configured. Run "ropilot init" first.');
431
443
  process.exit(1);
432
444
  }
433
445
 
434
- console.log(`Using API key: ${apiKey.slice(0, 20)}...`);
446
+ const source = projectConfig?.apiKey ? '.ropilot.json' : '~/.ropilot/config.json';
447
+ console.log(`Using API key from ${source}: ${apiKey.slice(0, 20)}...`);
435
448
  console.log('');
436
449
 
437
450
  // Re-install Studio plugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ropilot",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "AI-powered Roblox development assistant - MCP CLI",
5
5
  "author": "whut",
6
6
  "license": "MIT",