@@ -516,6 +516,24 @@ describe("Command Blocker", () => {
516516 await expect (
517517 plugin [ "tool.execute.before" ] ( input3 , output3 )
518518 ) . rejects . toThrow ( ) ;
519+
520+ const input4 = { tool : "bash" } ;
521+ const output4 = { args : { command : "git checkout file.txt" } } ;
522+ await expect (
523+ plugin [ "tool.execute.before" ] ( input4 , output4 )
524+ ) . rejects . toThrow ( ) ;
525+
526+ const input5 = { tool : "bash" } ;
527+ const output5 = { args : { command : "git checkout HEAD -- file.txt" } } ;
528+ await expect (
529+ plugin [ "tool.execute.before" ] ( input5 , output5 )
530+ ) . rejects . toThrow ( ) ;
531+
532+ const input6 = { tool : "bash" } ;
533+ const output6 = { args : { command : "git checkout main" } } ;
534+ await expect (
535+ plugin [ "tool.execute.before" ] ( input6 , output6 )
536+ ) . rejects . toThrow ( ) ;
519537 } ) ;
520538
521539 it ( "should allow non-git commands" , async ( ) => {
@@ -1047,80 +1065,7 @@ describe("Command Blocker", () => {
10471065 } ) ;
10481066 } ) ;
10491067
1050- describe ( "checkNixFileContent" , ( ) => {
1051- let plugin : any ;
1052- let mockApp : any ;
1053- let mockClient : any ;
1054- let mock$ : any ;
1055-
1056- beforeEach ( async ( ) => {
1057- mockApp = { } ;
1058- mockClient = { } ;
1059- mock$ = { } ;
1060- plugin = await CommandBlocker ( {
1061- app : mockApp ,
1062- client : mockClient ,
1063- $ : mock$ ,
1064- } ) ;
1065- } ) ;
1066-
1067- it ( "should block npm install in nix files" , async ( ) => {
1068- const input1 = { tool : "edit" } ;
1069- const output1 = {
1070- args : { filePath : "flake.nix" , newString : "npm install package" } ,
1071- } ;
1072- await expect (
1073- plugin [ "tool.execute.before" ] ( input1 , output1 )
1074- ) . rejects . toThrow (
1075- "`npm install` has no internet access during build in Nix sandbox"
1076- ) ;
1077-
1078- const input2 = { tool : "edit" } ;
1079- const output2 = {
1080- args : {
1081- filePath : "default.nix" ,
1082- newString : "some content npm install" ,
1083- } ,
1084- } ;
1085- await expect (
1086- plugin [ "tool.execute.before" ] ( input2 , output2 )
1087- ) . rejects . toThrow ( ) ;
1088- } ) ;
1089-
1090- it ( "should allow other content in nix files" , async ( ) => {
1091- const input = { tool : "edit" } ;
1092- const output = {
1093- args : { filePath : "flake.nix" , newString : "some nix content" } ,
1094- } ;
1095- await expect (
1096- plugin [ "tool.execute.before" ] ( input , output )
1097- ) . resolves . toBeUndefined ( ) ;
1098- } ) ;
1099-
1100- it ( "should allow npm install in non-nix files" , async ( ) => {
1101- const input = { tool : "edit" } ;
1102- const output = {
1103- args : { filePath : "package.json" , newString : "npm install" } ,
1104- } ;
1105- await expect (
1106- plugin [ "tool.execute.before" ] ( input , output )
1107- ) . resolves . toBeUndefined ( ) ;
1108- } ) ;
11091068
1110- it ( "should handle empty inputs" , async ( ) => {
1111- const input1 = { tool : "edit" } ;
1112- const output1 = { args : { filePath : "" , newString : "content" } } ;
1113- await expect (
1114- plugin [ "tool.execute.before" ] ( input1 , output1 )
1115- ) . resolves . toBeUndefined ( ) ;
1116-
1117- const input2 = { tool : "edit" } ;
1118- const output2 = { args : { filePath : "file.nix" , newString : "" } } ;
1119- await expect (
1120- plugin [ "tool.execute.before" ] ( input2 , output2 )
1121- ) . resolves . toBeUndefined ( ) ;
1122- } ) ;
1123- } ) ;
11241069
11251070 describe ( "checkTypeScriptAnyType" , ( ) => {
11261071 let plugin : any ;
@@ -1139,32 +1084,30 @@ describe("Command Blocker", () => {
11391084 } ) ;
11401085 } ) ;
11411086
1142- it ( "should block any type annotations" , async ( ) => {
1087+ it ( "should allow any type annotations (temporarily disabled) " , async ( ) => {
11431088 const input1 = { tool : "edit" } ;
11441089 const output1 = {
11451090 args : { filePath : "test.ts" , newString : "const x: any = 5;" } ,
11461091 } ;
11471092 await expect (
11481093 plugin [ "tool.execute.before" ] ( input1 , output1 )
1149- ) . rejects . toThrow (
1150- "`any` type annotations are blocked in TypeScript files. Use proper type annotations for better type safety."
1151- ) ;
1094+ ) . resolves . toBeUndefined ( ) ;
11521095
11531096 const input2 = { tool : "edit" } ;
11541097 const output2 = {
11551098 args : { filePath : "test.ts" , newString : "function f(param: any) {}" } ,
11561099 } ;
11571100 await expect (
11581101 plugin [ "tool.execute.before" ] ( input2 , output2 )
1159- ) . rejects . toThrow ( ) ;
1102+ ) . resolves . toBeUndefined ( ) ;
11601103
11611104 const input3 = { tool : "edit" } ;
11621105 const output3 = {
11631106 args : { filePath : "test.ts" , newString : "const arr: any[] = [];" } ,
11641107 } ;
11651108 await expect (
11661109 plugin [ "tool.execute.before" ] ( input3 , output3 )
1167- ) . rejects . toThrow ( ) ;
1110+ ) . resolves . toBeUndefined ( ) ;
11681111
11691112 const input4 = { tool : "edit" } ;
11701113 const output4 = {
@@ -1175,15 +1118,15 @@ describe("Command Blocker", () => {
11751118 } ;
11761119 await expect (
11771120 plugin [ "tool.execute.before" ] ( input4 , output4 )
1178- ) . rejects . toThrow ( ) ;
1121+ ) . resolves . toBeUndefined ( ) ;
11791122
11801123 const input5 = { tool : "edit" } ;
11811124 const output5 = {
11821125 args : { filePath : "test.ts" , newString : "const x = value as any;" } ,
11831126 } ;
11841127 await expect (
11851128 plugin [ "tool.execute.before" ] ( input5 , output5 )
1186- ) . rejects . toThrow ( ) ;
1129+ ) . resolves . toBeUndefined ( ) ;
11871130 } ) ;
11881131
11891132 it ( "should allow proper type annotations" , async ( ) => {
@@ -1274,24 +1217,9 @@ describe("Command Blocker", () => {
12741217 ) ;
12751218 } ) ;
12761219
1277- it ( "should check file content for nix files" , async ( ) => {
1278- const plugin = await CommandBlocker ( {
1279- app : mockApp ,
1280- client : mockClient ,
1281- $ : mock$ ,
1282- } ) ;
1283- const input = { tool : "edit" } ;
1284- const output = {
1285- args : { filePath : "flake.nix" , newString : "npm install package" } ,
1286- } ;
12871220
1288- const hook = ( plugin as PluginHook ) [ "tool.execute.before" ] ;
1289- await expect ( hook ( input , output ) ) . rejects . toThrow (
1290- "`npm install` has no internet access during build in Nix sandbox"
1291- ) ;
1292- } ) ;
12931221
1294- it ( "should check file content for TypeScript any types" , async ( ) => {
1222+ it ( "should allow file content with TypeScript any types (temporarily disabled) " , async ( ) => {
12951223 const plugin = await CommandBlocker ( {
12961224 app : mockApp ,
12971225 client : mockClient ,
@@ -1304,9 +1232,7 @@ describe("Command Blocker", () => {
13041232
13051233 await expect (
13061234 plugin [ "tool.execute.before" ] ( input , output )
1307- ) . rejects . toThrow (
1308- "`any` type annotations are blocked in TypeScript files"
1309- ) ;
1235+ ) . resolves . toBeUndefined ( ) ;
13101236 } ) ;
13111237
13121238 it ( "should check bash commands" , async ( ) => {
0 commit comments