|
10 | 10 | [eca.features.prompt :as f.prompt] |
11 | 11 | [eca.features.tools.mcp :as f.mcp] |
12 | 12 | [eca.llm-api :as llm-api] |
13 | | - [eca.shared :as shared :refer [multi-str]])) |
| 13 | + [eca.shared :as shared :refer [multi-str update-some]])) |
14 | 14 |
|
15 | 15 | (set! *warn-on-reflection* true) |
16 | 16 |
|
|
105 | 105 | :type :native |
106 | 106 | :description "Prompt sent to LLM as system instructions." |
107 | 107 | :arguments []}] |
108 | | - custom-commands (map (fn [custom] |
109 | | - {:name (:name custom) |
110 | | - :type :custom-prompt |
111 | | - :description (:path custom) |
112 | | - :arguments []}) |
113 | | - (custom-commands config (:workspace-folders db)))] |
| 108 | + custom-cmds (map (fn [custom] |
| 109 | + {:name (:name custom) |
| 110 | + :type :custom-prompt |
| 111 | + :description (:path custom) |
| 112 | + :arguments []}) |
| 113 | + (custom-commands config (:workspace-folders db)))] |
114 | 114 | (concat mcp-prompts |
115 | 115 | eca-commands |
116 | | - custom-commands))) |
| 116 | + custom-cmds))) |
117 | 117 |
|
118 | | -(defn ^:private get-custom-command [command args custom-commands] |
| 118 | +(defn ^:private get-custom-command [command args custom-cmds] |
119 | 119 | (when-let [raw-content (:content (first (filter #(= command (:name %)) |
120 | | - custom-commands)))] |
| 120 | + custom-cmds)))] |
121 | 121 | (let [raw-content (string/replace raw-content "$ARGS" (string/join " " args))] |
122 | 122 | (reduce (fn [content [i arg]] |
123 | 123 | (string/replace content (str "$ARG" (inc i)) arg)) |
|
130 | 130 | "" |
131 | 131 | (str "Default model: " model) |
132 | 132 | "" |
| 133 | + (str "Login providers: " (reduce |
| 134 | + (fn [s [provider auth]] |
| 135 | + (str s provider ": " (-> auth |
| 136 | + (update-some :verifier shared/obfuscate) |
| 137 | + (update-some :device-code shared/obfuscate) |
| 138 | + (update-some :access-token shared/obfuscate) |
| 139 | + (update-some :api-key shared/obfuscate)) "\n")) |
| 140 | + "\n" |
| 141 | + (:auth db))) |
133 | 142 | (str "Relevant env vars: " (reduce (fn [s [key val]] |
134 | 143 | (if (or (string/includes? key "KEY") |
135 | 144 | (string/includes? key "API") |
|
142 | 151 |
|
143 | 152 | (defn handle-command! [command args {:keys [chat-id db* config full-model instructions]}] |
144 | 153 | (let [db @db* |
145 | | - custom-commands (custom-commands config (:workspace-folders db))] |
| 154 | + custom-cmds (custom-commands config (:workspace-folders db))] |
146 | 155 | (case command |
147 | 156 | "init" {:type :send-prompt |
148 | 157 | :clear-history-after-finished? true |
|
188 | 197 | :chats {chat-id [{:role "system" :content [{:type :text :text instructions}]}]}} |
189 | 198 |
|
190 | 199 | ;; else check if a custom command |
191 | | - (if-let [custom-command-prompt (get-custom-command command args custom-commands)] |
| 200 | + (if-let [custom-command-prompt (get-custom-command command args custom-cmds)] |
192 | 201 | {:type :send-prompt |
193 | 202 | :clear-history-after-finished? false |
194 | 203 | :prompt custom-command-prompt} |
|
0 commit comments