enhance: add bb ai:check-common-errors

This commit is contained in:
Tienson Qin
2025-08-13 15:35:33 +08:00
parent 3faee9cc7e
commit 03a004e452
3 changed files with 22 additions and 1 deletions

5
bb.edn
View File

@@ -207,7 +207,10 @@
logseq.tasks.lang/validate-translations
file-sync:integration-tests
logseq.tasks.file-sync/integration-tests}
logseq.tasks.file-sync/integration-tests
ai:check-common-errors
logseq.tasks.common-errors/check-common-errors}
:tasks/config
{:large-vars

View File

@@ -0,0 +1,3 @@
You're Clojure expert, you're responsible to check those common errors:
1. `empty?` should be used instead of `empty` when a boolean value is expected in an expression.

View File

@@ -0,0 +1,15 @@
(ns logseq.tasks.common-errors
"Task to use AI to detect common errors"
(:require [babashka.fs :as fs]
[babashka.process :refer [shell]]
[clojure.string :as string]))
(defn check-common-errors
[]
(let [prompt (String. (fs/read-all-bytes "prompts/clojure_errors.md"))
diff (:out (shell {:out :string} "git diff --no-prefix -U100 -- '*.cljs'"))]
(when-not (string/blank? diff)
(let [command (format "gh models run openai/gpt-5 \"%s\""
(str prompt
(format "\n\n <diff>%s</diff>" diff)))]
(shell command)))))