cloving 0.3.18 → 0.3.19
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/.DS_Store +0 -0
- package/.aider.chat.history.md +16978 -0
- package/.aider.input.history +15 -0
- package/.aider.tags.cache.v3/cache.db +0 -0
- package/.aider.tags.cache.v3/cache.db-shm +0 -0
- package/.aider.tags.cache.v3/cache.db-wal +0 -0
- package/.cursorrules +77 -0
- package/.github/workflows/auto-release.yml +83 -0
- package/.github/workflows/ci.yml +32 -0
- package/.github/workflows/npm-publish.yml +34 -0
- package/.gitignore +67 -0
- package/.husky/_/.gitignore +1 -0
- package/.husky/_/applypatch-msg +2 -0
- package/.husky/_/commit-msg +2 -0
- package/.husky/_/h +22 -0
- package/.husky/_/husky.sh +9 -0
- package/.husky/_/post-applypatch +2 -0
- package/.husky/_/post-checkout +2 -0
- package/.husky/_/post-commit +2 -0
- package/.husky/_/post-merge +2 -0
- package/.husky/_/post-rewrite +2 -0
- package/.husky/_/pre-applypatch +2 -0
- package/.husky/_/pre-auto-gc +2 -0
- package/.husky/_/pre-commit +2 -0
- package/.husky/_/pre-merge-commit +2 -0
- package/.husky/_/pre-push +2 -0
- package/.husky/_/pre-rebase +2 -0
- package/.husky/_/prepare-commit-msg +2 -0
- package/.husky/pre-commit +1 -0
- package/.husky/pre-push +1 -0
- package/.prettierrc.json +7 -0
- package/.tool-versions +2 -0
- package/SECURITY.md +15 -0
- package/cloving.json +67 -0
- package/dist/managers/CommitManager.js +8 -2
- package/dist/package.json +1 -1
- package/jest.config.js +11 -0
- package/package.json +1 -1
- package/src/cloving_gpt/adapters/azureopenai.ts +83 -0
- package/src/cloving_gpt/adapters/claude.ts +140 -0
- package/src/cloving_gpt/adapters/gemini.ts +146 -0
- package/src/cloving_gpt/adapters/index.ts +43 -0
- package/src/cloving_gpt/adapters/mistral.ts +142 -0
- package/src/cloving_gpt/adapters/ollama.ts +136 -0
- package/src/cloving_gpt/adapters/openai.ts +113 -0
- package/src/cloving_gpt/index.ts +229 -0
- package/src/commands/chat.ts +12 -0
- package/src/commands/config.ts +192 -0
- package/src/commands/generate/code.ts +18 -0
- package/src/commands/generate/commit.ts +9 -0
- package/src/commands/generate/context.ts +93 -0
- package/src/commands/generate/docs.ts +9 -0
- package/src/commands/generate/review.ts +9 -0
- package/src/commands/generate/shell.ts +9 -0
- package/src/commands/generate/unit_tests.ts +9 -0
- package/src/commands/init.ts +9 -0
- package/src/commands/models.ts +21 -0
- package/src/commands/proxy.ts +9 -0
- package/src/commands/tokens.ts +82 -0
- package/src/index.ts +197 -0
- package/src/managers/BlockManager.ts +126 -0
- package/src/managers/ChatManager.ts +755 -0
- package/src/managers/ChunkManager.ts +31 -0
- package/src/managers/CodeManager.ts +226 -0
- package/src/managers/CommitManager.ts +71 -0
- package/src/managers/DocsManager.ts +101 -0
- package/src/managers/InitManager.ts +263 -0
- package/src/managers/ProxyManager.ts +240 -0
- package/src/managers/ReviewManager.ts +154 -0
- package/src/managers/ShellManager.ts +172 -0
- package/src/managers/StreamManager.ts +353 -0
- package/src/managers/UnitTestManager.ts +293 -0
- package/src/utils/config_utils.ts +271 -0
- package/src/utils/git_utils.ts +230 -0
- package/src/utils/model_utils.ts +3 -0
- package/src/utils/prompt_utils.ts +375 -0
- package/src/utils/prompts/CODEGEN_COULDNT_APPLY.md +5 -0
- package/src/utils/prompts/CODEGEN_EXAMPLES.md +82 -0
- package/src/utils/prompts/CODEGEN_INSTRUCTIONS.md +43 -0
- package/src/utils/prompts/DOCS_INSTRUCTIONS.md +9 -0
- package/src/utils/prompts/INIT_INSTRUCTIONS.md +132 -0
- package/src/utils/prompts/REVIEW_INSTRUCTIONS.md +49 -0
- package/src/utils/prompts/SHELL_INSTRUCTIONS.md +15 -0
- package/src/utils/prompts/SPECIAL_FILES.md +66 -0
- package/src/utils/prompts/index.ts +37 -0
- package/src/utils/string_utils.ts +552 -0
- package/src/utils/types.ts +127 -0
- package/tests/commands/generate/unit_tests.test.ts +27 -0
- package/tests/utils/git_utils.test.ts +116 -0
- package/tests/utils/model_utils.test.ts +27 -0
- package/tests/utils/prompt_utils.test.ts +33 -0
- package/tests/utils/string_utils.test.ts +560 -0
- package/tsconfig.json +14 -0
- package/yarn.lock +5823 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
# 2024-08-11 14:44:54.497516
|
|
3
|
+
+move the logic for `src/commands/generate/commit.ts` into a CommitManager.ts similar to how `src/managers/CodeManager.ts`
|
|
4
|
+
|
|
5
|
+
# 2024-08-11 14:47:53.307920
|
|
6
|
+
+can you make CommitM
|
|
7
|
+
|
|
8
|
+
# 2024-08-12 07:34:19.616951
|
|
9
|
+
+what is 1+1?
|
|
10
|
+
|
|
11
|
+
# 2024-08-13 16:41:12.331108
|
|
12
|
+
+fix `src/managers/ReviewManager.ts` to use the private chatHistory: ChatMessage[] like `src/managers/CodeManager.ts`
|
|
13
|
+
|
|
14
|
+
# 2024-08-13 16:43:18.098654
|
|
15
|
+
+how do I modify `src/utils/command_utils.ts` generateCodegenPrompt to make sure that the CURRENT in a *CURRENT/NEW* Block is as small as possible and does not try to include large chunks of unneeded code to replace
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
package/.cursorrules
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# TypeScript-specific coding standards
|
|
2
|
+
typescript:
|
|
3
|
+
style:
|
|
4
|
+
quotes: 'single' # Use single quotes for strings
|
|
5
|
+
semi: false # No semicolons at end of statements
|
|
6
|
+
trailingComma: 'all' # Add trailing commas wherever possible
|
|
7
|
+
printWidth: 100 # Maximum line length before wrapping
|
|
8
|
+
tabWidth: 2 # Number of spaces for each indentation level
|
|
9
|
+
bracketSpacing: true # Spaces between brackets in object literals
|
|
10
|
+
arrowParens: 'avoid' # Omit parentheses for single arrow function parameters
|
|
11
|
+
|
|
12
|
+
imports:
|
|
13
|
+
preferNamed: true # Prefer named imports over default imports
|
|
14
|
+
grouping: # Order of import groups
|
|
15
|
+
- '^@/' # Internal modules first
|
|
16
|
+
- '^[./]' # Relative imports second
|
|
17
|
+
maxLineLength: 100 # Maximum length for import statements
|
|
18
|
+
sortImports: true # Sort imports alphabetically within groups
|
|
19
|
+
newlineAfterImports: true # Add newline after import section
|
|
20
|
+
|
|
21
|
+
naming:
|
|
22
|
+
classes: 'PascalCase' # Example: UserService, ConfigManager
|
|
23
|
+
interfaces: 'PascalCase' # Example: UserInterface, ConfigOptions
|
|
24
|
+
types: 'PascalCase' # Example: UserType, ConfigType
|
|
25
|
+
enums: 'PascalCase' # Example: UserRole, LogLevel
|
|
26
|
+
variables: 'camelCase' # Example: userData, configSettings
|
|
27
|
+
functions: 'camelCase' # Example: getData(), processConfig()
|
|
28
|
+
constants: 'UPPER_CASE' # Example: API_KEY, MAX_RETRIES
|
|
29
|
+
privateMembers: 'camelCase' # Example: private myPrivateVar
|
|
30
|
+
typeParameters: 'PascalCase' # Example: <T>, <TKey>
|
|
31
|
+
|
|
32
|
+
organization:
|
|
33
|
+
preferConst: true # Use const by default, let only when necessary
|
|
34
|
+
maxParametersPerFunction: 4 # Limit function parameters for better readability
|
|
35
|
+
maxFunctionLength: 50 # Keep functions concise and focused
|
|
36
|
+
memberOrdering: # Class member ordering
|
|
37
|
+
- 'public-static-field'
|
|
38
|
+
- 'private-static-field'
|
|
39
|
+
- 'public-instance-field'
|
|
40
|
+
- 'private-instance-field'
|
|
41
|
+
- 'constructor'
|
|
42
|
+
- 'public-instance-method'
|
|
43
|
+
- 'private-instance-method'
|
|
44
|
+
|
|
45
|
+
documentation:
|
|
46
|
+
jsdocStyle: true # Use JSDoc style comments for documentation
|
|
47
|
+
requireParamTypes: true # Require type annotations in @param tags
|
|
48
|
+
requireReturnType: true # Require return type annotations
|
|
49
|
+
requireExampleComments: true # Include examples in complex function docs
|
|
50
|
+
multilineCommentStyle: # Style for multiline comments
|
|
51
|
+
startsWith: '/**' # Start with /** for JSDoc comments
|
|
52
|
+
linePrefix: ' * ' # Each line starts with ' * '
|
|
53
|
+
endsWith: ' */' # End with */
|
|
54
|
+
|
|
55
|
+
# General project-wide settings
|
|
56
|
+
general:
|
|
57
|
+
fileNaming: 'kebab-case' # Example: user-service.ts, config-manager.ts
|
|
58
|
+
directoryNaming: 'kebab-case' # Example: user-services/, config-utils/
|
|
59
|
+
maxLineLength: 100 # Maximum characters per line
|
|
60
|
+
indentation: 'spaces' # Use spaces instead of tabs
|
|
61
|
+
indentSize: 2 # Number of spaces per indentation level
|
|
62
|
+
newlineAtEndOfFile: true # Ensure files end with a newline
|
|
63
|
+
|
|
64
|
+
patterns:
|
|
65
|
+
utils:
|
|
66
|
+
location: 'src/utils' # Utility functions go in src/utils
|
|
67
|
+
naming: '${name}_utils' # Example: string_utils.ts, file_utils.ts
|
|
68
|
+
managers:
|
|
69
|
+
location: 'src/managers' # Manager classes go in src/managers
|
|
70
|
+
naming: '${Name}Manager' # Example: ChatManager.ts, StreamManager.ts
|
|
71
|
+
types:
|
|
72
|
+
location: 'src/utils/types.ts' # Central types file
|
|
73
|
+
constants:
|
|
74
|
+
location: 'src/utils/constants.ts' # Central constants file
|
|
75
|
+
tests:
|
|
76
|
+
location: 'tests' # Test files in tests directory
|
|
77
|
+
naming: '${name}.test.ts' # Example: string_utils.test.ts
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Auto Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: ['20.x', '22.x']
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout code
|
|
18
|
+
uses: actions/checkout@v3
|
|
19
|
+
|
|
20
|
+
- name: Set up Node.js
|
|
21
|
+
uses: actions/setup-node@v3
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: yarn install
|
|
27
|
+
|
|
28
|
+
- name: Run TypeScript checks
|
|
29
|
+
run: yarn run check
|
|
30
|
+
|
|
31
|
+
- name: Run tests
|
|
32
|
+
run: yarn run test
|
|
33
|
+
|
|
34
|
+
check-version-and-release:
|
|
35
|
+
needs: test
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
steps:
|
|
38
|
+
- name: Checkout code
|
|
39
|
+
uses: actions/checkout@v4
|
|
40
|
+
with:
|
|
41
|
+
fetch-depth: 0
|
|
42
|
+
|
|
43
|
+
- name: Get current version
|
|
44
|
+
id: package-version
|
|
45
|
+
run: echo "::set-output name=version::$(node -p "require('./package.json').version")"
|
|
46
|
+
|
|
47
|
+
- name: Get latest release version
|
|
48
|
+
id: latest-release
|
|
49
|
+
run: |
|
|
50
|
+
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
|
51
|
+
echo "::set-output name=version::${latest_tag#v}"
|
|
52
|
+
|
|
53
|
+
- name: Compare versions
|
|
54
|
+
id: compare-versions
|
|
55
|
+
run: |
|
|
56
|
+
if [ "${{ steps.package-version.outputs.version }}" != "${{ steps.latest-release.outputs.version }}" ]; then
|
|
57
|
+
echo "::set-output name=changed::true"
|
|
58
|
+
else
|
|
59
|
+
echo "::set-output name=changed::false"
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
- name: Generate changelog
|
|
63
|
+
if: steps.compare-versions.outputs.changed == 'true'
|
|
64
|
+
id: changelog
|
|
65
|
+
uses: metcalfc/changelog-generator@v4.3.1
|
|
66
|
+
with:
|
|
67
|
+
myToken: ${{ secrets.GITHUB_TOKEN }}
|
|
68
|
+
head-ref: v${{ steps.package-version.outputs.version }}
|
|
69
|
+
base-ref: v${{ steps.latest-release.outputs.version }}
|
|
70
|
+
|
|
71
|
+
- name: Create Release
|
|
72
|
+
if: steps.compare-versions.outputs.changed == 'true'
|
|
73
|
+
uses: actions/create-release@v1
|
|
74
|
+
env:
|
|
75
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
76
|
+
with:
|
|
77
|
+
tag_name: v${{ steps.package-version.outputs.version }}
|
|
78
|
+
release_name: Release v${{ steps.package-version.outputs.version }}
|
|
79
|
+
body: |
|
|
80
|
+
Changes in this Release:
|
|
81
|
+
${{ steps.changelog.outputs.changelog }}
|
|
82
|
+
draft: false
|
|
83
|
+
prerelease: false
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: ['20.x', '22.x']
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout code
|
|
18
|
+
uses: actions/checkout@v3
|
|
19
|
+
|
|
20
|
+
- name: Set up Node.js
|
|
21
|
+
uses: actions/setup-node@v3
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: yarn install
|
|
27
|
+
|
|
28
|
+
- name: Run TypeScript checks
|
|
29
|
+
run: yarn run check
|
|
30
|
+
|
|
31
|
+
- name: Run tests
|
|
32
|
+
run: yarn run test
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [created]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: 20
|
|
18
|
+
- run: yarn install
|
|
19
|
+
- run: yarn test
|
|
20
|
+
|
|
21
|
+
publish-npm:
|
|
22
|
+
needs: build
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: 20
|
|
29
|
+
registry-url: https://registry.npmjs.org/
|
|
30
|
+
- run: yarn install
|
|
31
|
+
- run: yarn build
|
|
32
|
+
- run: npm publish
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/.gitignore
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
npm-debug.log
|
|
4
|
+
yarn-error.log
|
|
5
|
+
yarn-debug.log
|
|
6
|
+
.pnp/
|
|
7
|
+
.pnp.js
|
|
8
|
+
|
|
9
|
+
# TypeScript
|
|
10
|
+
*.tsbuildinfo
|
|
11
|
+
|
|
12
|
+
# Compiled output
|
|
13
|
+
dist/
|
|
14
|
+
build/
|
|
15
|
+
out/
|
|
16
|
+
|
|
17
|
+
# IDEs and editors
|
|
18
|
+
.vscode/
|
|
19
|
+
.idea/
|
|
20
|
+
*.swp
|
|
21
|
+
*.swo
|
|
22
|
+
*.sublime-workspace
|
|
23
|
+
|
|
24
|
+
# Operating System Files
|
|
25
|
+
.DS_Store
|
|
26
|
+
Thumbs.db
|
|
27
|
+
|
|
28
|
+
# Environment variables
|
|
29
|
+
.env
|
|
30
|
+
.env.local
|
|
31
|
+
.env.development.local
|
|
32
|
+
.env.test.local
|
|
33
|
+
.env.production.local
|
|
34
|
+
|
|
35
|
+
# Debug logs
|
|
36
|
+
logs
|
|
37
|
+
*.log
|
|
38
|
+
npm-debug.log*
|
|
39
|
+
yarn-debug.log*
|
|
40
|
+
yarn-error.log*
|
|
41
|
+
|
|
42
|
+
# Coverage directory used by tools like istanbul
|
|
43
|
+
coverage/
|
|
44
|
+
|
|
45
|
+
# Temporary folders
|
|
46
|
+
tmp/
|
|
47
|
+
temp/
|
|
48
|
+
|
|
49
|
+
# Optional npm cache directory
|
|
50
|
+
.npm
|
|
51
|
+
|
|
52
|
+
# Optional eslint cache
|
|
53
|
+
.eslintcache
|
|
54
|
+
|
|
55
|
+
# Optional REPL history
|
|
56
|
+
.node_repl_history
|
|
57
|
+
|
|
58
|
+
# Output of 'npm pack'
|
|
59
|
+
*.tgz
|
|
60
|
+
|
|
61
|
+
# Yarn Integrity file
|
|
62
|
+
.yarn-integrity
|
|
63
|
+
|
|
64
|
+
# Stores VSCode versions used for testing VSCode extensions
|
|
65
|
+
.vscode-test
|
|
66
|
+
.clovingprojects
|
|
67
|
+
.yarn
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*
|
package/.husky/_/h
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
[ "$HUSKY" = "2" ] && set -x
|
|
3
|
+
n=$(basename "$0")
|
|
4
|
+
s=$(dirname "$(dirname "$0")")/$n
|
|
5
|
+
|
|
6
|
+
[ ! -f "$s" ] && exit 0
|
|
7
|
+
|
|
8
|
+
if [ -f "$HOME/.huskyrc" ]; then
|
|
9
|
+
echo "husky - '~/.huskyrc' is DEPRECATED, please move your code to ~/.config/husky/init.sh"
|
|
10
|
+
fi
|
|
11
|
+
i="${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh"
|
|
12
|
+
[ -f "$i" ] && . "$i"
|
|
13
|
+
|
|
14
|
+
[ "${HUSKY-}" = "0" ] && exit 0
|
|
15
|
+
|
|
16
|
+
export PATH="node_modules/.bin:$PATH"
|
|
17
|
+
sh -e "$s" "$@"
|
|
18
|
+
c=$?
|
|
19
|
+
|
|
20
|
+
[ $c != 0 ] && echo "husky - $n script failed (code $c)"
|
|
21
|
+
[ $c = 127 ] && echo "husky - command not found in PATH=$PATH"
|
|
22
|
+
exit $c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx lint-staged
|
package/.husky/pre-push
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx lint-prepush
|
package/.prettierrc.json
ADDED
package/.tool-versions
ADDED
package/SECURITY.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Data sensitivity
|
|
4
|
+
|
|
5
|
+
The sensitive data that is currently handled by the Cloving CLI is:
|
|
6
|
+
|
|
7
|
+
- Various AI API keys, which are stored in the cloving configuration within the **user home directory** (`~/.clovingconfig`).
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
Report vulnerabilities to security [at] cloving.ai
|
|
12
|
+
|
|
13
|
+
They will be handled ASAP.
|
|
14
|
+
If the vulnerability is accepted, a mitigation will be implemented and a proper disclosure will be released.
|
|
15
|
+
The triage and mitigation process will depend on the potential severity and impact of the vulnerability.
|
package/cloving.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"languages": [
|
|
3
|
+
{
|
|
4
|
+
"name": "TypeScript",
|
|
5
|
+
"version": "^5.5.4",
|
|
6
|
+
"primary": true,
|
|
7
|
+
"directory": "src",
|
|
8
|
+
"extension": ".ts"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "JavaScript",
|
|
12
|
+
"version": "ES2020",
|
|
13
|
+
"directory": "src",
|
|
14
|
+
"extension": ".js"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"frameworks": [
|
|
18
|
+
{
|
|
19
|
+
"name": "Node.js",
|
|
20
|
+
"type": "Runtime environment",
|
|
21
|
+
"primary": true,
|
|
22
|
+
"directory": "src",
|
|
23
|
+
"extension": ".ts"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "Express",
|
|
27
|
+
"type": "Web framework",
|
|
28
|
+
"version": "^4.19.2",
|
|
29
|
+
"directory": "src",
|
|
30
|
+
"extension": ".ts"
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"testingFrameworks": [
|
|
34
|
+
{
|
|
35
|
+
"name": "Jest",
|
|
36
|
+
"type": "Testing framework",
|
|
37
|
+
"version": "^29.7.0",
|
|
38
|
+
"directory": "tests"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"buildTools": [
|
|
42
|
+
{
|
|
43
|
+
"name": "TypeScript Compiler (tsc)",
|
|
44
|
+
"type": "Transpiler",
|
|
45
|
+
"version": "^5.5.4"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "Vite",
|
|
49
|
+
"type": "Build tool",
|
|
50
|
+
"version": "^5.4.0"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"packageManager": "Yarn",
|
|
54
|
+
"linters": [
|
|
55
|
+
{
|
|
56
|
+
"name": "ESLint",
|
|
57
|
+
"version": "^8.57.0",
|
|
58
|
+
"type": "Linter"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "Prettier",
|
|
62
|
+
"version": "^3.2.5",
|
|
63
|
+
"type": "Code formatter"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"projectType": "Command-line tool"
|
|
67
|
+
}
|
|
@@ -15,6 +15,12 @@ class CommitManager {
|
|
|
15
15
|
options.silent = (0, config_utils_1.getConfig)(options).globalSilent || false;
|
|
16
16
|
this.gpt = new cloving_gpt_1.default(options);
|
|
17
17
|
}
|
|
18
|
+
cleanCommitMessage(message) {
|
|
19
|
+
// Remove markdown code block formatting if present, including any text before and after
|
|
20
|
+
const codeBlockRegex = /.*?```.*\n(.*?)\n```.*/m;
|
|
21
|
+
const match = message.match(codeBlockRegex);
|
|
22
|
+
return match ? match[1].trim() : message.trim();
|
|
23
|
+
}
|
|
18
24
|
async generateCommit() {
|
|
19
25
|
try {
|
|
20
26
|
// Get the git diff
|
|
@@ -28,8 +34,8 @@ class CommitManager {
|
|
|
28
34
|
const prompt = (0, git_utils_1.generateCommitMessagePrompt)(diff);
|
|
29
35
|
// Instantiate ClovingGPT and get the commit message
|
|
30
36
|
const rawCommitMessage = await this.gpt.generateText({ prompt });
|
|
31
|
-
// Clean the commit message using extractMarkdown
|
|
32
|
-
const commitMessage = (0, string_utils_1.extractMarkdown)(rawCommitMessage);
|
|
37
|
+
// Clean the commit message using extractMarkdown and remove code blocks
|
|
38
|
+
const commitMessage = this.cleanCommitMessage((0, string_utils_1.extractMarkdown)(rawCommitMessage));
|
|
33
39
|
// Write the commit message to a temporary file
|
|
34
40
|
const tempCommitFilePath = path_1.default.join('.git', 'SUGGESTED_COMMIT_EDITMSG');
|
|
35
41
|
fs_1.default.writeFileSync(tempCommitFilePath, commitMessage);
|
package/dist/package.json
CHANGED
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Adapter } from '.'
|
|
2
|
+
import type { GPTRequest, OpenAIStreamChunk } from '../../utils/types'
|
|
3
|
+
|
|
4
|
+
export class AzureOpenAIAdapter implements Adapter {
|
|
5
|
+
private model: string
|
|
6
|
+
private endpoint: string
|
|
7
|
+
|
|
8
|
+
static supportedModels: string[] = [
|
|
9
|
+
'azureopenai:gpt:4o-2024-08-06',
|
|
10
|
+
'azureopenai:gpt:4o',
|
|
11
|
+
'azureopenai:gpt:4o-mini',
|
|
12
|
+
'azureopenai:gpt:4-turbo',
|
|
13
|
+
'azureopenai:gpt:3.5-turbo',
|
|
14
|
+
// Add more supported models as needed
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
static listSupportedModels(): void {
|
|
18
|
+
AzureOpenAIAdapter.supportedModels.forEach((model) => {
|
|
19
|
+
console.log(model)
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
constructor(model: string, endpoint: string) {
|
|
24
|
+
this.model = model
|
|
25
|
+
this.endpoint = endpoint
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getEndpoint(): string {
|
|
29
|
+
return this.endpoint
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getHeaders(apiKey: string): Record<string, string> {
|
|
33
|
+
return {
|
|
34
|
+
Authorization: `Bearer ${apiKey}`,
|
|
35
|
+
'Content-Type': 'application/json',
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getPayload(request: GPTRequest, stream: boolean = false): Record<string, any> {
|
|
40
|
+
return {
|
|
41
|
+
model: this.model.replace('azureopenai:', '').replace(':', '-'),
|
|
42
|
+
messages:
|
|
43
|
+
request.messages && request.messages.length > 0
|
|
44
|
+
? request.messages
|
|
45
|
+
: [{ role: 'user', content: request.prompt }],
|
|
46
|
+
max_tokens: request.maxTokens,
|
|
47
|
+
temperature: request.temperature || 0.2,
|
|
48
|
+
stream,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
extractResponse(data: any): string {
|
|
53
|
+
return data.choices[0].message.content
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
convertStream(data: string): OpenAIStreamChunk | null {
|
|
57
|
+
let beginningChar = 0
|
|
58
|
+
let lastChar = 0
|
|
59
|
+
|
|
60
|
+
while (lastChar < data.length) {
|
|
61
|
+
try {
|
|
62
|
+
let remainingString = data.slice(beginningChar, lastChar)
|
|
63
|
+
|
|
64
|
+
const firstBraceIndex = remainingString.indexOf('{')
|
|
65
|
+
if (firstBraceIndex > -1) {
|
|
66
|
+
remainingString = remainingString.slice(firstBraceIndex)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const parsedObject = JSON.parse(remainingString)
|
|
70
|
+
const output = parsedObject?.choices[0]?.delta?.content || ''
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
output,
|
|
74
|
+
lastChar,
|
|
75
|
+
}
|
|
76
|
+
} catch (error) {
|
|
77
|
+
lastChar += 1
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return null
|
|
82
|
+
}
|
|
83
|
+
}
|