cloving 0.3.13 → 0.3.15

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/dist/index.js CHANGED
File without changes
@@ -100,7 +100,6 @@ class ChatManager extends StreamManager_1.default {
100
100
  }
101
101
  const trimmedLine = line.trim();
102
102
  if (this.isPastedCode(trimmedLine)) {
103
- console.log('Detected pasted code. Processing as multiline input...');
104
103
  this.multilineInput = trimmedLine;
105
104
  this.isMultilineMode = true;
106
105
  await this.handleCommand(this.multilineInput);
@@ -609,8 +608,8 @@ ${prompt}
609
608
 
610
609
  ### Note
611
610
 
612
- Whenever possible, break up the changes into pieces and make sure every change is in its own CURRENT / NEW block.
613
- Do not allow empty CURRENT blocks and if you add content to the CURRENT block, you also have to add the same content to the NEW block.`;
611
+ Whenever possible, break up the changes into pieces and make sure every change is in its own *CURRENT/NEW* Blocks.
612
+ Do not allow empty CURRENT blocks in *CURRENT/NEW* Blocks and if you add content to the CURRENT block, you also have to add the same content to the NEW block.`;
614
613
  }
615
614
  handleClose() {
616
615
  console.log('Goodbye!');
@@ -146,14 +146,14 @@ class StreamManager extends events_1.EventEmitter {
146
146
  process.stdout.write(colors_1.default.gray.bold(`\`\`\`${language} \n`));
147
147
  process.stdout.write(colors_1.default.gray.bold(`<<<<<<< CURRENT ${currentNewBlock.filePath}\n`));
148
148
  try {
149
- process.stdout.write((0, cli_highlight_1.default)(currentNewBlock.currentContent, { language }));
149
+ process.stdout.write((0, cli_highlight_1.default)(currentNewBlock.currentContent));
150
150
  }
151
151
  catch (error) {
152
152
  process.stdout.write(currentNewBlock.currentContent);
153
153
  }
154
154
  process.stdout.write(colors_1.default.gray.bold('\n=======\n'));
155
155
  try {
156
- process.stdout.write((0, cli_highlight_1.default)(currentNewBlock.newContent, { language }));
156
+ process.stdout.write((0, cli_highlight_1.default)(currentNewBlock.newContent));
157
157
  }
158
158
  catch (error) {
159
159
  process.stdout.write(currentNewBlock.newContent);
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "packageManager": "yarn@1.22.22",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "packageManager": "yarn@1.22.22",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const axios_1 = __importDefault(require("axios"));
7
- class AbstractGPT {
8
- constructor() {
9
- const clovingModel = process.env.CLOVING_MODEL;
10
- this.apiKey = process.env.CLOVING_API_KEY || '';
11
- if (!clovingModel || !this.apiKey) {
12
- throw new Error("CLOVING_MODEL and CLOVING_API_KEY environment variables must be set");
13
- }
14
- const [provider, model] = clovingModel.split(':');
15
- this.provider = provider;
16
- this.model = model;
17
- }
18
- getEndpoint() {
19
- switch (this.provider) {
20
- case 'openai':
21
- return `https://api.openai.com/v1/engines/${this.model}/completions`;
22
- case 'claude':
23
- return `https://api.anthropic.com/v1/claude/${this.model}`;
24
- case 'gpt4all':
25
- return `https://api.gpt4all.io/v1/models/${this.model}/completions`;
26
- default:
27
- throw new Error(`Unsupported provider: ${this.provider}`);
28
- }
29
- }
30
- async generateText(request) {
31
- const endpoint = this.getEndpoint();
32
- const response = await axios_1.default.post(endpoint, {
33
- model: this.model,
34
- prompt: request.prompt,
35
- max_tokens: request.maxTokens || 100,
36
- temperature: request.temperature || 0.7
37
- }, {
38
- headers: {
39
- 'Authorization': `Bearer ${this.apiKey}`,
40
- 'Content-Type': 'application/json'
41
- }
42
- });
43
- switch (this.provider) {
44
- case 'openai':
45
- return response.data.choices[0].text;
46
- case 'claude':
47
- return response.data.completion;
48
- case 'gpt4all':
49
- return response.data.text;
50
- default:
51
- throw new Error(`Unsupported provider: ${this.provider}`);
52
- }
53
- }
54
- }
55
- exports.default = AbstractGPT;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GPT4AllAdapter = void 0;
4
- class GPT4AllAdapter {
5
- constructor(model) {
6
- this.model = model;
7
- }
8
- getEndpoint() {
9
- return `https://api.gpt4all.io/v1/models/${this.model}/completions`;
10
- }
11
- getHeaders(apiKey) {
12
- return {
13
- 'Authorization': `Bearer ${apiKey}`,
14
- 'Content-Type': 'application/json'
15
- };
16
- }
17
- getPayload(request) {
18
- return {
19
- model: this.model,
20
- prompt: request.prompt,
21
- max_tokens: request.maxTokens,
22
- temperature: request.temperature || 0.7
23
- };
24
- }
25
- extractResponse(data) {
26
- return data.text;
27
- }
28
- }
29
- exports.GPT4AllAdapter = GPT4AllAdapter;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const readline_1 = __importDefault(require("readline"));
7
- const child_process_1 = require("child_process");
8
- const git_utils_1 = require("../utils/git_utils");
9
- const model_utils_1 = require("../utils/model_utils");
10
- const cloving_gpt_1 = __importDefault(require("../cloving_gpt"));
11
- const analyze = async () => {
12
- try {
13
- // Define the prompt for analysis
14
- const gitDiff = await (0, git_utils_1.getGitDiff)();
15
- const model = (0, model_utils_1.getModel)();
16
- const prompt = `Explain why the change is being made and document a description of these changes.
17
- Also list any bugs in the new code as well as recommended fixes for those bugs with code examples.
18
-
19
- ${gitDiff}`;
20
- // Instantiate ClovingGPT and get the analysis
21
- const gpt = new cloving_gpt_1.default();
22
- const analysis = await gpt.generateText({ prompt });
23
- // Print the analysis to the console
24
- console.log(analysis);
25
- // Prompt the user to copy the analysis to the clipboard
26
- const rl = readline_1.default.createInterface({
27
- input: process.stdin,
28
- output: process.stdout
29
- });
30
- rl.question('Do you want to copy the analysis to the clipboard? [Y/n] ', (answer) => {
31
- if (answer.toLowerCase() === 'y' || answer === '') {
32
- try {
33
- (0, child_process_1.execFileSync)('pbcopy', { input: analysis });
34
- console.log('Analysis copied to clipboard');
35
- }
36
- catch (error) {
37
- console.error('Error: pbcopy command not found. Unable to copy to clipboard.');
38
- }
39
- }
40
- rl.close();
41
- });
42
- }
43
- catch (error) {
44
- console.error('Error during analysis:', error.message);
45
- }
46
- };
47
- exports.default = analyze;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = (options) => {
4
- if (options.verbose)
5
- console.log('Verbose mode enabled');
6
- console.log('Checking something...');
7
- };
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const path_1 = __importDefault(require("path"));
8
- const child_process_1 = require("child_process");
9
- const git_utils_1 = require("../utils/git_utils");
10
- const string_utils_1 = require("../utils/string_utils");
11
- const config_utils_1 = require("../utils/config_utils");
12
- const cloving_gpt_1 = __importDefault(require("../cloving_gpt"));
13
- const generateAndCommitMessage = async (options) => {
14
- options.silent = (0, config_utils_1.getConfig)(options).globalSilent || false;
15
- const gpt = new cloving_gpt_1.default(options);
16
- try {
17
- // Generate the prompt for commit message
18
- const prompt = (0, git_utils_1.generateCommitMessagePrompt)();
19
- // Instantiate ClovingGPT and get the commit message
20
- const rawCommitMessage = await gpt.generateText({ prompt });
21
- // Clean the commit message using extractMarkdown
22
- const commitMessage = (0, string_utils_1.extractMarkdown)(rawCommitMessage);
23
- // Write the commit message to a temporary file
24
- const tempCommitFilePath = path_1.default.join('.git', 'SUGGESTED_COMMIT_EDITMSG');
25
- fs_1.default.writeFileSync(tempCommitFilePath, commitMessage);
26
- // Commit the changes using the generated commit message
27
- try {
28
- (0, child_process_1.execFileSync)('git', ['commit', '-a', '--edit', '--file', tempCommitFilePath], { stdio: 'inherit' });
29
- }
30
- catch (commitError) {
31
- // If commit is canceled (non-zero exit), handle it here
32
- console.log('Commit was canceled or failed.');
33
- }
34
- // Remove the temporary file using fs
35
- fs_1.default.unlink(tempCommitFilePath, (err) => {
36
- if (err)
37
- throw err;
38
- });
39
- }
40
- catch (error) {
41
- console.error('Could not generate commit message');
42
- }
43
- };
44
- exports.default = generateAndCommitMessage;
@@ -1,235 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.describe = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const os_1 = __importDefault(require("os"));
9
- const path_1 = __importDefault(require("path"));
10
- const child_process_1 = require("child_process");
11
- const string_utils_1 = require("../utils/string_utils");
12
- const cloving_gpt_1 = __importDefault(require("../cloving_gpt"));
13
- const readline_1 = __importDefault(require("readline"));
14
- const ignore_1 = __importDefault(require("ignore"));
15
- // List of special files to check
16
- const specialFiles = [
17
- 'package.json',
18
- 'Gemfile',
19
- 'requirements.txt',
20
- 'Pipfile',
21
- 'pyproject.toml',
22
- 'pom.xml',
23
- 'build.gradle',
24
- '.csproj',
25
- 'packages.config',
26
- 'composer.json',
27
- 'CMakeLists.txt',
28
- 'conanfile.txt',
29
- 'conanfile.py',
30
- 'go.mod',
31
- 'Cargo.toml',
32
- 'Package.swift',
33
- 'build.gradle.kts',
34
- 'Podfile',
35
- 'Cartfile',
36
- 'cpanfile',
37
- 'DESCRIPTION',
38
- 'mix.exs',
39
- 'build.sbt',
40
- 'pubspec.yaml',
41
- 'stack.yaml',
42
- 'cabal.project',
43
- 'Project.toml',
44
- 'rockspec',
45
- 'rebar.config',
46
- 'project.clj'
47
- ];
48
- const runCommand = (command, args) => {
49
- return new Promise((resolve, reject) => {
50
- const process = (0, child_process_1.spawn)(command, args);
51
- const output = [];
52
- process.stdout.on('data', (data) => {
53
- output.push(data.toString());
54
- });
55
- process.stderr.on('data', (data) => {
56
- console.error(`stderr: ${data}`);
57
- });
58
- process.on('close', (code) => {
59
- if (code !== 0) {
60
- reject(new Error(`${command} process exited with code ${code}`));
61
- }
62
- else {
63
- resolve(output.join('').trim().split('\n'));
64
- }
65
- });
66
- });
67
- };
68
- const generateFileList = async () => {
69
- try {
70
- const lsOutput = await runCommand('ls', []);
71
- const findOutput = await runCommand('find', ['.']);
72
- const cleanedFindOutput = findOutput.map(file => file.startsWith('./') ? file.slice(2) : file);
73
- const files = [...lsOutput, ...cleanedFindOutput];
74
- const uniqueFiles = Array.from(new Set(files));
75
- return uniqueFiles.filter(file => file && !file.includes('.git') && !file.includes('node_modules') && !file.includes('tmp'));
76
- }
77
- catch (error) {
78
- console.error('Error generating file list:', error.message);
79
- return [];
80
- }
81
- };
82
- const collectSpecialFileContents = () => {
83
- const specialFileContents = {};
84
- for (const file of specialFiles) {
85
- if (fs_1.default.existsSync(file)) {
86
- try {
87
- const content = fs_1.default.readFileSync(file, 'utf-8');
88
- specialFileContents[file] = file.endsWith('.json') ? JSON.parse(content) : content;
89
- }
90
- catch (error) {
91
- specialFileContents[file] = fs_1.default.readFileSync(file, 'utf-8');
92
- }
93
- }
94
- }
95
- return specialFileContents;
96
- };
97
- // Main function for the describe command
98
- const describe = async () => {
99
- // Generate a temporary file path
100
- const tempFilePath = path_1.default.join(os_1.default.tmpdir(), `describe_${Date.now()}.tmp`);
101
- try {
102
- // Read .gitignore and create ignore instance
103
- const gitignorePath = path_1.default.join(process.cwd(), '.gitignore');
104
- const ig = (0, ignore_1.default)();
105
- if (fs_1.default.existsSync(gitignorePath)) {
106
- const gitignoreContent = fs_1.default.readFileSync(gitignorePath, 'utf-8');
107
- ig.add(gitignoreContent);
108
- }
109
- // Generate the file list excluding .git, node_modules and matching .gitignore patterns
110
- const fileList = await generateFileList();
111
- const filteredFileList = fileList.filter(file => {
112
- try {
113
- return !ig.ignores(file);
114
- }
115
- catch (error) {
116
- return false;
117
- }
118
- });
119
- // Limit the file list to the first 100 files
120
- const limitedFileList = filteredFileList.slice(0, 100);
121
- // Collect the contents of special files
122
- const specialFileContents = collectSpecialFileContents();
123
- // Generate the JSON object for the AI chat model
124
- const projectDetails = {
125
- files: limitedFileList,
126
- specialFiles: specialFileContents
127
- };
128
- const prompt = `Here is a JSON object describing my project:
129
- ${JSON.stringify(projectDetails, null, 2)}
130
-
131
- Please return JSON-formatted metadata about the project, including:
132
- - The programming language(s) used
133
- - The detected framework(s) (if any)
134
- - The version of the language(s)
135
-
136
- Here is an example response:
137
-
138
- {
139
- "languages": [
140
- {
141
- "name": "TypeScript",
142
- "version": "~> 5.5.3"
143
- "primary": true
144
- },
145
- {
146
- "name": "JavaScript",
147
- "version": "ES6+"
148
- }
149
- ],
150
- "frameworks": [
151
- {
152
- "name": "Node.js",
153
- "type": "Runtime environment",
154
- "primary": true
155
- }
156
- ],
157
- "testingFrameworks": [
158
- {
159
- "name": "Jest",
160
- "type": "Testing framework",
161
- "version": "29.7.0"
162
- "directory": "tests"
163
- },
164
- ],
165
- "buildTools": [
166
- {
167
- "name": "TypeScript Compiler (tsc)",
168
- "type": "Transpiler"
169
- },
170
- {
171
- "name": "Vite",
172
- "type": "Build tool",
173
- "version": "5.3.3"
174
- }
175
- ],
176
- "packageManager": "Yarn",
177
- "linters": [
178
- {
179
- "name": "ESLint",
180
- "version": "9.6.0"
181
- }
182
- ],
183
- "databases": [
184
- {
185
- "name": "MongoDB",
186
- "version": "5.0.3",
187
- "primary": true
188
- }
189
- ],
190
- "projectType": "Command-line tool",
191
- }`;
192
- // Estimate and print token count if DEBUG=1
193
- if (process.env.DEBUG === '1') {
194
- (0, string_utils_1.estimateTokens)(prompt).then(tokenCount => {
195
- console.log(`Estimated token count: ${tokenCount}`);
196
- });
197
- }
198
- // Instantiate ClovingGPT and get the AI chat response
199
- const gpt = new cloving_gpt_1.default();
200
- const aiChatResponse = await gpt.generateText({ prompt });
201
- // Write the AI chat response to a temporary file
202
- fs_1.default.writeFileSync(tempFilePath, aiChatResponse);
203
- // Extract JSON metadata from the AI response
204
- const jsonMetadata = (0, string_utils_1.extractJsonMetadata)(aiChatResponse);
205
- if (jsonMetadata) {
206
- console.log(jsonMetadata);
207
- }
208
- else {
209
- console.log(aiChatResponse);
210
- }
211
- const response = jsonMetadata || aiChatResponse;
212
- // Clean up
213
- fs_1.default.unlinkSync(tempFilePath);
214
- // Ask user if they want to save the result to cloving.json
215
- const rl = readline_1.default.createInterface({
216
- input: process.stdin,
217
- output: process.stdout
218
- });
219
- rl.question('Do you want to save this file to cloving.json to improve the context of future cloving requests? [Yn] ', (answer) => {
220
- rl.close();
221
- if (answer.toLowerCase() === 'y' || answer.trim() === '') {
222
- fs_1.default.writeFileSync('cloving.json', response);
223
- console.log('File saved to cloving.json');
224
- }
225
- else {
226
- console.log('File not saved.');
227
- }
228
- });
229
- }
230
- catch (error) {
231
- console.error('Error describing the project:', error.message);
232
- }
233
- };
234
- exports.describe = describe;
235
- exports.default = exports.describe;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const DocumentationManager_1 = __importDefault(require("../../managers/DocumentationManager"));
7
- const documentation = async (options) => {
8
- const documentationManager = new DocumentationManager_1.default(options);
9
- await documentationManager.generateDocumentation();
10
- };
11
- exports.default = documentation;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fizzbuzzCommand = void 0;
7
- const commander_1 = require("commander");
8
- const inquirer_1 = __importDefault(require("inquirer"));
9
- const cli_highlight_1 = __importDefault(require("cli-highlight"));
10
- const copy_paste_1 = __importDefault(require("copy-paste"));
11
- const fizzbuzz_utils_1 = require("../../utils/fizzbuzz_utils");
12
- exports.fizzbuzzCommand = new commander_1.Command('fizzbuzz')
13
- .description('Generate FizzBuzz sequence')
14
- .action(async () => {
15
- const answers = await inquirer_1.default.prompt([
16
- {
17
- type: 'number',
18
- name: 'start',
19
- message: 'Enter the starting number:',
20
- default: 1,
21
- },
22
- {
23
- type: 'number',
24
- name: 'end',
25
- message: 'Enter the ending number:',
26
- default: 100,
27
- },
28
- ]);
29
- const fizzBuzzArray = (0, fizzbuzz_utils_1.generateFizzBuzzArray)(answers.start, answers.end);
30
- const output = fizzBuzzArray.join('\n');
31
- console.log((0, cli_highlight_1.default)(output, { language: 'plaintext', ignoreIllegals: true }));
32
- copy_paste_1.default.copy(output, () => {
33
- console.log('FizzBuzz sequence copied to clipboard!');
34
- });
35
- });
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const cloving_gpt_1 = __importDefault(require("../../cloving_gpt"));
7
- const config_utils_1 = require("../../utils/config_utils");
8
- class InitCommand {
9
- constructor(options) {
10
- this.options = options;
11
- this.chatHistory = [];
12
- options.silent = (0, config_utils_1.getConfig)(options).globalSilent || false;
13
- this.gpt = new cloving_gpt_1.default(options);
14
- }
15
- }
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const inquirer_1 = __importDefault(require("inquirer"));
7
- const cli_highlight_1 = __importDefault(require("cli-highlight"));
8
- const child_process_1 = require("child_process");
9
- const string_utils_1 = require("../../utils/string_utils");
10
- const command_utils_1 = require("../../utils/command_utils");
11
- const config_utils_1 = require("../../utils/config_utils");
12
- const cloving_gpt_1 = __importDefault(require("../../cloving_gpt"));
13
- const generateShellPrompt = (prompt) => {
14
- const shell = (0, child_process_1.execSync)('echo $SHELL').toString().trim();
15
- const os = (0, child_process_1.execSync)('echo $OSTYPE').toString().trim();
16
- return `Generate an executable ${shell} script that works on ${os}. Try to make it a single line if possible and as simple and straightforward as possible.
17
-
18
- Do not add any commentary or context to the message other than the commit message itself.
19
-
20
- An example of the output for this should look like the following:
21
-
22
- \`\`\`sh
23
- find . -type f -name "*.ts" -exec sed -i '' 's/old/new/g' {} +
24
- \`\`\`
25
-
26
- Don't use that script, it is only an example.
27
-
28
- Here is the description of what I want the script to do:
29
-
30
- ${prompt}`;
31
- };
32
- const generateExplainShellPrompt = (prompt) => {
33
- return `${prompt}
34
-
35
- Please briefly explain how this shell script works.`;
36
- };
37
- const sh = async (options) => {
38
- let { prompt } = options;
39
- options.silent = (0, config_utils_1.getConfig)(options).globalSilent || false;
40
- const gpt = new cloving_gpt_1.default(options);
41
- try {
42
- if (!prompt) {
43
- prompt = await (0, command_utils_1.promptUser)('What would you like to do: ');
44
- }
45
- // Generate the prompt for commit message
46
- const shellPrompt = generateShellPrompt(prompt);
47
- // Instantiate ClovingGPT and get the commit message
48
- const rawShellCommand = await gpt.generateText({ prompt: shellPrompt });
49
- // Clean the commit message using extractMarkdown
50
- const generatedShell = (0, string_utils_1.extractMarkdown)(rawShellCommand);
51
- // remove #! from the generated shell script
52
- const generatedShellWithoutShebang = generatedShell.replace(/^#!.*?\s/, '');
53
- console.log((0, cli_highlight_1.default)(generatedShellWithoutShebang));
54
- // Inquirer prompt for further actions
55
- const { action } = await inquirer_1.default.prompt([
56
- {
57
- type: 'list',
58
- name: 'action',
59
- message: 'What would you like to do?',
60
- choices: [
61
- { name: 'Execute', value: 'execute' },
62
- { name: 'Revise', value: 'revise' },
63
- { name: 'Explain', value: 'explain' },
64
- { name: 'Copy to Clipboard', value: 'copy' },
65
- { name: 'Cancel', value: 'cancel' },
66
- ],
67
- },
68
- ]);
69
- switch (action) {
70
- case 'execute':
71
- (0, child_process_1.execSync)(generatedShellWithoutShebang, { stdio: 'inherit' });
72
- break;
73
- case 'revise':
74
- // Logic to revise the prompt (not implemented in this example)
75
- console.log('Revise option selected. Implement revision logic here.');
76
- break;
77
- case 'explain':
78
- const explainPrompt = generateExplainShellPrompt(generatedShellWithoutShebang);
79
- const explainShellCommand = await gpt.generateText({ prompt: explainPrompt });
80
- console.log((0, cli_highlight_1.default)(explainShellCommand, { language: 'markdown' }));
81
- break;
82
- case 'copy':
83
- (0, child_process_1.execFileSync)('pbcopy', { input: generatedShellWithoutShebang });
84
- console.log('Script copied to clipboard.');
85
- break;
86
- case 'cancel':
87
- console.log('Operation cancelled.');
88
- break;
89
- }
90
- }
91
- catch (error) {
92
- console.error('Could not generate shell script');
93
- }
94
- };
95
- exports.default = sh;