cloving 0.3.10 → 0.3.12
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/cloving_gpt/adapters/azureopenai.js +1 -1
- package/dist/cloving_gpt/index.js +31 -38
- package/dist/commands/config.js +45 -0
- package/dist/commands/generate/commit.js +1 -1
- package/dist/commands/generate/docs.js +11 -0
- package/dist/commands/generate/documentation.js +11 -0
- package/dist/commands/generate/review.js +1 -1
- package/dist/commands/tokens.js +24 -0
- package/dist/index.js +10 -0
- package/dist/managers/BlockManager.js +17 -13
- package/dist/managers/ChatManager.js +22 -208
- package/dist/managers/CodeManager.js +58 -55
- package/dist/managers/CommitManager.js +1 -1
- package/dist/managers/DocsManager.js +86 -0
- package/dist/managers/DocumentationManager.js +114 -0
- package/dist/managers/InitManager.js +2 -1
- package/dist/managers/ReviewManager.js +59 -169
- package/dist/managers/ShellManager.js +49 -0
- package/dist/managers/StreamManager.js +291 -0
- package/dist/managers/UnitTestManager.js +3 -3
- package/dist/package.json +2 -2
- package/dist/utils/config_utils.js +43 -0
- package/dist/utils/git_utils.js +29 -0
- package/dist/utils/prompt_utils.js +125 -307
- package/dist/utils/prompts/CODEGEN_COULDNT_APPLY.md +5 -0
- package/dist/utils/prompts/CODEGEN_EXAMPLES.md +82 -0
- package/dist/utils/prompts/CODEGEN_INSTRUCTIONS.md +42 -0
- package/dist/utils/prompts/DOCS_INSTRUCTIONS.md +9 -0
- package/dist/utils/prompts/INIT_INSTRUCTIONS.md +132 -0
- package/dist/utils/prompts/REVIEW_INSTRUCTIONS.md +49 -0
- package/dist/utils/prompts/SHELL_INSTRUCTIONS.md +15 -0
- package/dist/utils/prompts/SPECIAL_FILES.md +66 -0
- package/dist/utils/prompts/index.js +27 -0
- package/package.json +2 -2
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Initialization Instructions
|
|
2
|
+
|
|
3
|
+
You are an AI assistant helping to initialize a project by analyzing its structure and technologies.
|
|
4
|
+
|
|
5
|
+
Please return JSON-formatted metadata about the project, including:
|
|
6
|
+
|
|
7
|
+
- The programming language(s) used
|
|
8
|
+
- The detected framework(s) (if any)
|
|
9
|
+
- The version of the language(s)
|
|
10
|
+
|
|
11
|
+
Here is a typescript interface for the expected response:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
interface LanguageConfig {
|
|
15
|
+
name: string
|
|
16
|
+
version?: string
|
|
17
|
+
primary?: boolean
|
|
18
|
+
directory: string
|
|
19
|
+
extension: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface FrameworkConfig {
|
|
23
|
+
name: string
|
|
24
|
+
type: string
|
|
25
|
+
version?: string
|
|
26
|
+
primary?: boolean
|
|
27
|
+
directory?: string
|
|
28
|
+
extension?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface TestingFrameworkConfig {
|
|
32
|
+
name: string
|
|
33
|
+
type: string
|
|
34
|
+
version?: string
|
|
35
|
+
directory?: string
|
|
36
|
+
runCommand?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface BuildToolConfig {
|
|
40
|
+
name: string
|
|
41
|
+
type: string
|
|
42
|
+
version?: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface LinterConfig {
|
|
46
|
+
name: string
|
|
47
|
+
version?: string
|
|
48
|
+
type?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface DatabaseConfig {
|
|
52
|
+
name: string
|
|
53
|
+
primary?: boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface ClovingfileConfig {
|
|
57
|
+
languages: LanguageConfig[]
|
|
58
|
+
frameworks: FrameworkConfig[]
|
|
59
|
+
testingFrameworks?: TestingFrameworkConfig[]
|
|
60
|
+
buildTools: BuildToolConfig[]
|
|
61
|
+
packageManager: string
|
|
62
|
+
linters: LinterConfig[]
|
|
63
|
+
databases?: DatabaseConfig[]
|
|
64
|
+
projectType: string
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Here is an example response:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"languages": [
|
|
73
|
+
{
|
|
74
|
+
"name": "TypeScript",
|
|
75
|
+
"version": "~> 5.5.3",
|
|
76
|
+
"primary": true,
|
|
77
|
+
"directory": "src",
|
|
78
|
+
"extension": ".ts"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "JavaScript",
|
|
82
|
+
"version": "ES6+",
|
|
83
|
+
"directory": "src",
|
|
84
|
+
"extension": ".js"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"frameworks": [
|
|
88
|
+
{
|
|
89
|
+
"name": "Node.js",
|
|
90
|
+
"type": "Runtime environment",
|
|
91
|
+
"primary": true,
|
|
92
|
+
"directory": "src",
|
|
93
|
+
"extension": ".js"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"testingFrameworks": [
|
|
97
|
+
{
|
|
98
|
+
"name": "Jest",
|
|
99
|
+
"type": "Testing framework",
|
|
100
|
+
"version": "29.7.0",
|
|
101
|
+
"directory": "tests",
|
|
102
|
+
"runCommand": "yarn test"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"buildTools": [
|
|
106
|
+
{
|
|
107
|
+
"name": "TypeScript Compiler (tsc)",
|
|
108
|
+
"type": "Transpiler"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "Vite",
|
|
112
|
+
"type": "Build tool",
|
|
113
|
+
"version": "5.3.3"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"packageManager": "Yarn",
|
|
117
|
+
"linters": [
|
|
118
|
+
{
|
|
119
|
+
"name": "ESLint",
|
|
120
|
+
"version": "9.6.0"
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
"databases": [
|
|
124
|
+
{
|
|
125
|
+
"name": "MongoDB",
|
|
126
|
+
"version": "5.0.3",
|
|
127
|
+
"primary": true
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"projectType": "Command-line tool"
|
|
131
|
+
}
|
|
132
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
### Example of a well-structured response
|
|
2
|
+
|
|
3
|
+
# Code Review: Enhanced Code Generation and File Handling
|
|
4
|
+
|
|
5
|
+
## Changes Overview
|
|
6
|
+
|
|
7
|
+
These changes primarily focus on improving the code generation process and adding more robust file handling capabilities. The main modifications include:
|
|
8
|
+
|
|
9
|
+
1. Enhancing the code generation prompt with a structured example response.
|
|
10
|
+
2. Implementing a new function to extract file names and contents from the generated code.
|
|
11
|
+
3. Adding a new option to save generated code directly to files.
|
|
12
|
+
4. Improving the copy-to-clipboard functionality to allow copying individual files.
|
|
13
|
+
5. Removing an unused import in the review.ts file.
|
|
14
|
+
|
|
15
|
+
## Reason for Changes
|
|
16
|
+
|
|
17
|
+
The changes aim to enhance the usability and flexibility of the code generation tool by providing clearer prompts, better file management, and more control over the generated code.
|
|
18
|
+
|
|
19
|
+
## Detailed Description
|
|
20
|
+
|
|
21
|
+
1. **Enhanced Code Generation Prompt** - The `generateCodePrompt` function now includes a structured example of a well-formatted response. This helps guide the AI to produce more consistent and usable output, making it easier to parse and use the generated code.
|
|
22
|
+
2. **File Extraction Function** - A new function `extractFilesAndContent` has been added to parse the raw code command and extract individual file names and their contents. This enables more granular control over the generated code, allowing for file-specific operations.
|
|
23
|
+
3. **Save to File Option** - A new 'Save Source Code to Files' option has been added to the user action menu. This feature allows users to save generated code directly to files in the appropriate directory structure.
|
|
24
|
+
4. **Improved Copy to Clipboard** - The 'Copy Source Code to Clipboard' option has been enhanced to allow users to choose specific files to copy, rather than copying all generated code at once.
|
|
25
|
+
5. **Removed Unused Import** - The unused import of `execFileSync` from 'child_process' has been removed from the review.ts file, improving code cleanliness.
|
|
26
|
+
|
|
27
|
+
## Potential Bugs and Recommended Fixes
|
|
28
|
+
|
|
29
|
+
### 1. Possible undefined access in `extractFilesAndContent`
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const contentMatch = regex.exec(rawCodeCommand)
|
|
33
|
+
if (contentMatch) {
|
|
34
|
+
files.push(fileName)
|
|
35
|
+
let content = contentMatch[1]
|
|
36
|
+
// ...
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
There's a potential for `contentMatch[1]` to be undefined if the regex doesn't capture any groups. To fix this, add a null check:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
const contentMatch = regex.exec(rawCodeCommand)
|
|
44
|
+
if (contentMatch && contentMatch[1]) {
|
|
45
|
+
files.push(fileName)
|
|
46
|
+
let content = contentMatch[1]
|
|
47
|
+
// ...
|
|
48
|
+
}
|
|
49
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Shell Script Instructions
|
|
2
|
+
|
|
3
|
+
Generate an executable script that works on the current operating system. Try to make it a single line if possible and as simple and straightforward as possible.
|
|
4
|
+
|
|
5
|
+
Do not add any commentary or context to the message other than the commit message itself.
|
|
6
|
+
|
|
7
|
+
## Example
|
|
8
|
+
|
|
9
|
+
An example of the output for this should look like the following:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
find . -type f -name "*.ts" -exec sed -i '' 's/old/new/g' {} +
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Don't use that script, it is only an example.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Special Files
|
|
2
|
+
|
|
3
|
+
The following is a list of special files recognized by the system:
|
|
4
|
+
|
|
5
|
+
- package.json
|
|
6
|
+
- Gemfile
|
|
7
|
+
- requirements.txt
|
|
8
|
+
- Pipfile
|
|
9
|
+
- pyproject.toml
|
|
10
|
+
- pom.xml
|
|
11
|
+
- build.gradle
|
|
12
|
+
- .csproj
|
|
13
|
+
- packages.config
|
|
14
|
+
- composer.json
|
|
15
|
+
- CMakeLists.txt
|
|
16
|
+
- conanfile.txt
|
|
17
|
+
- conanfile.py
|
|
18
|
+
- go.mod
|
|
19
|
+
- Cargo.toml
|
|
20
|
+
- Package.swift
|
|
21
|
+
- build.gradle.kts
|
|
22
|
+
- Podfile
|
|
23
|
+
- Cartfile
|
|
24
|
+
- cpanfile
|
|
25
|
+
- DESCRIPTION
|
|
26
|
+
- mix.exs
|
|
27
|
+
- build.sbt
|
|
28
|
+
- pubspec.yaml
|
|
29
|
+
- stack.yaml
|
|
30
|
+
- top.sls
|
|
31
|
+
- requirements.yml
|
|
32
|
+
- terraform.tf
|
|
33
|
+
- versions.tf
|
|
34
|
+
- main.yml
|
|
35
|
+
- cabal.project
|
|
36
|
+
- Project.toml
|
|
37
|
+
- rockspec
|
|
38
|
+
- rebar.config
|
|
39
|
+
- project.clj
|
|
40
|
+
- tsconfig.json
|
|
41
|
+
- .eslintrc.js
|
|
42
|
+
- .eslintrc.json
|
|
43
|
+
- .eslintrc.yaml
|
|
44
|
+
- .eslintrc.yml
|
|
45
|
+
- .eslintrc
|
|
46
|
+
- .prettierrc
|
|
47
|
+
- .prettierrc.js
|
|
48
|
+
- .prettierrc.json
|
|
49
|
+
- .prettierrc.yaml
|
|
50
|
+
- .prettierrc.yml
|
|
51
|
+
- .prettierrc
|
|
52
|
+
- .stylelintrc
|
|
53
|
+
- .stylelintrc.json
|
|
54
|
+
- .stylelintrc.yaml
|
|
55
|
+
- .stylelintrc.yml
|
|
56
|
+
- .stylelintrc
|
|
57
|
+
- jest.config.js
|
|
58
|
+
- jest.config.json
|
|
59
|
+
- jest.config.ts
|
|
60
|
+
- jest.config.cjs
|
|
61
|
+
- jest.config.mjs
|
|
62
|
+
- webpack.config.js
|
|
63
|
+
- webpack.config.ts
|
|
64
|
+
- webpack.config.cjs
|
|
65
|
+
- webpack.config.mjs
|
|
66
|
+
- webpack.config.common.js
|
|
@@ -0,0 +1,27 @@
|
|
|
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.REVIEW_INSTRUCTIONS = exports.CODEGEN_EXAMPLES = exports.SPECIAL_FILES = exports.INIT_INSTRUCTIONS = exports.DOCS_INSTRUCTIONS = exports.CODEGEN_COULDNT_APPLY = exports.CODEGEN_INSTRUCTIONS = exports.SHELL_INSTRUCTIONS = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const CODEGEN_COULDNT_APPLY = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'CODEGEN_COULDNT_APPLY.md'), 'utf-8');
|
|
10
|
+
exports.CODEGEN_COULDNT_APPLY = CODEGEN_COULDNT_APPLY;
|
|
11
|
+
const CODEGEN_INSTRUCTIONS = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'CODEGEN_INSTRUCTIONS.md'), 'utf-8');
|
|
12
|
+
exports.CODEGEN_INSTRUCTIONS = CODEGEN_INSTRUCTIONS;
|
|
13
|
+
const CODEGEN_EXAMPLES = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'CODEGEN_EXAMPLES.md'), 'utf-8');
|
|
14
|
+
exports.CODEGEN_EXAMPLES = CODEGEN_EXAMPLES;
|
|
15
|
+
const SHELL_INSTRUCTIONS = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'SHELL_INSTRUCTIONS.md'), 'utf-8');
|
|
16
|
+
exports.SHELL_INSTRUCTIONS = SHELL_INSTRUCTIONS;
|
|
17
|
+
const REVIEW_INSTRUCTIONS = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'REVIEW_INSTRUCTIONS.md'), 'utf-8');
|
|
18
|
+
exports.REVIEW_INSTRUCTIONS = REVIEW_INSTRUCTIONS;
|
|
19
|
+
const DOCS_INSTRUCTIONS = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'DOCS_INSTRUCTIONS.md'), 'utf-8');
|
|
20
|
+
exports.DOCS_INSTRUCTIONS = DOCS_INSTRUCTIONS;
|
|
21
|
+
const INIT_INSTRUCTIONS = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'INIT_INSTRUCTIONS.md'), 'utf-8');
|
|
22
|
+
exports.INIT_INSTRUCTIONS = INIT_INSTRUCTIONS;
|
|
23
|
+
const SPECIAL_FILES_PATH = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'SPECIAL_FILES.md'), 'utf-8');
|
|
24
|
+
const SPECIAL_FILES = SPECIAL_FILES_PATH.split('\n')
|
|
25
|
+
.filter((line) => line.startsWith('- '))
|
|
26
|
+
.map((line) => line.slice(2).trim());
|
|
27
|
+
exports.SPECIAL_FILES = SPECIAL_FILES;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloving",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"packageManager": "yarn@1.22.22",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc && cp package.json dist/package.json",
|
|
8
|
+
"build": "tsc && cp package.json dist/package.json && cp src/utils/prompts/*.md dist/utils/prompts/",
|
|
9
9
|
"start": "node dist/index.js",
|
|
10
10
|
"watch": "tsc -w",
|
|
11
11
|
"check": "bash -c 'npx tsc --noEmit --skipLibCheck'",
|