cloving 0.3.17 → 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.
@@ -88,6 +88,8 @@ class OpenAIAdapter {
88
88
  exports.OpenAIAdapter = OpenAIAdapter;
89
89
  // List of supported models
90
90
  OpenAIAdapter.supportedModels = [
91
+ 'openai:gpt:o1-preview',
92
+ 'openai:gpt:o1-mini',
91
93
  'openai:gpt:4o-2024-08-06',
92
94
  'openai:gpt:4o',
93
95
  'openai:gpt:4o-mini',
@@ -20,7 +20,7 @@ const generateContextPrompt = (files, contextFiles) => {
20
20
  .join('\n');
21
21
  return `### Description of App
22
22
 
23
- ${JSON.stringify((0, config_utils_1.getClovingConfig)(), null, 2)}
23
+ ${JSON.stringify((0, config_utils_1.getNearestClovingConfig)().config, null, 2)}
24
24
 
25
25
  ${specialFiles}
26
26
 
@@ -62,7 +62,7 @@ const tokens = async (options) => {
62
62
  prompt += `
63
63
  ### Description of App
64
64
 
65
- ${JSON.stringify((0, config_utils_1.getClovingConfig)(), null, 2)}
65
+ ${JSON.stringify((0, config_utils_1.getNearestClovingConfig)().config, null, 2)}
66
66
 
67
67
  ${contextFileContents}`;
68
68
  /**
@@ -40,7 +40,14 @@ class ProxyManager {
40
40
  this.app.get('/', (_req, res) => {
41
41
  res.json({ message: 'ClovingGPT proxy server running' });
42
42
  });
43
- this.app.post('/v1/chat/completions', this.handleChatCompletions.bind(this));
43
+ this.app.post('/v1/chat/completions', async (req, res, next) => {
44
+ try {
45
+ await this.handleChatCompletions(req, res);
46
+ }
47
+ catch (error) {
48
+ next(error);
49
+ }
50
+ });
44
51
  }
45
52
  async loadContextFiles() {
46
53
  let files = this.options.files || '.';
@@ -93,7 +100,7 @@ ${content}
93
100
 
94
101
  ### Description of App
95
102
 
96
- ${JSON.stringify((0, config_utils_1.getClovingConfig)(), null, 2)}
103
+ ${JSON.stringify((0, config_utils_1.getNearestClovingConfig)().config, null, 2)}
97
104
 
98
105
  ${contextFileContents}
99
106
 
@@ -242,7 +242,7 @@ class StreamManager extends events_1.EventEmitter {
242
242
  */
243
243
  async loadContextFiles() {
244
244
  try {
245
- const config = (0, config_utils_1.getClovingConfig)();
245
+ const config = (0, config_utils_1.getNearestClovingConfig)().config;
246
246
  const primaryLanguage = config.languages.find((lang) => lang.primary);
247
247
  const defaultDirectory = primaryLanguage ? primaryLanguage.directory : '.';
248
248
  const testingDirectories = config.testingFrameworks?.map((framework) => framework.directory) || [];
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.3.15",
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",
@@ -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) {
@@ -7,9 +7,27 @@ 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.generateCommitMessagePrompt = exports.getCurrentBranchName = exports.getDefaultBranchName = exports.getGitDiff = void 0;
10
+ exports.generateCommitMessagePrompt = exports.readCommitlintConfig = exports.findCommitlintConfig = exports.getCurrentBranchName = exports.getDefaultBranchName = exports.getGitDiff = void 0;
11
11
  const child_process_1 = require("child_process");
12
12
  const readline_1 = __importDefault(require("readline"));
13
+ const fs_1 = __importDefault(require("fs"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const COMMITLINT_CONFIG_FILES = [
16
+ '.commitlintrc',
17
+ '.commitlintrc.json',
18
+ '.commitlintrc.yaml',
19
+ '.commitlintrc.yml',
20
+ '.commitlintrc.js',
21
+ '.commitlintrc.cjs',
22
+ '.commitlintrc.mjs',
23
+ '.commitlintrc.ts',
24
+ '.commitlintrc.cts',
25
+ 'commitlint.config.js',
26
+ 'commitlint.config.cjs',
27
+ 'commitlint.config.mjs',
28
+ 'commitlint.config.ts',
29
+ 'commitlint.config.cts',
30
+ ];
13
31
  /**
14
32
  * Prompts the user with a question and returns their answer.
15
33
  * @param {string} question - The question to ask the user.
@@ -88,24 +106,108 @@ const getCurrentBranchName = () => {
88
106
  }
89
107
  };
90
108
  exports.getCurrentBranchName = getCurrentBranchName;
109
+ /**
110
+ * Checks if a commitlint configuration file exists in the project.
111
+ * @returns {string | null} The path to the commitlint config file if found, null otherwise.
112
+ */
113
+ const findCommitlintConfig = () => {
114
+ for (const configFile of COMMITLINT_CONFIG_FILES) {
115
+ if (fs_1.default.existsSync(configFile)) {
116
+ return configFile;
117
+ }
118
+ }
119
+ return null;
120
+ };
121
+ exports.findCommitlintConfig = findCommitlintConfig;
122
+ /**
123
+ * Reads and parses the commitlint configuration file.
124
+ * @param {string} configPath - Path to the commitlint config file.
125
+ * @returns {object | null} The parsed configuration object or null if unable to parse.
126
+ */
127
+ const readCommitlintConfig = (configPath) => {
128
+ try {
129
+ const ext = path_1.default.extname(configPath);
130
+ if (['.js', '.cjs', '.mjs', '.ts', '.cts'].includes(ext)) {
131
+ // For JavaScript/TypeScript config files, we can't safely require them
132
+ // as they might have dependencies or complex configurations
133
+ return null;
134
+ }
135
+ if (['.json', '', '.yaml', '.yml'].includes(ext)) {
136
+ const content = fs_1.default.readFileSync(configPath, 'utf-8');
137
+ if (ext === '.json' || ext === '') {
138
+ return JSON.parse(content);
139
+ }
140
+ // For YAML files, we'll just return the raw content as a string
141
+ return { config: content };
142
+ }
143
+ return null;
144
+ }
145
+ catch (error) {
146
+ console.error('Error reading commitlint config:', error.message);
147
+ return null;
148
+ }
149
+ };
150
+ exports.readCommitlintConfig = readCommitlintConfig;
91
151
  /**
92
152
  * Generates a prompt for creating a commit message based on a Git diff.
93
153
  * @param {string} diff - The Git diff to base the commit message on.
94
154
  * @returns {string} A prompt string for generating a commit message.
95
155
  */
96
156
  const generateCommitMessagePrompt = (diff) => {
97
- return `Generate a concise and meaningful commit message based on a diff.
157
+ // Check if commitlint is configured
158
+ const commitlintConfig = (0, exports.findCommitlintConfig)();
159
+ let configInfo = '';
160
+ if (commitlintConfig) {
161
+ const config = (0, exports.readCommitlintConfig)(commitlintConfig);
162
+ if (config) {
163
+ configInfo = `\nFound commitlint configuration at ${commitlintConfig}:
164
+ \`\`\`json
165
+ ${JSON.stringify(config, null, 2)}
166
+ \`\`\`
167
+ Please ensure the commit message follows any additional rules specified in this configuration.
168
+ `;
169
+ }
170
+ }
171
+ return `Generate a conventional commit message following the Conventional Commits specification (www.conventionalcommits.org).${configInfo}
172
+
173
+ The commit message should follow this format:
174
+ <type>[optional scope]: <description>
175
+
176
+ [optional body]
177
+
178
+ [optional footer(s)]
179
+
180
+ Types must be one of:
181
+ 1. revert: Reverts a previous commit
182
+ 2. feat: A new feature
183
+ 3. fix: A bug fix
184
+ 4. refactor: A code change that neither fixes a bug nor adds a feature
185
+ 5. perf: A code change that improves performance
186
+ 6. build: Changes that affect the build system or external dependencies or updates to versions of dependencies or version bumps
187
+ 7. test: Adding missing tests or correcting existing tests
188
+ 8. docs: Documentation only changes
189
+ 9. style: Changes that do not affect the meaning of the code
190
+ 10. ci: Changes to our CI configuration files and scripts
191
+ 11. chore: Other changes that don't modify src or test files
192
+
193
+ Use the order of types as an order of precedence for the commit message if there are multiple types in one commit.
194
+
195
+ The scope should be the part of the codebase affected.
196
+ The description should be imperative, present tense, and not capitalized.
197
+ Breaking changes should be indicated by "!" before the ":" or by "BREAKING CHANGE:" in the footer.
98
198
 
99
199
  Do not add any commentary or context to the message other than the commit message itself.
100
200
 
101
- An example of the output for this should look like the following:
201
+ Here is an example of a valid conventional commit message:
102
202
 
103
203
  \`\`\`plaintext
104
- Update dependencies and package versions
204
+ feat(api): add new endpoint for user authentication
205
+
206
+ - Implement JWT token generation
207
+ - Add password hashing with bcrypt
208
+ - Create user validation middleware
105
209
 
106
- - Upgrade Ruby gems including aws-sdk, honeybadger, irb, and rubocop
107
- - Update Node.js packages including esbuild, tinymce, and trix
108
- - Bump TypeScript and ESLint related packages to latest versions
210
+ BREAKING CHANGE: 'auth' endpoint now requires API key in headers
109
211
  \`\`\`
110
212
 
111
213
  Here is the diff to help you write the commit message:
@@ -56,7 +56,7 @@ const generateCodegenPrompt = (contextFilesContent) => {
56
56
  ## Description of App
57
57
 
58
58
  \`\`\`json
59
- ${JSON.stringify((0, config_utils_1.getClovingConfig)(), null, 2)}
59
+ ${JSON.stringify((0, config_utils_1.getNearestClovingConfig)().config, null, 2)}
60
60
  \`\`\`
61
61
 
62
62
  ## Special Files
@@ -99,7 +99,7 @@ ${prompts_1.CODEGEN_EXAMPLES}
99
99
  ## Description of App
100
100
 
101
101
  \`\`\`json
102
- ${JSON.stringify((0, config_utils_1.getClovingConfig)(), null, 2)}
102
+ ${JSON.stringify((0, config_utils_1.getNearestClovingConfig)().config, null, 2)}
103
103
  \`\`\`
104
104
 
105
105
  ## Special Files
@@ -136,7 +136,7 @@ const generateReviewPrompt = (options, contextFiles) => {
136
136
  .join('\n');
137
137
  prompt += `### Description of App
138
138
 
139
- ${JSON.stringify((0, config_utils_1.getClovingConfig)(), null, 2)}
139
+ ${JSON.stringify((0, config_utils_1.getNearestClovingConfig)().config, null, 2)}
140
140
 
141
141
  ${contextFileContents}
142
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloving",
3
- "version": "0.3.17",
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,27 +39,27 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@inquirer/prompts": "^5.3.8",
43
- "axios": "^1.7.7",
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
52
  "eslint-plugin-import": "^2.31.0",
53
- "eslint-plugin-jsdoc": "^50.3.1",
54
- "eslint-plugin-n": "^16.6.2",
55
- "eslint-plugin-promise": "^6.6.0",
56
- "express": "^4.21.1",
57
- "ignore": "^5.3.2",
58
- "ini": "^4.1.3",
59
- "isbinaryfile": "^5.0.2",
60
- "nock": "^13.5.5",
61
- "vite": "^5.4.8",
62
- "vite-node": "^2.1.2"
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",
@@ -67,15 +67,15 @@
67
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.13",
71
- "@types/node": "^22.7.5",
72
- "husky": "^9.1.6",
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.10",
76
- "prettier": "^3.3.3",
74
+ "lint-prepush": "^3.0.2",
75
+ "lint-staged": "^15.4.3",
76
+ "prettier": "^3.5.1",
77
77
  "ts-jest": "^29.2.5",
78
- "typescript": "^5.6.3"
78
+ "typescript": "^5.7.3"
79
79
  },
80
80
  "resolutions": {
81
81
  "eslint": "8.57.0",