@@ -28,6 +28,8 @@ async function findUnusedFiles(directory) {
28
28
// Agent 2: Comment Quality Evaluator
29
29
async function moveComments ( filePath ) {
30
30
const fileContent = fs . readFileSync ( filePath , "utf-8" ) ;
31
+ console . log ( 'acorn' , filePath )
32
+ //install -g uglify-js
31
33
// const response = await ollama.generate({
32
34
// model: "codellama:13b",
33
35
// prompt: `Evaluate the following code comments and suggest improvements or removal of unnecessary ones:\n\n${fileContent}`,
@@ -49,7 +51,8 @@ async function moveComments(filePath) {
49
51
} ) ;
50
52
51
53
let newFileContent = acorn . generate ( ast ) ;
52
- fs . writeFileSync ( filePath , newFileContent ) ;
54
+ console . log ( newFileContent )
55
+ //fs.writeFileSync(filePath, newFileContent);
53
56
return { newFileContent, comments } ;
54
57
// Process the response and return suggestions
55
58
}
@@ -95,15 +98,17 @@ async function runAllAgents(directory) {
95
98
//const directorySuggestions = await suggestDirectorySimplifications(directory);
96
99
//saveSuggestions({ directory_suggestions: directorySuggestions }, "directory_suggestions.json");
97
100
let count = {
98
- comments : { }
101
+ comments : { } ,
102
+ by_extension : { } ,
99
103
100
104
}
101
105
102
106
files . forEach ( file => {
103
- count [ path . extname ( file ) ] = ( count [ path . extname ( file ) ] || 0 ) + fs . readFileSync ( file , 'utf-8' ) . length
104
- count [ 'comments' ] [ file ] = moveComments ( file )
105
- count [ file ] = fs . readFileSync ( file , 'utf-8' ) . length
106
-
107
+ if ( path . extname ( file ) === '.js' || path . extname ( file ) === '.ts' || path . extname ( file ) === '.jsx' || path . extname ( file ) === '.tsx' ) {
108
+ count . by_extension [ path . extname ( file ) ] = ( count . by_extension [ path . extname ( file ) ] || 0 ) + fs . readFileSync ( file , 'utf-8' ) . length
109
+ //count['comments'][file] = moveComments(file)
110
+ count [ file ] = fs . readFileSync ( file , 'utf-8' ) . length
111
+ }
107
112
} ) ;
108
113
109
114
//console.log(count)
@@ -113,6 +118,41 @@ async function runAllAgents(directory) {
113
118
114
119
//anthropci ---- 200k maximum
115
120
//gemini 2 million token context window
121
+
122
+
123
+ // Move all JSX and TSX files to a folder called 'views'
124
+ const moveFilesToViews = async ( ) => {
125
+ const viewsDir = path . join ( root_dir , 'views' ) ;
126
+ if ( ! fs . existsSync ( viewsDir ) ) {
127
+ fs . mkdirSync ( viewsDir ) ;
128
+ }
129
+
130
+ files . filter ( file => file . endsWith ( '.jsx' ) || file . endsWith ( '.tsx' ) ) . forEach ( file => {
131
+ const newFilePath = path . join ( viewsDir , path . basename ( file ) ) ;
132
+ fs . renameSync ( file , newFilePath ) ;
133
+ console . log ( `Moved ${ file } to ${ newFilePath } ` ) ;
134
+ } ) ;
135
+ } ;
136
+
137
+ // Move all HTML files to a folder called 'views/archive'
138
+ const moveHtmlFilesToArchive = async ( ) => {
139
+ const archiveDir = path . join ( root_dir , 'views' , 'archive' ) ;
140
+ if ( ! fs . existsSync ( archiveDir ) ) {
141
+ fs . mkdirSync ( archiveDir , { recursive : true } ) ;
142
+ }
143
+
144
+ files . filter ( file => file . endsWith ( '.html' ) ) . forEach ( file => {
145
+ const newFilePath = path . join ( archiveDir , path . basename ( file ) ) ;
146
+ fs . renameSync ( file , newFilePath ) ;
147
+ console . log ( `Moved ${ file } to ${ newFilePath } ` ) ;
148
+ } ) ;
149
+ } ;
150
+
151
+ await moveFilesToViews ( ) ;
152
+ await moveHtmlFilesToArchive ( ) ;
153
+
154
+
155
+
116
156
}
117
157
118
158
runAllAgents ( )
0 commit comments