cloving 0.1.3 → 0.1.7
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/README.md +117 -36
- package/dist/cloving_gpt/index.js +14 -10
- package/dist/commands/commit.js +2 -2
- package/dist/commands/config.js +33 -6
- package/dist/commands/generate/commit.js +44 -0
- package/dist/commands/generate/review.js +57 -0
- package/dist/commands/generate/unit_tests.js +125 -0
- package/dist/commands/init.js +7 -12
- package/dist/commands/project/build.js +88 -0
- package/dist/commands/project/complete.js +12 -0
- package/dist/commands/project/init.js +76 -0
- package/dist/commands/project/plan.js +108 -0
- package/dist/commands/review.js +2 -2
- package/dist/commands/unit_tests.js +2 -2
- package/dist/index.js +58 -20
- package/dist/utils/command_utils.js +1 -48
- package/dist/utils/config_utils.js +168 -0
- package/dist/utils/git_utils.js +34 -22
- package/dist/utils/string_utils.js +36 -1
- package/package.json +5 -1
package/dist/utils/git_utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getGitDiff = exports.generateCommitMessagePrompt = void 0;
|
|
6
|
+
exports.getCurrentBranchName = exports.getDefaultBranchName = exports.getGitDiff = exports.generateCommitMessagePrompt = void 0;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const readline_1 = __importDefault(require("readline"));
|
|
9
9
|
const askQuestion = (question) => {
|
|
@@ -39,27 +39,8 @@ ${diff}`;
|
|
|
39
39
|
exports.generateCommitMessagePrompt = generateCommitMessagePrompt;
|
|
40
40
|
const getGitDiff = async () => {
|
|
41
41
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.toString()
|
|
45
|
-
.trim();
|
|
46
|
-
if (mainBranchName === '') {
|
|
47
|
-
console.error('Could not determine the default branch.');
|
|
48
|
-
const answer = await askQuestion('Do you want to run `git remote set-head origin -a`? [Y/n] ');
|
|
49
|
-
if (answer.toLowerCase() === 'y' || answer === '') {
|
|
50
|
-
(0, child_process_1.execSync)('git remote set-head origin -a');
|
|
51
|
-
mainBranchName = (0, child_process_1.execSync)('git symbolic-ref refs/remotes/origin/HEAD | sed \'s@^refs/remotes/origin/@@\'')
|
|
52
|
-
.toString()
|
|
53
|
-
.trim();
|
|
54
|
-
if (mainBranchName === '') {
|
|
55
|
-
throw new Error('Error: Could not determine the default branch (main or master)');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
throw new Error('Operation aborted by user.');
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const gitDiff = (0, child_process_1.execSync)(`git diff ${mainBranchName} --`).toString().trim();
|
|
42
|
+
const defaultBranchName = await (0, exports.getDefaultBranchName)();
|
|
43
|
+
const gitDiff = (0, child_process_1.execSync)(`git diff ${defaultBranchName} --`).toString().trim();
|
|
63
44
|
return gitDiff;
|
|
64
45
|
}
|
|
65
46
|
catch (error) {
|
|
@@ -68,3 +49,34 @@ const getGitDiff = async () => {
|
|
|
68
49
|
}
|
|
69
50
|
};
|
|
70
51
|
exports.getGitDiff = getGitDiff;
|
|
52
|
+
const getDefaultBranchName = async () => {
|
|
53
|
+
let defaultBranchName = (0, child_process_1.execSync)('git symbolic-ref refs/remotes/origin/HEAD | sed \'s@^refs/remotes/origin/@@\'')
|
|
54
|
+
.toString()
|
|
55
|
+
.trim();
|
|
56
|
+
if (defaultBranchName === '') {
|
|
57
|
+
console.error('Could not determine the default branch.');
|
|
58
|
+
const answer = await askQuestion('Do you want to run `git remote set-head origin -a`? [Y/n] ');
|
|
59
|
+
if (answer.toLowerCase() === 'y' || answer === '') {
|
|
60
|
+
(0, child_process_1.execSync)('git remote set-head origin -a');
|
|
61
|
+
defaultBranchName = await (0, exports.getDefaultBranchName)();
|
|
62
|
+
if (defaultBranchName === '') {
|
|
63
|
+
throw new Error('Error: Could not determine the default branch (main or master)');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw new Error('Operation aborted by user.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return defaultBranchName;
|
|
71
|
+
};
|
|
72
|
+
exports.getDefaultBranchName = getDefaultBranchName;
|
|
73
|
+
const getCurrentBranchName = () => {
|
|
74
|
+
try {
|
|
75
|
+
return (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD').toString().trim();
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.error('Error getting current branch name:', error.message);
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.getCurrentBranchName = getCurrentBranchName;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractMarkdown = exports.extractJsonMetadata = exports.estimateTokens = void 0;
|
|
3
|
+
exports.parseMarkdownInstructions = exports.extractMarkdown = exports.extractJsonMetadata = exports.estimateTokens = void 0;
|
|
4
4
|
// Function to estimate token count
|
|
5
5
|
const estimateTokens = async (text) => {
|
|
6
6
|
const charCount = text.length;
|
|
@@ -61,3 +61,38 @@ const extractMarkdown = (response) => {
|
|
|
61
61
|
return markdownString;
|
|
62
62
|
};
|
|
63
63
|
exports.extractMarkdown = extractMarkdown;
|
|
64
|
+
const parseMarkdownInstructions = (input) => {
|
|
65
|
+
const lines = input.split('\n');
|
|
66
|
+
const result = [];
|
|
67
|
+
let buffer = [];
|
|
68
|
+
let inCodeBlock = false;
|
|
69
|
+
lines.forEach(line => {
|
|
70
|
+
if (line.trim().startsWith('```')) {
|
|
71
|
+
if (inCodeBlock) {
|
|
72
|
+
// End of code block
|
|
73
|
+
buffer.push(line);
|
|
74
|
+
result.push(buffer.join('\n'));
|
|
75
|
+
buffer = [];
|
|
76
|
+
inCodeBlock = false;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// Start of code block
|
|
80
|
+
if (buffer.length > 0) {
|
|
81
|
+
result.push(buffer.join('\n'));
|
|
82
|
+
buffer = [];
|
|
83
|
+
}
|
|
84
|
+
buffer.push(line);
|
|
85
|
+
inCodeBlock = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
buffer.push(line);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
// If buffer has any remaining lines, add them to the result
|
|
93
|
+
if (buffer.length > 0) {
|
|
94
|
+
result.push(buffer.join('\n'));
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
};
|
|
98
|
+
exports.parseMarkdownInstructions = parseMarkdownInstructions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloving",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"axios": "^1.7.2",
|
|
41
|
+
"cli-highlight": "^2.1.11",
|
|
41
42
|
"commander": "^12.1.0",
|
|
42
43
|
"eslint": "^9.6.0",
|
|
43
44
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -48,11 +49,14 @@
|
|
|
48
49
|
"eslint-plugin-n": "^17.9.0",
|
|
49
50
|
"eslint-plugin-promise": "^6.4.0",
|
|
50
51
|
"ignore": "^5.3.1",
|
|
52
|
+
"ini": "^4.1.3",
|
|
53
|
+
"inquirer": "^10.0.1",
|
|
51
54
|
"nock": "^13.5.4",
|
|
52
55
|
"vite": "^5.3.3",
|
|
53
56
|
"vite-node": "^2.0.1"
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
59
|
+
"@types/ini": "^4.1.1",
|
|
56
60
|
"@types/jest": "^29.5.12",
|
|
57
61
|
"@types/node": "^20.14.10",
|
|
58
62
|
"husky": "^9.0.11",
|