Skip to content

Commit a48161f

Browse files
committed
Add /repo-map-show command.
1 parent 82356d2 commit a48161f

2 files changed

Lines changed: 32 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Add `/repo-map-show` command.
6+
57
## 0.16.0
68

79
- Support custom system prompts via config `systemPromptTemplate`.

src/eca/features/chat.clj

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@
252252
:type :text}]})})
253253
(send-content! chat-ctx :assistant
254254
(assoc-some
255-
{:type :toolCallRejected
256-
:origin (tool-name->origin name all-tools)
257-
:name name
258-
:arguments arguments
259-
:reason :user
260-
:id id}
261-
:details details))))
255+
{:type :toolCallRejected
256+
:origin (tool-name->origin name all-tools)
257+
:name name
258+
:arguments arguments
259+
:reason :user
260+
:id id}
261+
:details details))))
262262
(swap! tool-call-by-id* dissoc id)
263263
(send-content! chat-ctx :system {:type :progress :state :running :text "Generating"})
264264
{:new-messages (get-in @db* [:chats chat-id :messages])}))
@@ -296,23 +296,25 @@
296296
(prompt-messages! messages false chat-ctx)))
297297

298298
(defn ^:private handle-command! [{:keys [command]} {:keys [chat-id db* model] :as chat-ctx}]
299-
(case command
300-
"costs" (let [db @db*
301-
total-input-tokens (get-in db [:chats chat-id :total-input-tokens] 0)
302-
total-input-cache-creation-tokens (get-in db [:chats chat-id :total-input-cache-creation-tokens] nil)
303-
total-input-cache-read-tokens (get-in db [:chats chat-id :total-input-cache-read-tokens] nil)
304-
total-output-tokens (get-in db [:chats chat-id :total-output-tokens] 0)
305-
text (multi-str (str "Total input tokens: " total-input-tokens)
306-
(when total-input-cache-creation-tokens
307-
(str "Total input cache creation tokens: " total-input-cache-creation-tokens))
308-
(when total-input-cache-read-tokens
309-
(str "Total input cache read tokens: " total-input-cache-read-tokens))
310-
(str "Total output tokens: " total-output-tokens)
311-
(str "Total cost: $" (tokens->cost total-input-tokens total-input-cache-creation-tokens total-input-cache-read-tokens total-output-tokens model db)))]
312-
(send-content! chat-ctx :system {:type :text
313-
:text text}))
314-
(send-content! chat-ctx :system {:type :text
315-
:text (str "Unknown command: " command)}))
299+
(let [db @db*]
300+
(case command
301+
"costs" (let [total-input-tokens (get-in db [:chats chat-id :total-input-tokens] 0)
302+
total-input-cache-creation-tokens (get-in db [:chats chat-id :total-input-cache-creation-tokens] nil)
303+
total-input-cache-read-tokens (get-in db [:chats chat-id :total-input-cache-read-tokens] nil)
304+
total-output-tokens (get-in db [:chats chat-id :total-output-tokens] 0)
305+
text (multi-str (str "Total input tokens: " total-input-tokens)
306+
(when total-input-cache-creation-tokens
307+
(str "Total input cache creation tokens: " total-input-cache-creation-tokens))
308+
(when total-input-cache-read-tokens
309+
(str "Total input cache read tokens: " total-input-cache-read-tokens))
310+
(str "Total output tokens: " total-output-tokens)
311+
(str "Total cost: $" (tokens->cost total-input-tokens total-input-cache-creation-tokens total-input-cache-read-tokens total-output-tokens model db)))]
312+
(send-content! chat-ctx :system {:type :text
313+
:text text}))
314+
"repo-map-show" (send-content! chat-ctx :system {:type :text
315+
:text (f.index/repo-map db {:as-string? true})})
316+
(send-content! chat-ctx :system {:type :text
317+
:text (str "Unknown command: " command)})))
316318
(finish-chat-prompt! :idle chat-ctx))
317319

318320
(defn prompt
@@ -398,6 +400,10 @@
398400
eca-commands [{:name "costs"
399401
:type :native
400402
:description "Show the total costs of the current chat session."
403+
:arguments []}
404+
{:name "repo-map-show"
405+
:type :native
406+
:description "Show the actual repoMap of current session."
401407
:arguments []}]
402408
commands (concat mcp-prompts
403409
eca-commands)

0 commit comments

Comments
 (0)