-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanalyze-source.lisp
More file actions
executable file
·55 lines (46 loc) · 1.7 KB
/
analyze-source.lisp
File metadata and controls
executable file
·55 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
;;; -*- Lisp -*-
(in-package "GEMINI")
(defconstant +fence+
(if (boundp '+fence+)
(symbol-value '+fence+)
"```"))
(defun fence-start (language)
(declare (optimizable-series-function))
(scan (list (concatenate 'string +fence+ language))))
(defun fence-end ()
(declare (optimizable-series-function))
(scan (list +fence+)))
(defun file->part (filename language)
(part
(str:join #\Newline
(collect 'list
(catenate
(fence-start language)
(scan-file filename #'read-line)
(fence-end))))))
(defun lisp->part (filename)
(file->part filename "lisp"))
(defparameter
*analyze-system-instructions*
(concatenate 'string
h "You are an expert Common Lisp developer with many years experience."
" You will be given a file from a Common Lisp system based on"
" the following system definition."))
(defparameter
*analyze-instructions*
(concatenate 'string
"Analyze the following Common Lisp file."
" Ensure the file follows best practices, look for bugs"
" and ambiguities, check that the file uses ideomatic"
" Common Lisp, note any problem areas, and give concrete,"
" actionable suggestions for improvements."))
(defun analyze-file (system filename)
(let ((*system-instruction*
(content :parts
(list (part *analyze-system-instructions*)
(lisp->part (asdf/system:system-source-file system)))))
(*include-thoughts* t))
(invoke-gemini
(list
(part *analyze-instructions*)
(lisp->part (asdf/system:system-relative-pathname system filename))))))