@@ -19,6 +19,8 @@ import {
1919 debugLogger ,
2020 ApprovalMode ,
2121 type MCPServerConfig ,
22+ type GeminiCLIExtension ,
23+ Storage ,
2224} from '@google/gemini-cli-core' ;
2325import { loadCliConfig , parseArguments , type CliArgs } from './config.js' ;
2426import {
@@ -3524,4 +3526,75 @@ describe('loadCliConfig mcpEnabled', () => {
35243526 expect ( config . getAllowedMcpServers ( ) ) . toEqual ( [ 'serverA' ] ) ;
35253527 expect ( config . getBlockedMcpServers ( ) ) . toEqual ( [ 'serverB' ] ) ;
35263528 } ) ;
3529+
3530+ describe ( 'extension plan settings' , ( ) => {
3531+ beforeEach ( ( ) => {
3532+ vi . spyOn ( Storage . prototype , 'getProjectTempDir' ) . mockReturnValue (
3533+ '/tmp/test-project' ,
3534+ ) ;
3535+ } ) ;
3536+
3537+ it ( 'should use plan directory from active extension when user has not specified one' , async ( ) => {
3538+ process . argv = [ 'node' , 'script.js' ] ;
3539+ const settings = createTestMergedSettings ( {
3540+ experimental : { plan : true } ,
3541+ } ) ;
3542+ const argv = await parseArguments ( settings ) ;
3543+
3544+ vi . spyOn ( ExtensionManager . prototype , 'getExtensions' ) . mockReturnValue ( [
3545+ {
3546+ name : 'ext-plan' ,
3547+ isActive : true ,
3548+ plan : { directory : 'ext-plans-dir' } ,
3549+ } as unknown as GeminiCLIExtension ,
3550+ ] ) ;
3551+
3552+ const config = await loadCliConfig ( settings , 'test-session' , argv ) ;
3553+ expect ( config . storage . getPlansDir ( ) ) . toContain ( 'ext-plans-dir' ) ;
3554+ } ) ;
3555+
3556+ it ( 'should NOT use plan directory from active extension when user has specified one' , async ( ) => {
3557+ process . argv = [ 'node' , 'script.js' ] ;
3558+ const settings = createTestMergedSettings ( {
3559+ experimental : { plan : true } ,
3560+ general : {
3561+ plan : { directory : 'user-plans-dir' } ,
3562+ } ,
3563+ } ) ;
3564+ const argv = await parseArguments ( settings ) ;
3565+
3566+ vi . spyOn ( ExtensionManager . prototype , 'getExtensions' ) . mockReturnValue ( [
3567+ {
3568+ name : 'ext-plan' ,
3569+ isActive : true ,
3570+ plan : { directory : 'ext-plans-dir' } ,
3571+ } as unknown as GeminiCLIExtension ,
3572+ ] ) ;
3573+
3574+ const config = await loadCliConfig ( settings , 'test-session' , argv ) ;
3575+ expect ( config . storage . getPlansDir ( ) ) . toContain ( 'user-plans-dir' ) ;
3576+ expect ( config . storage . getPlansDir ( ) ) . not . toContain ( 'ext-plans-dir' ) ;
3577+ } ) ;
3578+
3579+ it ( 'should NOT use plan directory from inactive extension' , async ( ) => {
3580+ process . argv = [ 'node' , 'script.js' ] ;
3581+ const settings = createTestMergedSettings ( {
3582+ experimental : { plan : true } ,
3583+ } ) ;
3584+ const argv = await parseArguments ( settings ) ;
3585+
3586+ vi . spyOn ( ExtensionManager . prototype , 'getExtensions' ) . mockReturnValue ( [
3587+ {
3588+ name : 'ext-plan' ,
3589+ isActive : false ,
3590+ plan : { directory : 'ext-plans-dir-inactive' } ,
3591+ } as unknown as GeminiCLIExtension ,
3592+ ] ) ;
3593+
3594+ const config = await loadCliConfig ( settings , 'test-session' , argv ) ;
3595+ expect ( config . storage . getPlansDir ( ) ) . not . toContain (
3596+ 'ext-plans-dir-inactive' ,
3597+ ) ;
3598+ } ) ;
3599+ } ) ;
35273600} ) ;
0 commit comments