void-cmd
Version:
AI-powered CLI tool that converts natural language to shell commands using Cerebras API
102 lines • 4.22 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SettingsCommand = void 0;
const utils_1 = require("../utils");
const config_1 = require("../config");
const readline = __importStar(require("readline"));
class SettingsCommand {
constructor() {
this.name = 'settings';
this.description = 'Configure API key and other settings';
}
async execute(_options) {
try {
await this.configureSettings();
}
catch (error) {
(0, utils_1.errorHandler)(error);
}
}
async configureSettings() {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const question = (prompt) => {
return new Promise((resolve) => {
rl.question(prompt, resolve);
});
};
try {
(0, utils_1.log)('\n⚙️ VCMD Settings Configuration');
(0, utils_1.log)('===============================\n');
const currentSettings = (0, config_1.loadSettings)();
if (currentSettings.apiKey) {
(0, utils_1.log)(`Current API Key: ${currentSettings.apiKey.substring(0, 8)}...`);
(0, utils_1.log)(`Current Base URL: ${currentSettings.baseUrl || 'https://api.cerebras.ai/v1'}`);
(0, utils_1.log)(`Current Model: ${currentSettings.model || 'llama-4-scout-17b-16e-instruct'}\n`);
}
const apiKey = await question('Enter your Cerebras API Key (starts with csk-): ');
if (!apiKey.trim()) {
(0, utils_1.log)('❌ API Key is required!');
return;
}
if (!apiKey.startsWith('csk-')) {
(0, utils_1.log)('⚠️ Warning: API Key should start with "csk-"');
}
const baseUrl = await question(`Enter Base URL (default: https://api.cerebras.ai/v1): `);
const model = await question(`Enter Model (default: llama-4-scout-17b-16e-instruct): `);
const settings = {
apiKey: apiKey.trim(),
baseUrl: baseUrl.trim() || 'https://api.cerebras.ai/v1',
model: model.trim() || 'llama-4-scout-17b-16e-instruct'
};
(0, config_1.saveSettings)(settings);
(0, utils_1.log)('\n✅ Settings saved successfully!');
(0, utils_1.log)(`Settings file: ${(0, config_1.getSettingsFilePath)()}`);
(0, utils_1.log)('\nYou can now use: vcmd can you [your request]');
}
catch (error) {
(0, utils_1.log)('\n❌ Failed to configure settings');
throw error;
}
finally {
rl.close();
}
}
}
exports.SettingsCommand = SettingsCommand;
//# sourceMappingURL=settings.js.map