@@ -11,6 +11,7 @@ import { activateGuide } from './guide';
1111import { ChatPanel } from './chatPanel' ;
1212import { isUnderTokenLimit , initTokenizer } from './deepseekTokenizer' ;
1313import * as ragService from './ragService' ;
14+ import { collectSupportedFiles } from './languageMapping' ;
1415
1516let currentOperationController : AbortController | null = null ;
1617
@@ -211,6 +212,36 @@ export function activate(context: vscode.ExtensionContext) {
211212 vscode . window . showInformationMessage ( `CVB file generated at: ${ cvbFilePath } ` ) ;
212213 } ) ;
213214
215+ // New command for the context menu
216+ let packupToCvbCommand = vscode . commands . registerCommand ( 'codeReDesign.packupToCvb' , async ( uri : vscode . Uri , selectedUris : vscode . Uri [ ] ) => {
217+ // Collect URIs (prioritize selectedUris for multi-selection)
218+ const uris : vscode . Uri [ ] = selectedUris && selectedUris . length > 0 ? selectedUris : uri ? [ uri ] : [ ] ;
219+
220+ if ( uris . length === 0 ) {
221+ vscode . window . showErrorMessage ( 'No files or folders selected.' ) ;
222+ return ;
223+ }
224+
225+ // Collect all supported files (recursively for folders)
226+ const filePaths = await collectSupportedFiles ( uris ) ;
227+
228+ const userRequest = await vscode . window . showInputBox ( {
229+ prompt : 'Enter your refactoring request' ,
230+ placeHolder : 'e.g., Move all mouse event handling code to a single file' ,
231+ } ) ;
232+
233+ if ( ! userRequest ) {
234+ return ;
235+ }
236+
237+ try {
238+ const cvbFilePath = generateCvb ( filePaths , userRequest ) ;
239+ vscode . window . showInformationMessage ( `CVB file generated at: ${ cvbFilePath } ` ) ;
240+ } catch ( error ) {
241+ vscode . window . showErrorMessage ( `Failed to generate CVB file: ${ ( error as Error ) . message } ` ) ;
242+ }
243+ } ) ;
244+
214245 // 注册命令:上传 CVB 并调用 API
215246 let redesignCvbCommand = vscode . commands . registerCommand ( 'codeReDesign.redesignCvb' , async ( ) => {
216247 const workspaceFolders = vscode . workspace . workspaceFolders ;
@@ -367,7 +398,7 @@ export function activate(context: vscode.ExtensionContext) {
367398 }
368399 } ) ;
369400
370- context . subscriptions . push ( generateCvbCommand , redesignCvbCommand , applyCvbCommand , stopOperation , analyzeCodeCommand , outputChannel , startChatCommand ) ;
401+ context . subscriptions . push ( generateCvbCommand , redesignCvbCommand , applyCvbCommand , stopOperation , analyzeCodeCommand , startChatCommand , packupToCvbCommand ) ;
371402
372403 setupCvbAsMarkdown ( context ) ;
373404
0 commit comments