This commit is contained in:
Matyi Kari 2025-03-06 09:52:39 -06:00
parent 8c4d3768be
commit f92c96be1d
10 changed files with 873 additions and 62 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

4
.gitignore vendored
View File

@ -4,4 +4,6 @@ dist
*.app *.app
*.exe *.exe
*.pkg *.pkg
*.blob *.blob
pkg-root
uninstall-scripts

1
.husky/pre-commit Normal file
View File

@ -0,0 +1 @@
pnpm lint

View File

@ -68,7 +68,7 @@ pnpm remove -g vvk
Use the `vvk config set` command to configure your settings: Use the `vvk config set` command to configure your settings:
```bash ```bash
# Set your OpenAI API key # If using your own Openai API key, set it in the config
vvk config set openaiApiKey your_api_key_here vvk config set openaiApiKey your_api_key_here
# Enable or disable command confirmation (default: true) # Enable or disable command confirmation (default: true)
@ -86,7 +86,7 @@ vvk config list
## **Login** ## **Login**
Use the `vvk login` command to log in in the browser: If using VVK Cloud, use the `vvk login` command to log in through the browser
```bash ```bash
# Sets the key and userId values # Sets the key and userId values

11
eslint.config.mjs Normal file
View File

@ -0,0 +1,11 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
/** @type {import('eslint').Linter.Config[]} */
export default [
{ files: ['**/*.{js,mjs,cjs,ts}'] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];

View File

@ -1,10 +1,13 @@
{ {
"name": "vvk", "name": "vvk",
"version": "1.1.1", "version": "1.1.2",
"description": "A command-line interface tool that converts natural language instructions into shell commands using OpenAI's GPT-4.", "description": "A command-line interface tool that converts natural language instructions into shell commands using OpenAI's GPT-4.",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"build": "rimraf dist && webpack" "build": "rimraf dist && webpack",
"lint": "eslint src/**",
"lint:fix": "eslint src/** --fix",
"prepare": "husky"
}, },
"bin": { "bin": {
"vvk": "dist/index.js" "vvk": "dist/index.js"
@ -15,19 +18,29 @@
"LICENSE" "LICENSE"
], ],
"keywords": [], "keywords": [],
"author": "Matyi Kari", "author": "Matyi Kari <matykari@gmail.com>",
"license": "MIT", "license": "MIT",
"homepage": "https://vvk.ai",
"bugs": {
"url": "https://github.com/matyik/vvk/issues",
"email": "matykari@gmail.com"
},
"devDependencies": { "devDependencies": {
"@types/node": "^22.13.5", "@eslint/js": "^9.21.0",
"@types/node": "^22.13.9",
"eslint": "^9.21.0",
"globals": "^16.0.0",
"husky": "^9.1.7",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"ts-loader": "^9.5.2", "ts-loader": "^9.5.2",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.7.3", "typescript": "^5.8.2",
"typescript-eslint": "^8.26.0",
"webpack": "^5.98.0", "webpack": "^5.98.0",
"webpack-cli": "^6.0.1" "webpack-cli": "^6.0.1"
}, },
"dependencies": { "dependencies": {
"axios": "^1.8.1", "axios": "^1.8.1",
"openai": "^4.85.4" "openai": "^4.86.2"
} }
} }

873
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -11,14 +11,14 @@ export function configCommand(args: string[]) {
process.exit(1); process.exit(1);
} }
// For boolean fields, parse the value // For boolean fields, parse the value
let parsedValue: any = value; let parsedValue: string | boolean = value;
if (key === 'confirmCommand') { if (key === 'confirmCommand') {
parsedValue = value.toLowerCase() === 'true' || value.toLowerCase() === 'y'; parsedValue = value.toLowerCase() === 'true' || value.toLowerCase() === 'y';
} }
const updated = updateConfig({ [key]: parsedValue }); const updated = updateConfig({ [key]: parsedValue });
console.log('Configuration updated:', updated); console.log('Configuration updated:', updated);
} else if (command === 'get' || command === 'list') { } else if (command === 'get' || command === 'list') {
let config = loadConfig(); const config = loadConfig();
if (config.key && config.key.length > 0) { if (config.key && config.key.length > 0) {
config.key = '********'; config.key = '********';
} }

View File

@ -29,7 +29,7 @@ if (args[0] === 'config') {
`); `);
process.exit(0); process.exit(0);
} else if ((args[0] === '--version' || args[0] === '-v') && args.length === 1) { } else if ((args[0] === '--version' || args[0] === '-v') && args.length === 1) {
console.log('1.1.1'); console.log('1.1.2');
} else if (args[0] === 'login' && args.length === 1) { } else if (args[0] === 'login' && args.length === 1) {
login(); login();
} else if (args[0] === 'logout' && args.length === 1) { } else if (args[0] === 'logout' && args.length === 1) {
@ -78,6 +78,7 @@ function confirmExecution(command: string) {
} }
} else if (normalized === 'y') { } else if (normalized === 'y') {
executeCommand(command); executeCommand(command);
process.exit(0);
} else { } else {
console.log('Command execution canceled.'); console.log('Command execution canceled.');
process.exit(0); process.exit(0);

View File

@ -43,7 +43,7 @@ export async function login() {
key = data.key; key = data.key;
userId = data.userId; userId = data.userId;
} }
} catch (err) { } catch {
// Ignore errors while waiting // Ignore errors while waiting
} }
} }
@ -59,8 +59,12 @@ export async function logout() {
updateConfig({ key: '', userId: '' }); updateConfig({ key: '', userId: '' });
console.log('✅ Logged out successfully!'); console.log('✅ Logged out successfully!');
process.exit(0); process.exit(0);
} catch (err: any) { } catch (err: unknown) {
console.error('❌ Error during logout:', err.message); if (err instanceof Error) {
console.error('❌ Error during logout:', err.message);
} else {
console.error('❌ Error during logout:', err);
}
process.exit(1); process.exit(1);
} }
} }