Skip to content

Commit

Permalink
Support multiple --registers
Browse files Browse the repository at this point in the history
  • Loading branch information
slimslenderslacks committed Dec 6, 2024
1 parent fc94d7e commit ffb476b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/docker/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@
[nil "--nostream" "disable streaming responses"
:id :stream
:assoc-fn (fn [m k _] (assoc m k false))]
[nil "--register ref" "register a prompt REF"]
[nil "--register ref" "register a prompt REF"
:multi true
:default []
:update-fn conj]
[nil "--mcp" "use the mcp jsonrpc protocol"]
[nil "--debug" "add debug logging"]
[nil "--help" "print option summary"]])
Expand Down
17 changes: 8 additions & 9 deletions src/jsonrpc/db.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@
(def db* (atom {}))

(defn get-prompt-data [{:keys [register] :as opts}]
(let [f (git/prompt-file register)
{:keys [messages metadata functions] :as entry} (prompts/get-prompts (assoc opts :prompts f))]
entry))
(->> register
(map (fn [ref] [ref (git/prompt-file ref)]))
(map (fn [[ref f]]
(let [m (prompts/get-prompts (assoc opts :prompts f))]
[(or (-> m :metadata :name) ref) m])))
(into {})))

(defn add [opts]
(logger/info "adding prompts" (:register opts))
(let [m (get-prompt-data opts)]
(swap! db* update-in [:mcp.prompts/registry]
(fnil assoc {})
#_(:register opts)
(or (-> m :metadata :name) (:register opts))
m)))
(swap! db* update-in [:mcp.prompts/registry] (fnil merge {}) m)))

(comment
(add {:register "github:docker/labs-ai-tools-for-devs?path=prompts/examples/explain_dockerfile.md&ref=slim/server"}))
(add {:register ["github:docker/labs-ai-tools-for-devs?path=prompts/examples/explain_dockerfile.md&ref=slim/server"]}))

2 changes: 1 addition & 1 deletion src/jsonrpc/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
(defn entry->prompt-listing [k v m]
(merge
{:name (str k)}
(select-keys m [:description])))
(select-keys (:metadata v) [:description])))

(defmethod lsp.server/receive-request "prompts/list" [_ {:keys [db*]} params]
;; TODO might contain a cursor
Expand Down

0 comments on commit ffb476b

Please sign in to comment.