mirror of
https://github.com/tcsenpai/vvk.git
synced 2025-06-09 20:47:30 +00:00
setup
This commit is contained in:
parent
3157e4e0dd
commit
8fa8e6e623
8
.prettierrc
Normal file
8
.prettierrc
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 120,
|
||||||
|
"singleQuote": true,
|
||||||
|
"useTabs": false,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"semi": true,
|
||||||
|
"bracketSpacing": true
|
||||||
|
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Matyi Kari
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
75
README.md
Normal file
75
README.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
# zzk
|
||||||
|
|
||||||
|
A command-line interface tool that converts natural language instructions into shell commands using OpenAI's GPT-4.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm add -g zzk
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Before using this tool, you need to:
|
||||||
|
|
||||||
|
1. Have an OpenAI API key
|
||||||
|
2. Create a `.env` file in your project root with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
OPENAI_API_KEY=your_api_key_here
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
zzk <your natural language command>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# List all files in the current directory
|
||||||
|
zzk show me all files in this folder
|
||||||
|
|
||||||
|
# Find large files
|
||||||
|
zzk find files larger than 100MB
|
||||||
|
|
||||||
|
# Search for text in files
|
||||||
|
zzk search for "hello world" in all javascript files
|
||||||
|
```
|
||||||
|
|
||||||
|
The tool will:
|
||||||
|
|
||||||
|
1. Process your natural language input
|
||||||
|
2. Generate an appropriate shell command
|
||||||
|
3. Show you the command for confirmation
|
||||||
|
4. Execute the command upon your approval
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
To set up the development environment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Clone the repository
|
||||||
|
git clone [your-repo-url]
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
pnpm build
|
||||||
|
|
||||||
|
# Create a global link
|
||||||
|
pnpm link --global
|
||||||
|
|
||||||
|
# Now you can use the development version globally
|
||||||
|
zzk <command>
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT License - see LICENSE file for details
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
13
package.json
13
package.json
@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "zzk",
|
"name": "zzk",
|
||||||
"version": "0.0.1",
|
"version": "0.1.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rimraf dist && webpack",
|
"build": "rimraf dist && webpack"
|
||||||
"start": "node -r dotenv/config dist/index.js",
|
},
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"bin": {
|
||||||
|
"zzk": "dist/index.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "Matyi Kari",
|
||||||
"license": "ISC",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.13.5",
|
"@types/node": "^22.13.5",
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
|
11
src/index.ts
11
src/index.ts
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { config } from 'dotenv';
|
import { config } from 'dotenv';
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import OpenAI from 'openai';
|
import OpenAI from 'openai';
|
||||||
@ -25,7 +27,7 @@ if (!userInput) {
|
|||||||
function confirmExecution(command: string) {
|
function confirmExecution(command: string) {
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout
|
output: process.stdout,
|
||||||
});
|
});
|
||||||
|
|
||||||
rl.question(`\nRun this command? [y/N]: ${command} `, (answer) => {
|
rl.question(`\nRun this command? [y/N]: ${command} `, (answer) => {
|
||||||
@ -60,11 +62,10 @@ async function processCommand(input: string) {
|
|||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: 'system',
|
role: 'system',
|
||||||
content:
|
content: "Convert the user's request into a shell command without explanation.",
|
||||||
"Convert the user's request into a shell command without explanation."
|
|
||||||
},
|
},
|
||||||
{ role: 'user', content: input }
|
{ role: 'user', content: input },
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const command = response.choices[0]?.message?.content?.trim();
|
const command = response.choices[0]?.message?.content?.trim();
|
||||||
|
@ -6,18 +6,18 @@ module.exports = {
|
|||||||
mode: 'production',
|
mode: 'production',
|
||||||
output: {
|
output: {
|
||||||
filename: 'index.js',
|
filename: 'index.js',
|
||||||
path: path.resolve(__dirname, 'dist')
|
path: path.resolve(__dirname, 'dist'),
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.ts', '.js']
|
extensions: ['.ts', '.js'],
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.ts$/,
|
test: /\.ts$/,
|
||||||
use: 'ts-loader',
|
use: 'ts-loader',
|
||||||
exclude: /node_modules/
|
exclude: /node_modules/,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user