@@ -1011,6 +1011,30 @@ describe('Approval mode tool exclusion logic', () => {
10111011 expect ( excludedTools ) . not . toContain ( WRITE_FILE_TOOL_NAME ) ;
10121012 } ) ;
10131013
1014+ it ( 'should exclude all interactive tools in non-interactive mode with plan approval mode' , async ( ) => {
1015+ process . argv = [
1016+ 'node' ,
1017+ 'script.js' ,
1018+ '--approval-mode' ,
1019+ 'plan' ,
1020+ '-p' ,
1021+ 'test' ,
1022+ ] ;
1023+ const settings = createTestMergedSettings ( {
1024+ experimental : {
1025+ plan : true ,
1026+ } ,
1027+ } ) ;
1028+ const argv = await parseArguments ( createTestMergedSettings ( ) ) ;
1029+
1030+ const config = await loadCliConfig ( settings , 'test-session' , argv ) ;
1031+
1032+ const excludedTools = config . getExcludeTools ( ) ;
1033+ expect ( excludedTools ) . toContain ( SHELL_TOOL_NAME ) ;
1034+ expect ( excludedTools ) . toContain ( EDIT_TOOL_NAME ) ;
1035+ expect ( excludedTools ) . toContain ( WRITE_FILE_TOOL_NAME ) ;
1036+ } ) ;
1037+
10141038 it ( 'should exclude no interactive tools in non-interactive mode with legacy yolo flag' , async ( ) => {
10151039 process . argv = [ 'node' , 'script.js' , '--yolo' , '-p' , 'test' ] ;
10161040 const argv = await parseArguments ( createTestMergedSettings ( ) ) ;
@@ -1099,7 +1123,7 @@ describe('Approval mode tool exclusion logic', () => {
10991123 await expect (
11001124 loadCliConfig ( settings , 'test-session' , invalidArgv as CliArgs ) ,
11011125 ) . rejects . toThrow (
1102- 'Invalid approval mode: invalid_mode. Valid values are: yolo, auto_edit, default' ,
1126+ 'Invalid approval mode: invalid_mode. Valid values are: yolo, auto_edit, plan, default' ,
11031127 ) ;
11041128 } ) ;
11051129} ) ;
@@ -2052,6 +2076,42 @@ describe('loadCliConfig approval mode', () => {
20522076 expect ( config . getApprovalMode ( ) ) . toBe ( ServerConfig . ApprovalMode . YOLO ) ;
20532077 } ) ;
20542078
2079+ it ( 'should set Plan approval mode when --approval-mode=plan is used and experimental.plan is enabled' , async ( ) => {
2080+ process . argv = [ 'node' , 'script.js' , '--approval-mode' , 'plan' ] ;
2081+ const argv = await parseArguments ( createTestMergedSettings ( ) ) ;
2082+ const settings = createTestMergedSettings ( {
2083+ experimental : {
2084+ plan : true ,
2085+ } ,
2086+ } ) ;
2087+ const config = await loadCliConfig ( settings , 'test-session' , argv ) ;
2088+ expect ( config . getApprovalMode ( ) ) . toBe ( ServerConfig . ApprovalMode . PLAN ) ;
2089+ } ) ;
2090+
2091+ it ( 'should throw error when --approval-mode=plan is used but experimental.plan is disabled' , async ( ) => {
2092+ process . argv = [ 'node' , 'script.js' , '--approval-mode' , 'plan' ] ;
2093+ const argv = await parseArguments ( createTestMergedSettings ( ) ) ;
2094+ const settings = createTestMergedSettings ( {
2095+ experimental : {
2096+ plan : false ,
2097+ } ,
2098+ } ) ;
2099+
2100+ await expect ( loadCliConfig ( settings , 'test-session' , argv ) ) . rejects . toThrow (
2101+ 'Approval mode "plan" is only available when experimental.plan is enabled.' ,
2102+ ) ;
2103+ } ) ;
2104+
2105+ it ( 'should throw error when --approval-mode=plan is used but experimental.plan setting is missing' , async ( ) => {
2106+ process . argv = [ 'node' , 'script.js' , '--approval-mode' , 'plan' ] ;
2107+ const argv = await parseArguments ( createTestMergedSettings ( ) ) ;
2108+ const settings = createTestMergedSettings ( { } ) ;
2109+
2110+ await expect ( loadCliConfig ( settings , 'test-session' , argv ) ) . rejects . toThrow (
2111+ 'Approval mode "plan" is only available when experimental.plan is enabled.' ,
2112+ ) ;
2113+ } ) ;
2114+
20552115 // --- Untrusted Folder Scenarios ---
20562116 describe ( 'when folder is NOT trusted' , ( ) => {
20572117 beforeEach ( ( ) => {
0 commit comments