cloving 0.3.16 → 0.3.18

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.
Files changed (35) hide show
  1. package/dist/abstract_gpt/index.js +55 -0
  2. package/dist/cloving_gpt/adapters/Adapter.js +2 -0
  3. package/dist/cloving_gpt/adapters/gpt4all.js +29 -0
  4. package/dist/commands/analyze.js +47 -0
  5. package/dist/commands/check.js +7 -0
  6. package/dist/commands/commit.js +44 -0
  7. package/dist/commands/describe.js +235 -0
  8. package/dist/commands/generate/context.js +1 -1
  9. package/dist/commands/generate/documentation.js +11 -0
  10. package/dist/commands/generate/fizzbuzz.js +35 -0
  11. package/dist/commands/generate/init.js +15 -0
  12. package/dist/commands/generate/sh.js +95 -0
  13. package/dist/commands/project/build.js +88 -0
  14. package/dist/commands/project/complete.js +12 -0
  15. package/dist/commands/project/init.js +82 -0
  16. package/dist/commands/project/plan.js +108 -0
  17. package/dist/commands/review.js +50 -0
  18. package/dist/commands/tokens.js +1 -1
  19. package/dist/commands/unit_tests.js +150 -0
  20. package/dist/commands/update.js +7 -0
  21. package/dist/file2.js +4 -0
  22. package/dist/index.js +0 -0
  23. package/dist/managers/DocumentationManager.js +114 -0
  24. package/dist/managers/ProxyManager.js +9 -2
  25. package/dist/managers/StreamManager.js +1 -1
  26. package/dist/managers/src/managers/ProxyManager.js +1 -0
  27. package/dist/newfile.js +2 -0
  28. package/dist/package.json +26 -26
  29. package/dist/utils/command_utils.js +384 -0
  30. package/dist/utils/config_utils.js +21 -4
  31. package/dist/utils/gitUtils.js +42 -0
  32. package/dist/utils/git_utils.js +109 -7
  33. package/dist/utils/modelUtils.js +7 -0
  34. package/dist/utils/prompt_utils.js +3 -3
  35. package/package.json +26 -26
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ const newContent = 'This is new';
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "packageManager": "yarn@1.22.22",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,43 +39,43 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@inquirer/prompts": "^5.3.8",
43
- "axios": "^1.7.3",
42
+ "@inquirer/prompts": "^7.3.2",
43
+ "axios": "^1.7.9",
44
44
  "cli-highlight": "^2.1.11",
45
45
  "colors": "^1.4.0",
46
- "commander": "^12.1.0",
46
+ "commander": "^13.1.0",
47
47
  "copy-paste": "^1.5.3",
48
- "eslint": "^8.57.0",
49
- "eslint-config-prettier": "^9.1.0",
48
+ "eslint": "^9.20.1",
49
+ "eslint-config-prettier": "^10.0.1",
50
50
  "eslint-config-raine": "^0.5.0",
51
51
  "eslint-config-standard": "^17.1.0",
52
- "eslint-plugin-import": "^2.29.1",
53
- "eslint-plugin-jsdoc": "^50.1.0",
54
- "eslint-plugin-n": "^16.6.2",
55
- "eslint-plugin-promise": "^6.6.0",
56
- "express": "^4.19.2",
57
- "ignore": "^5.3.2",
58
- "ini": "^4.1.3",
59
- "isbinaryfile": "^5.0.2",
60
- "nock": "^13.5.4",
61
- "vite": "^5.4.0",
62
- "vite-node": "^2.0.5"
52
+ "eslint-plugin-import": "^2.31.0",
53
+ "eslint-plugin-jsdoc": "^50.6.3",
54
+ "eslint-plugin-n": "^17.15.1",
55
+ "eslint-plugin-promise": "^7.2.1",
56
+ "express": "^4.21.2",
57
+ "ignore": "^7.0.3",
58
+ "ini": "^5.0.0",
59
+ "isbinaryfile": "^5.0.4",
60
+ "nock": "^14.0.1",
61
+ "vite": "^6.1.1",
62
+ "vite-node": "^3.0.6"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/body-parser": "^1.19.5",
66
66
  "@types/copy-paste": "^1.1.33",
67
- "@types/express": "^4.17.21",
67
+ "@types/express": "^5.0.0",
68
68
  "@types/ini": "^4.1.1",
69
69
  "@types/inquirer": "^9.0.7",
