cloving 0.3.17 → 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.
Files changed (102) hide show
  1. package/.DS_Store +0 -0
  2. package/.aider.chat.history.md +16978 -0
  3. package/.aider.input.history +15 -0
  4. package/.aider.tags.cache.v3/cache.db +0 -0
  5. package/.aider.tags.cache.v3/cache.db-shm +0 -0
  6. package/.aider.tags.cache.v3/cache.db-wal +0 -0
  7. package/.cursorrules +77 -0
  8. package/.github/workflows/auto-release.yml +83 -0
  9. package/.github/workflows/ci.yml +32 -0
  10. package/.github/workflows/npm-publish.yml +34 -0
  11. package/.gitignore +67 -0
  12. package/.husky/_/.gitignore +1 -0
  13. package/.husky/_/applypatch-msg +2 -0
  14. package/.husky/_/commit-msg +2 -0
  15. package/.husky/_/h +22 -0
  16. package/.husky/_/husky.sh +9 -0
  17. package/.husky/_/post-applypatch +2 -0
  18. package/.husky/_/post-checkout +2 -0
  19. package/.husky/_/post-commit +2 -0
  20. package/.husky/_/post-merge +2 -0
  21. package/.husky/_/post-rewrite +2 -0
  22. package/.husky/_/pre-applypatch +2 -0
  23. package/.husky/_/pre-auto-gc +2 -0
  24. package/.husky/_/pre-commit +2 -0
  25. package/.husky/_/pre-merge-commit +2 -0
  26. package/.husky/_/pre-push +2 -0
  27. package/.husky/_/pre-rebase +2 -0
  28. package/.husky/_/prepare-commit-msg +2 -0
  29. package/.husky/pre-commit +1 -0
  30. package/.husky/pre-push +1 -0
  31. package/.prettierrc.json +7 -0
  32. package/.tool-versions +2 -0
  33. package/SECURITY.md +15 -0
  34. package/cloving.json +67 -0
  35. package/dist/cloving_gpt/adapters/openai.js +2 -0
  36. package/dist/commands/generate/context.js +1 -1
  37. package/dist/commands/tokens.js +1 -1
  38. package/dist/managers/CommitManager.js +8 -2
  39. package/dist/managers/ProxyManager.js +9 -2
  40. package/dist/managers/StreamManager.js +1 -1
  41. package/dist/package.json +26 -26
  42. package/dist/utils/config_utils.js +21 -4
  43. package/dist/utils/git_utils.js +109 -7
  44. package/dist/utils/prompt_utils.js +3 -3
  45. package/jest.config.js +11 -0
  46. package/package.json +23 -23
  47. package/src/cloving_gpt/adapters/azureopenai.ts +83 -0
  48. package/src/cloving_gpt/adapters/claude.ts +140 -0
  49. package/src/cloving_gpt/adapters/gemini.ts +146 -0
  50. package/src/cloving_gpt/adapters/index.ts +43 -0
  51. package/src/cloving_gpt/adapters/mistral.ts +142 -0
  52. package/src/cloving_gpt/adapters/ollama.ts +136 -0
  53. package/src/cloving_gpt/adapters/openai.ts +113 -0
  54. package/src/cloving_gpt/index.ts +229 -0
  55. package/src/commands/chat.ts +12 -0
  56. package/src/commands/config.ts +192 -0
  57. package/src/commands/generate/code.ts +18 -0
  58. package/src/commands/generate/commit.ts +9 -0
  59. package/src/commands/generate/context.ts +93 -0
  60. package/src/commands/generate/docs.ts +9 -0
  61. package/src/commands/generate/review.ts +9 -0
  62. package/src/commands/generate/shell.ts +9 -0
  63. package/src/commands/generate/unit_tests.ts +9 -0
  64. package/src/commands/init.ts +9 -0
  65. package/src/commands/models.ts +21 -0
  66. package/src/commands/proxy.ts +9 -0
  67. package/src/commands/tokens.ts +82 -0
  68. package/src/index.ts +197 -0
  69. package/src/managers/BlockManager.ts +126 -0
  70. package/src/managers/ChatManager.ts +755 -0
  71. package/src/managers/ChunkManager.ts +31 -0
  72. package/src/managers/CodeManager.ts +226 -0
  73. package/src/managers/CommitManager.ts +71 -0
  74. package/src/managers/DocsManager.ts +101 -0
  75. package/src/managers/InitManager.ts +263 -0
  76. package/src/managers/ProxyManager.ts +240 -0
  77. package/src/managers/ReviewManager.ts +154 -0
  78. package/src/managers/ShellManager.ts +172 -0
  79. package/src/managers/StreamManager.ts +353 -0
  80. package/src/managers/UnitTestManager.ts +293 -0
  81. package/src/utils/config_utils.ts +271 -0
  82. package/src/utils/git_utils.ts +230 -0
  83. package/src/utils/model_utils.ts +3 -0
  84. package/src/utils/prompt_utils.ts +375 -0
  85. package/src/utils/prompts/CODEGEN_COULDNT_APPLY.md +5 -0
  86. package/src/utils/prompts/CODEGEN_EXAMPLES.md +82 -0
  87. package/src/utils/prompts/CODEGEN_INSTRUCTIONS.md +43 -0
  88. package/src/utils/prompts/DOCS_INSTRUCTIONS.md +9 -0
  89. package/src/utils/prompts/INIT_INSTRUCTIONS.md +132 -0
  90. package/src/utils/prompts/REVIEW_INSTRUCTIONS.md +49 -0
  91. package/src/utils/prompts/SHELL_INSTRUCTIONS.md +15 -0
  92. package/src/utils/prompts/SPECIAL_FILES.md +66 -0
  93. package/src/utils/prompts/index.ts +37 -0
  94. package/src/utils/string_utils.ts +552 -0
  95. package/src/utils/types.ts +127 -0
  96. package/tests/commands/generate/unit_tests.test.ts +27 -0
  97. package/tests/utils/git_utils.test.ts +116 -0
  98. package/tests/utils/model_utils.test.ts +27 -0
  99. package/tests/utils/prompt_utils.test.ts +33 -0
  100. package/tests/utils/string_utils.test.ts +560 -0
  101. package/tsconfig.json +14 -0
  102. 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
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
+ *
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
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,9 @@
1
+ echo "husky - DEPRECATED
2
+
3
+ Please remove the following two lines from $0:
4
+
5
+ #!/usr/bin/env sh
6
+ . \"\$(dirname -- \"\$0\")/_/husky.sh\"
7
+
8
+ They WILL FAIL in v10.0.0
9
+ "
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname "$0")/h"
@@ -0,0 +1 @@
1
+ npx lint-staged
@@ -0,0 +1 @@
1
+ npx lint-prepush
@@ -0,0 +1,7 @@
1
+ {
2
+ "semi": false,
3
+ "trailingComma": "all",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2
7
+ }
package/.tool-versions ADDED
@@ -0,0 +1,2 @@
1
+ yarn 1.22.22
2
+ nodejs 20.16.0
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
+ }
@@ -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
  /**
@@ -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);
@@ -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) || [];