@@ -167,13 +167,15 @@ Optionally, you can also include a SHORT, 1-paragraph <JUSTIFICATION/>.
167
167
- map
168
168
- fold
169
169
- filter
170
+ - equal
170
171
- zip
171
172
- length
172
173
- Nat/
173
174
- match
174
175
- fold
175
176
- succ
176
177
- zero
178
+ - compare
177
179
- add
178
180
- sub
179
181
- mul
@@ -200,7 +202,8 @@ Optionally, you can also include a SHORT, 1-paragraph <JUSTIFICATION/>.
200
202
Nat/equal is likely to be a pairwise comparison between Nats. As such, it must
201
203
include Nat (obviously), as well as its constructor and match. It returns a
202
204
Bool, so, it must also include its constructors and match. For completion, I've
203
- also added boolean AND and OR, since these are commonly used in comparison.
205
+ also added bool AND and OR, since these are often used in comparison. Finally,
206
+ Nat/compare and List/equal might be similar algorithms, so, I included them.
204
207
</JUSTIFICATION>
205
208
<DEPENDENCIES>
206
209
Nat
@@ -213,18 +216,23 @@ Bool/false
213
216
Bool/match
214
217
Bool/and
215
218
Bool/or
219
+ Nat/compare
220
+ List/equal
216
221
</DEPENDENCIES>
217
222
218
223
# HINTS
219
224
220
225
- Attempt to include ALL files that might be relevant, directly or not.
221
226
227
+ - Always include files that might be similar algorithms to the current one.
228
+ Example: 'Map/set' MUST include 'Mat/get'
229
+
222
230
- If the file is the constructor of an ADT, then, INCLUDE its type.
223
231
Example: 'List/cons' MUST include 'List'
224
232
225
233
- When in doubt, prefer to include MORE, rather than LESS, potencial dependencies.
226
234
227
- - Try to include AT LEAST 8 dependencies, and AT MOST 32 .
235
+ - Try to include AT LEAST 4 dependencies, and AT MOST (only if needed) 16 .
228
236
229
237
- Sometimes the user will give hints in the file. Follow them.
230
238
` . trim ( ) ;
@@ -244,7 +252,7 @@ async function predictDependencies(name, fileContent) {
244
252
}
245
253
return null ;
246
254
} ) ) ;
247
- return files . filter ( file => file !== null ) ;
255
+ return files . filter ( file => file !== null ) . map ( file => ( { ... file , name : file . name . replace ( / \/ _ $ / , '' ) } ) ) ;
248
256
}
249
257
250
258
// Function to build a tree structure from files
@@ -261,7 +269,7 @@ async function predictDependencies(name, fileContent) {
261
269
return result ;
262
270
}
263
271
264
- const allFiles = await getAllKind2Files ( path . join ( path . dirname ( name ) , '..' , '..' , 'book' ) ) ;
272
+ const allFiles = await getAllKind2Files ( "./" ) ;
265
273
const defsTree = buildTree ( allFiles ) ;
266
274
267
275
const aiInput = [
@@ -274,7 +282,7 @@ async function predictDependencies(name, fileContent) {
274
282
'</DEFINITIONS>'
275
283
] . join ( '\n' ) . trim ( ) ;
276
284
277
- const aiOutput = await chat ( "h " ) ( aiInput , { system : system_DepsPredictor , model : "h " } ) ;
285
+ const aiOutput = await chat ( "s " ) ( aiInput , { system : system_DepsPredictor , model : "s " } ) ;
278
286
console . log ( "" ) ;
279
287
280
288
const dependenciesMatch = aiOutput . match ( / < D E P E N D E N C I E S > ( [ \s \S ] * ) < \/ D E P E N D E N C I E S > / ) ;
@@ -302,7 +310,7 @@ async function typeCheck(file) {
302
310
async function main ( ) {
303
311
// Check for correct usage and parse command-line arguments
304
312
if ( process . argv . length < 3 ) {
305
- console . log ( "Usage: kind-refactor <file> <request> [<model>]" ) ;
313
+ console . log ( "Usage: kindcoder <file> <request> [<model>]" ) ;
306
314
process . exit ( 1 ) ;
307
315
}
308
316
@@ -315,7 +323,12 @@ async function main() {
315
323
316
324
// Get directory and file information
317
325
let dir = path . dirname ( file ) ;
318
- let fileContent = await fs . readFile ( file , 'utf-8' ) ;
326
+ let fileContent ;
327
+ try {
328
+ fileContent = await fs . readFile ( file , 'utf-8' ) ;
329
+ } catch ( e ) {
330
+ fileContent = "" ;
331
+ }
319
332
let dirContent = await fs . readdir ( dir ) ;
320
333
321
334
// If the request is empty, replace it by a default request.
0 commit comments