70
- "@types/jest": "^29.5.12",
71
- "@types/node": "^22.2.0",
72
- "husky": "^9.1.4",
70
+ "@types/jest": "^29.5.14",
71
+ "@types/node": "^22.13.4",
72
+ "husky": "^9.1.7",
73
73
  "jest": "^29.7.0",
74
- "lint-prepush": "^2.2.2",
75
- "lint-staged": "^15.2.9",
76
- "prettier": "^3.2.5",
77
- "ts-jest": "^29.2.4",
78
- "typescript": "^5.5.4"
74
+ "lint-prepush": "^3.0.2",
75
+ "lint-staged": "^15.4.3",
76
+ "prettier": "^3.5.1",
77
+ "ts-jest": "^29.2.5",
78
+ "typescript": "^5.7.3"
79
79
  },
80
80
  "resolutions": {
81
81
  "eslint": "8.57.0",
@@ -0,0 +1,384 @@
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.addFileOrDirectoryToContext = exports.readFileContent = exports.fetchModels = exports.runCommand = exports.generateFileList = exports.getAllFilesInDirectory = exports.checkForSpecialFiles = exports.collectSpecialFileContents = exports.generateShellPrompt = exports.generateCodegenPrompt = exports.getPackageVersion = exports.SPECIAL_FILES = exports.CODEGEN_INSTRUCTIONS = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const child_process_1 = require("child_process");
10
+ const isbinaryfile_1 = require("isbinaryfile");
11
+ const colors_1 = __importDefault(require("colors"));
12
+ const path_2 = require("path");
13
+ const config_utils_1 = require("./config_utils");
14
+ exports.CODEGEN_INSTRUCTIONS = `## AI Code Generation Instructions
15
+
16
+ ### General Guidelines
17
+
18
+ 1. **Respond as an expert software developer.**
19
+ 2. **Follow best practices and the latest standards found in the **Description of App** section.**
20
+ 3. **Adhere to existing conventions and libraries in the codebase.**
21
+
22
+ ### Request Handling
23
+
24
+ 1. **Try to understand the request, but if anything is unclear, ask questions.**
25
+ 2. **Decide if you need to propose edits to existing files not in the chat.**
26
+ - If yes, provide the full path names and ask the user to add them.
27
+ - Wait for user approval before proceeding.
28
+ 3. **Propose changes using *CURRENT/NEW* Blocks.**
29
+ 4. **Show the smallest possible *CURRENT* section that uniquely identifies the code.**
30
+ 5. **To move code, use two *CURRENT/NEW* blocks: one to remove and one to add.**
31
+ 6. **For new files or to replace an existing file, the *CURRENT* block is empty.**
32
+
33
+ ### *CURRENT/NEW* Block Format
34
+
35
+ 1. **Start a block with three backticks and the language name.**
36
+ \`\`\`typescript
37
+ 2. **Next line: seven <, CURRENT, and the file path.**
38
+ <<<<<<< CURRENT path/to/file.ts
39
+ 3. **Include the exact existing code to be changed.**
40
+ 4. **Divide with seven =.**
41
+ =======
42
+ 5. **Add the new code.**
43
+ 6. **End with seven > and NEW.**
44
+ >>>>>>> NEW
45
+ 7. **Close the block with three backticks.**
46
+ \`\`\``;
47
+ exports.SPECIAL_FILES = [
48
+ 'package.json',
49
+ 'Gemfile',
50
+ 'requirements.txt',
51
+ 'Pipfile',
52
+ 'pyproject.toml',
53
+ 'pom.xml',
54
+ 'build.gradle',
55
+ '.csproj',
56
+ 'packages.config',
57
+ 'composer.json',
58
+ 'CMakeLists.txt',
59
+ 'conanfile.txt',
60
+ 'conanfile.py',
61
+ 'go.mod',
62
+ 'Cargo.toml',
63
+ 'Package.swift',
64
+ 'build.gradle.kts',
65
+ 'Podfile',
66
+ 'Cartfile',
67
+ 'cpanfile',
68
+ 'DESCRIPTION',
69
+ 'mix.exs',
70
+ 'build.sbt',
71
+ 'pubspec.yaml',
72
+ 'stack.yaml',
73
+ 'cabal.project',
74
+ 'Project.toml',
75
+ 'rockspec',
76
+ 'rebar.config',
77
+ 'project.clj',
78
+ 'tsconfig.json',
79
+ '.eslintrc.js',
80
+ '.eslintrc.json',
81
+ '.eslintrc.yaml',
82
+ '.eslintrc.yml',
83
+ '.eslintrc',
84
+ '.prettierrc',
85
+ '.prettierrc.js',
86
+ '.prettierrc.json',
87
+ '.prettierrc.yaml',
88
+ '.prettierrc.yml',
89
+ '.prettierrc',
90
+ '.stylelintrc',
91
+ '.stylelintrc.json',
92
+ '.stylelintrc.yaml',
93
+ '.stylelintrc.yml',
94
+ '.stylelintrc',
95
+ 'jest.config.js',
96
+ 'jest.config.json',
97
+ 'jest.config.ts',
98
+ 'jest.config.cjs',
99
+ 'jest.config.mjs',
100
+ 'webpack.config.js',
101
+ 'webpack.config.ts',
102
+ 'webpack.config.cjs',
103
+ 'webpack.config.mjs',
104
+ 'webpack.config.common.js',
105
+ ];
106
+ const getPackageVersion = () => {
107
+ const packagePath = (0, path_2.join)(__dirname, '..', 'package.json');
108
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packagePath, 'utf8'));
109
+ return packageJson.version;
110
+ };
111
+ exports.getPackageVersion = getPackageVersion;
112
+ const renderAsString = (contextFile) => {
113
+ if (typeof contextFile === 'string') {
114
+ return contextFile;
115
+ }
116
+ return JSON.stringify(contextFile, null, 2);
117
+ };
118
+ const generateCodegenPrompt = (contextFilesContent) => {
119
+ const specialFileContents = (0, exports.collectSpecialFileContents)();
120
+ // detect if specialFileContents[file] is a string or an object
121
+ const specialFiles = Object.keys(specialFileContents)
122
+ .map((file) => `### Contents of **${file}**\n\n\`\`\`\n${renderAsString(specialFileContents[file])}\n\`\`\`\n\n`)
123
+ .join('\n');
124
+ const contextFileContents = Object.keys(contextFilesContent)
125
+ .map((file) => `### Contents of **${file}**\n\n\`\`\`\n${contextFilesContent[file]}\n\`\`\`\n\n`)
126
+ .join('\n');
127
+ const prompt = `${exports.CODEGEN_INSTRUCTIONS}
128
+
129
+ ## Description of App
130
+
131
+ \`\`\`json
132
+ ${JSON.stringify((0, config_utils_1.getClovingConfig)(), null, 2)}
133
+ \`\`\`
134
+
135
+ ## Special Files
136
+
137
+ ${specialFiles.length > 0 ? specialFiles : 'No special files provided.'}
138
+
139
+ ## Context Files
140
+
141
+ ${contextFileContents.length > 0 ? contextFileContents : 'No context files provided.'}
142
+
143
+ ## Directory structure
144
+
145
+ ${Object.keys(contextFilesContent).join('\n')}
146
+
147
+ ${exports.CODEGEN_INSTRUCTIONS}
148
+
149
+ ### Example 1: Changing a Variable
150
+
151
+ \`\`\`typescript
152
+ <<<<<<< CURRENT path/to/file.ts
153
+ const myVariable = 'exact'
154
+ const oldVariable = 1
155
+ =======
156
+ const myVariable = 'exact'
157
+ const newVariable = 2
158
+ >>>>>>> NEW
159
+ \`\`\`
160
+
161
+ ### Example 2: Create a New File
162
+
163
+ \`\`\`ruby
164
+ <<<<<<< CURRENT path/to/newfile.rb
165
+ =======
166
+ def new_function
167
+ puts 'Hello, world!'
168
+ end
169
+ >>>>>>> NEW
170
+ \`\`\`
171
+
172
+ ### Example 3: Moving a Function
173
+
174
+ Removing it from path/to/file.py
175
+
176
+ \`\`\`python
177
+ <<<<<<< CURRENT path/to/file.py
178
+ def old_function():
179
+ return 'Old function'
180
+ =======
181
+ >>>>>>> NEW
182
+ \`\`\`
183
+
184
+ Adding it to path/to/newfile.py
185
+
186
+ \`\`\`python
187
+ <<<<<<< CURRENT path/to/newfile.py
188
+ def existing_function():
189
+ return 'Existing function'
190
+
191
+ =======
192
+ def existing_function():
193
+ return 'Existing function'
194
+
195
+ def old_function():
196
+ return 'Old function'
197
+ >>>>>>> NEW
198
+ \`\`\`
199
+
200
+ ### Example 4: Removing a Function
201
+
202
+ \`\`\`java
203
+ <<<<<<< CURRENT path/to/file.java
204
+ public void oldFunction() {
205
+ System.out.println("Old function")
206
+ }
207
+ =======
208
+ >>>>>>> NEW
209
+ \`\`\`
210
+
211
+ ### Example 5: Replace a file
212
+
213
+ This will replace the entire contents of **path/to/file.rb** with the new content:
214
+
215
+ \`\`\`ruby
216
+ <<<<<<< CURRENT path/to/file.rb
217
+ =======
218
+ def new_function
219
+ puts 'Hello, world!'
220
+ end
221
+ >>>>>>> NEW
222
+ \`\`\`
223
+
224
+ ## Don't Invent Code That Isn't Provided in Context
225
+
226
+ A file might be referenced by just the file name without the full path, but the code must be provided in the *Context Files* section.
227
+
228
+ Unless you believe you are creating a whole new file, never ever under any circumstances make up code in the CURRENT block that was not provided to you in the *Context Files* section.
229
+
230
+ If a required file hasn't been provided in the *Context Files* section, stop everything and ask the user to provide it in the context by adding -f path/to/file to the command or add path/to/file in the interactive chat.`;
231
+ return prompt;
232
+ };
233
+ exports.generateCodegenPrompt = generateCodegenPrompt;
234
+ const generateShellPrompt = () => {
235
+ const shell = (0, child_process_1.execSync)('echo $SHELL').toString().trim();
236
+ const os = (0, child_process_1.execSync)('echo $OSTYPE').toString().trim();
237
+ 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.
238
+
239
+ Do not add any commentary or context to the message other than the commit message itself.
240
+
241
+ An example of the output for this should look like the following:
242
+
243
+ \`\`\`sh
244
+ find . -type f -name "*.ts" -exec sed -i '' 's/old/new/g' {} +
245
+ \`\`\`
246
+
247
+ Don't use that script, it is only an example.`;
248
+ };
249
+ exports.generateShellPrompt = generateShellPrompt;
250
+ const collectSpecialFileContents = () => {
251
+ const specialFileContents = {};
252
+ for (const file of exports.SPECIAL_FILES) {
253
+ if (fs_1.default.existsSync(file)) {
254
+ try {
255
+ const content = fs_1.default.readFileSync(file, 'utf-8');
256
+ specialFileContents[file] = file.endsWith('.json') ? JSON.parse(content) : content;
257
+ }
258
+ catch (error) {
259
+ specialFileContents[file] = fs_1.default.readFileSync(file, 'utf-8');
260
+ }
261
+ }
262
+ }
263
+ return specialFileContents;
264
+ };
265
+ exports.collectSpecialFileContents = collectSpecialFileContents;
266
+ const checkForSpecialFiles = () => exports.SPECIAL_FILES.some((file) => fs_1.default.existsSync(file));
267
+ exports.checkForSpecialFiles = checkForSpecialFiles;
268
+ const getAllFilesInDirectory = async (dir) => {
269
+ const subdirs = await fs_1.default.promises.readdir(dir);
270
+ const files = await Promise.all(subdirs.map(async (subdir) => {
271
+ const res = path_1.default.resolve(dir, subdir);
272
+ if (subdir === 'node_modules' || subdir === '.git' || subdir === '.DS_Store') {
273
+ return [];
274
+ }
275
+ const stat = await fs_1.default.promises.stat(res);
276
+ if (stat.isDirectory()) {
277
+ return (0, exports.getAllFilesInDirectory)(res);
278
+ }
279
+ else {
280
+ const isBinary = await (0, isbinaryfile_1.isBinaryFile)(res);
281
+ return isBinary ? [] : res;
282
+ }
283
+ }));
284
+ return files.flat();
285
+ };
286
+ exports.getAllFilesInDirectory = getAllFilesInDirectory;
287
+ const generateFileList = async () => {
288
+ try {
289
+ const lsOutput = await (0, exports.runCommand)('ls', []);
290
+ const findOutput = await (0, exports.runCommand)('find', ['.']);
291
+ const cleanedFindOutput = findOutput.map((file) => file.startsWith('./') ? file.slice(2) : file);
292
+ const files = [...lsOutput, ...cleanedFindOutput];
293
+ const uniqueFiles = Array.from(new Set(files));
294
+ return uniqueFiles.filter((file) => file && !file.includes('.git') && !file.includes('node_modules') && !file.includes('tmp'));
295
+ }
296
+ catch (error) {
297
+ console.error('Error generating file list:', error.message);
298
+ return [];
299
+ }
300
+ };
301
+ exports.generateFileList = generateFileList;
302
+ const runCommand = (command, args) => {
303
+ return new Promise((resolve, reject) => {
304
+ const process = (0, child_process_1.spawn)(command, args);
305
+ const output = [];
306
+ process.stdout.on('data', (data) => {
307
+ output.push(data.toString());
308
+ });
309
+ process.stderr.on('data', (data) => {
310
+ console.error(`stderr: ${data}`);
311
+ });
312
+ process.on('close', (code) => {
313
+ if (code !== 0) {
314
+ reject(new Error(`${command} process exited with code ${code}`));
315
+ }
316
+ else {
317
+ resolve(output.join('').trim().split('\n'));
318
+ }
319
+ });
320
+ });
321
+ };
322
+ exports.runCommand = runCommand;
323
+ const fetchModels = async () => {
324
+ try {
325
+ const modelsOutput = await (0, exports.runCommand)('cloving', ['models']);
326
+ return modelsOutput;
327
+ }
328
+ catch (error) {
329
+ console.error('Error fetching models:', error.message);
330
+ return [];
331
+ }
332
+ };
333
+ exports.fetchModels = fetchModels;
334
+ const readFileContent = (file) => {
335
+ try {
336
+ return fs_1.default.readFileSync(file, 'utf-8');
337
+ }
338
+ catch (error) {
339
+ console.error('Error reading file content:', error.message);
340
+ return '';
341
+ }
342
+ };
343
+ exports.readFileContent = readFileContent;
344
+ const addFileToContext = async (filePath, contextFiles, baseDir) => {
345
+ const relativePath = path_1.default.relative(baseDir, filePath);
346
+ if (await (0, isbinaryfile_1.isBinaryFile)(filePath)) {
347
+ return;
348
+ }
349
+ const content = await fs_1.default.promises.readFile(filePath, 'utf-8');
350
+ contextFiles[relativePath] = content;
351
+ };
352
+ const addDirectoryToContext = async (dirPath, contextFiles, baseDir) => {
353
+ const entries = await fs_1.default.promises.readdir(dirPath, { withFileTypes: true });
354
+ for (const entry of entries) {
355
+ const fullPath = path_1.default.join(dirPath, entry.name);
356
+ if (entry.isDirectory()) {
357
+ if (entry.name !== 'node_modules' && entry.name !== '.git') {
358
+ await addDirectoryToContext(fullPath, contextFiles, baseDir);
359
+ }
360
+ }
361
+ else {
362
+ await addFileToContext(fullPath, contextFiles, baseDir);
363
+ }
364
+ }
365
+ };
366
+ const addFileOrDirectoryToContext = async (contextFile, contextFiles, options) => {
367
+ const filePath = path_1.default.resolve(contextFile);
368
+ const baseDir = process.cwd();
369
+ try {
370
+ const stats = await fs_1.default.promises.stat(filePath);
371
+ if (stats.isDirectory()) {
372
+ await addDirectoryToContext(filePath, contextFiles, baseDir);
373
+ }
374
+ else if (stats.isFile()) {
375
+ await addFileToContext(filePath, contextFiles, baseDir);
376
+ }
377
+ }
378
+ catch (error) {
379
+ console.error(colors_1.default.red(`${colors_1.default.bold('Error')}: File or directory "${contextFile}" does not exist`));
380
+ process.exit(1);
381
+ }
382
+ return contextFiles;
383
+ };
384
+ exports.addFileOrDirectoryToContext = addFileOrDirectoryToContext;
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getTestingDirectory = exports.getAllFiles = exports.removeProjectConfig = exports.saveProjectConfig = exports.getProjectConfig = exports.getPrimaryModel = exports.saveConfig = exports.getClovingConfig = exports.getConfig = exports.CLOVINGPROJECT_PATH = exports.CLOVINGFILE_PATH = exports.CLOVING_CONFIG_PATH = void 0;
10
+ exports.getTestingDirectory = exports.getAllFiles = exports.removeProjectConfig = exports.saveProjectConfig = exports.getProjectConfig = exports.getPrimaryModel = exports.saveConfig = exports.getNearestClovingConfig = exports.getClovingConfig = exports.getConfig = exports.CLOVINGPROJECT_PATH = exports.CLOVINGFILE_PATH = exports.CLOVING_CONFIG_PATH = void 0;
11
11
  const os_1 = __importDefault(require("os"));
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const fs_1 = __importDefault(require("fs"));
@@ -86,8 +86,7 @@ const getClovingConfig = () => {
86
86
  return clovingConfig;
87
87
  }
