@@ -11,13 +11,13 @@ import {
1111import { PromptBuilder } from '@/utils/prompt-builder'
1212import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
1313
14- export const build_commit_message_prompt = async (
15- diff : string ,
16- repository : GitRepository ,
17- context_files : string [ ] = [ ] ,
18- workspace_provider ?: WorkspaceProvider ,
14+ export const build_commit_message_prompt = async ( params : {
15+ diff : string
16+ repository : GitRepository
17+ context_files ? : string [ ]
18+ workspace_provider ?: WorkspaceProvider
1919 diffs_only ?: boolean
20- ) : Promise < {
20+ } ) : Promise < {
2121 api_prompt : string
2222 chatbot_prompt : string
2323 cli_prompt : string
@@ -28,7 +28,9 @@ export const build_commit_message_prompt = async (
2828 config . inspect < string > ( 'commitMessageInstructions' ) ?. defaultValue ||
2929 ''
3030
31- const file_diffs = diff . split ( / ^ d i f f - - g i t / m) . filter ( ( d ) => d . trim ( ) !== '' )
31+ const file_diffs = params . diff
32+ . split ( / ^ d i f f - - g i t / m)
33+ . filter ( ( d ) => d . trim ( ) !== '' )
3234
3335 let changes_content = ''
3436 let context_content = ''
@@ -98,14 +100,14 @@ export const build_commit_message_prompt = async (
98100
99101 let is_ignored = false
100102
101- if ( file_path && workspace_provider ) {
103+ if ( file_path && params . workspace_provider ) {
102104 const absolute_path = vscode . Uri . joinPath (
103- repository . rootUri ,
105+ params . repository . rootUri ,
104106 file_path
105107 ) . fsPath
106108 if (
107- workspace_provider . is_ignored_by_patterns ( absolute_path ) ||
108- workspace_provider . is_excluded ( file_path )
109+ params . workspace_provider . is_ignored_by_patterns ( absolute_path ) ||
110+ params . workspace_provider . is_excluded ( file_path )
109111 ) {
110112 is_ignored = true
111113 }
@@ -139,7 +141,7 @@ export const build_commit_message_prompt = async (
139141 const should_include_full_content = ! is_ignored
140142
141143 if (
142- ! diffs_only &&
144+ ! params . diffs_only &&
143145 ! is_deleted &&
144146 file_path &&
145147 ! is_binary &&
@@ -148,9 +150,12 @@ export const build_commit_message_prompt = async (
148150 try {
149151 let full_content = ''
150152 try {
151- full_content = await repository . show ( '' , file_path )
153+ full_content = await params . repository . show ( '' , file_path )
152154 } catch {
153- const uri = vscode . Uri . joinPath ( repository . rootUri , file_path )
155+ const uri = vscode . Uri . joinPath (
156+ params . repository . rootUri ,
157+ file_path
158+ )
154159 const content = await vscode . workspace . fs . readFile ( uri )
155160 if ( ! content . includes ( 0 ) ) {
156161 full_content = Buffer . from ( content ) . toString ( 'utf8' )
@@ -189,22 +194,22 @@ export const build_commit_message_prompt = async (
189194 }
190195
191196 const context_results = await Promise . all (
192- context_files . map ( async ( file_path ) => {
193- if ( workspace_provider ) {
197+ ( params . context_files || [ ] ) . map ( async ( file_path ) => {
198+ if ( params . workspace_provider ) {
194199 const absolute_path = vscode . Uri . joinPath (
195- repository . rootUri ,
200+ params . repository . rootUri ,
196201 file_path
197202 ) . fsPath
198203 if (
199- workspace_provider . is_ignored_by_patterns ( absolute_path ) ||
200- workspace_provider . is_excluded ( file_path )
204+ params . workspace_provider . is_ignored_by_patterns ( absolute_path ) ||
205+ params . workspace_provider . is_excluded ( file_path )
201206 ) {
202207 return ''
203208 }
204209 }
205210
206211 try {
207- const uri = vscode . Uri . joinPath ( repository . rootUri , file_path )
212+ const uri = vscode . Uri . joinPath ( params . repository . rootUri , file_path )
208213 const content_uint8 = await vscode . workspace . fs . readFile ( uri )
209214 if ( ! content_uint8 . includes ( 0 ) ) {
210215 const full_content = Buffer . from ( content_uint8 ) . toString ( 'utf8' )
0 commit comments