@@ -180,13 +180,40 @@ export async function authCommand() {
180180 console . log ( chalk . blue . bold ( "\nTxtCode Authentication\n" ) ) ;
181181 console . log ( chalk . gray ( "Configure your TxtCode CLI for remote IDE control\n" ) ) ;
182182
183+ // Check for existing configuration
184+ const existingConfig = loadConfig ( ) ;
185+ if ( existingConfig && existingConfig . providers ) {
186+ console . log ( chalk . yellow ( "⚠️ Existing configuration detected!\n" ) ) ;
187+ console . log ( chalk . gray ( "Currently configured providers:" ) ) ;
188+ Object . keys ( existingConfig . providers ) . forEach ( provider => {
189+ const providerConfig = existingConfig . providers [ provider ] ;
190+ console . log ( chalk . white ( ` • ${ provider } (${ providerConfig . model } )` ) ) ;
191+ } ) ;
192+ console . log ( ) ;
193+
194+ const { shouldOverwrite } = await inquirer . prompt ( [
195+ {
196+ type : "confirm" ,
197+ name : "shouldOverwrite" ,
198+ message : "Do you want to reconfigure? This will overwrite existing providers." ,
199+ default : false ,
200+ } ,
201+ ] ) ;
202+
203+ if ( ! shouldOverwrite ) {
204+ console . log ( chalk . gray ( "\nAuthentication cancelled. Use 'txtcode config' to modify individual settings.\n" ) ) ;
205+ return ;
206+ }
207+ console . log ( chalk . yellow ( "\nReconfiguring all providers...\n" ) ) ;
208+ }
209+
183210 const selectedProviders = new Set < string > ( ) ;
184211
185212 // Helper function to configure a provider
186- async function configureProvider ( label : string ) {
213+ async function configureProvider ( label : string , existingProvider ?: string ) {
187214 console . log ( chalk . cyan ( `\n${ label } \n` ) ) ;
188215
189- // Get available providers (excluding already selected ones)
216+ // Get available providers (excluding already selected ones in this session )
190217 const allProviders = [
191218 { name : "Anthropic (Claude)" , value : "anthropic" } ,
192219 { name : "OpenAI (GPT)" , value : "openai" } ,
@@ -258,6 +285,20 @@ export async function authCommand() {
258285 // Step 3: Configure Secondary Provider 2
259286 const secondaryProvider2 = await configureProvider ( "Secondary AI Provider #2" ) ;
260287
288+ // Validate all providers are unique (safety check)
289+ const allConfiguredProviders = [
290+ primaryProvider . provider ,
291+ secondaryProvider1 . provider ,
292+ secondaryProvider2 . provider ,
293+ ] ;
294+ const uniqueProviders = new Set ( allConfiguredProviders ) ;
295+
296+ if ( uniqueProviders . size !== allConfiguredProviders . length ) {
297+ console . log ( chalk . red ( "\n[ERROR] Duplicate providers detected. Each provider must be unique.\n" ) ) ;
298+ console . log ( chalk . yellow ( "Please run 'txtcode auth' again and select different providers.\n" ) ) ;
299+ process . exit ( 1 ) ;
300+ }
301+
261302 // Step 4: Messaging Platform
262303 const platformAnswers = await inquirer . prompt ( [
263304 {
0 commit comments