88
88
  else if (fs_1.default.existsSync(exports.CLOVINGFILE_PATH)) {
89
- const configFile = fs_1.default.readFileSync(exports.CLOVINGFILE_PATH, 'utf-8');
90
- clovingConfig = JSON.parse(configFile);
89
+ clovingConfig = getClovingConfigAtPath(exports.CLOVINGFILE_PATH);
91
90
  return clovingConfig;
92
91
  }
93
92
  else {
@@ -96,6 +95,24 @@ const getClovingConfig = () => {
96
95
  }
97
96
  };
98
97
  exports.getClovingConfig = getClovingConfig;
98
+ const getClovingConfigAtPath = (fullPath) => {
99
+ const configFile = fs_1.default.readFileSync(fullPath, 'utf-8');
100
+ return JSON.parse(configFile);
101
+ };
102
+ const getNearestClovingConfig = () => {
103
+ let runPath = process.cwd();
104
+ const parts = runPath.split(path_1.default.sep);
105
+ while (parts.length > 0) {
106
+ const configPath = path_1.default.join(parts.join(path_1.default.sep), exports.CLOVINGFILE_PATH);
107
+ if (fs_1.default.existsSync(configPath)) {
108
+ clovingConfig = getClovingConfigAtPath(configPath);
109
+ return { config: clovingConfig, path: configPath };
110
+ }
111
+ parts.pop();
112
+ }
113
+ throw new Error(`No ${exports.CLOVINGFILE_PATH} file found in ${runPath} or any parent directory`);
114
+ };
115
+ exports.getNearestClovingConfig = getNearestClovingConfig;
99
116
  /**
100
117
  * Saves the Cloving configuration to the config file
101
118
  * @param {ClovingConfig} config - The configuration to save
@@ -199,7 +216,7 @@ Please provide instructions on how to set up testing for this project.`;
199
216
  const getAllFiles = async (options, forTesting) => {
200
217
  const gpt = new cloving_gpt_1.default(options);
201
218
  // Read the cloving.json file
202
- const config = (0, exports.getClovingConfig)();
219
+ const { config } = (0, exports.getNearestClovingConfig)();
203
220
  const testingDirectory = (0, exports.getTestingDirectory)();
204
221
  let allSrcFiles = [];
205
222
  if (forTesting && !testingDirectory) {
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGitDiff = exports.generateCommitMessagePrompt = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const generateCommitMessagePrompt = () => {
6
+ const diff = (0, child_process_1.execSync)('git diff').toString();
7
+ return `Generate a concise and meaningful commit message based on a diff.
8
+
9
+ Do not add any commentary or context to the message other than the commit message itself.
10
+
11
+ An example of the output for this should look like the following:
12
+
13
+ # Update dependencies and package versions
14
+
15
+ - Upgrade Ruby gems including aws-sdk, honeybadger, irb, and rubocop
16
+ - Update Node.js packages including esbuild, tinymce, and trix
17
+ - Bump TypeScript and ESLint related packages to latest versions
18
+
19
+ ====
20
+
21
+ Here is the diff to help you write the commit message:
22
+
23
+ ${diff}`;
24
+ };
25
+ exports.generateCommitMessagePrompt = generateCommitMessagePrompt;
26
+ const getGitDiff = () => {
27
+ try {
28
+ const masterBranchName = (0, child_process_1.execSync)('git symbolic-ref refs/remotes/origin/HEAD | sed \'s@^refs/remotes/origin/@@\'')
29
+ .toString()
30
+ .trim();
31
+ if (!masterBranchName) {
32
+ throw new Error('Error: Could not determine the default branch (main or master)');
33
+ }
34
+ const gitDiff = (0, child_process_1.execSync)(`git diff ${masterBranchName} --`).toString().trim();
35
+ return gitDiff;
36
+ }
37
+ catch (error) {
38
+ console.error('Error getting git diff:', error.message);
39
+ process.exit(1);
40
+ }
41
+ };
42
+ exports.getGitDiff = getGitDiff;