|
1 | 1 | (ns catalog
|
2 | 2 | (:require
|
3 | 3 | [babashka.fs :as fs]
|
| 4 | + [cheshire.core :as json] |
4 | 5 | [clj-yaml.core :as yaml]
|
5 | 6 | [clojure.edn :as edn]
|
| 7 | + [clojure.pprint :refer [pprint]] |
| 8 | + [clojure.string :as string] |
6 | 9 | [flatland.ordered.map :refer [ordered-map]]
|
7 | 10 | git
|
8 | 11 | [markdown :as markdown-parser]
|
|
60 | 63 | (generate-updated-catalog)
|
61 | 64 | ;; parse catalog
|
62 | 65 | (def catalog (yaml/parse-string (slurp "prompts/catalog.yaml")))
|
| 66 | + (string/join "," (->> (:registry catalog) keys (map name))) |
| 67 | + |
| 68 | + ;; raw github urls to |
| 69 | + (def prompt-refs |
| 70 | + (->> catalog |
| 71 | + :registry |
| 72 | + vals |
| 73 | + (map :ref) |
| 74 | + (map #(git/parse-github-ref %)) |
| 75 | + (map #(format "https://raw.githubusercontent.com/%s/%s/refs/heads/%s/%s" (:owner %) (:repo %) (or (:ref %) "main") (:path %))))) |
| 76 | + |
| 77 | + (->> prompt-refs (interpose "\n") (apply str) (println)) |
63 | 78 |
|
64 | 79 | ;; current git ref files
|
65 | 80 | (def local-prompt-files
|
|
70 | 85 | (map #(conj [%] (git/prompt-file %)))
|
71 | 86 | (into {})))
|
72 | 87 |
|
73 |
| - ;; parse all of the current git prompts |
74 |
| - (with-redefs [#'client/get-mcp-tools-from-prompt (constantly [])] |
| 88 | +;; parse all of the current git prompts |
| 89 | + (with-redefs [client/get-mcp-tools-from-prompt (constantly [])] |
75 | 90 | (def all-prompt-files (map (fn [[k v]] [k (f->prompt v)]) local-prompt-files)))
|
76 | 91 |
|
| 92 | + (pprint (->> all-prompt-files |
| 93 | + (map (fn [[k v]] [k (dissoc v :mcp/resources)])) |
| 94 | + (into {}))) |
| 95 | + (spit "crap.json" (json/generate-string |
| 96 | + (->> all-prompt-files |
| 97 | + (map (fn [[k v]] [k (dissoc v :mcp/resources :mcp/prompt-registry)])) |
| 98 | + (into {})) |
| 99 | + {:pretty true})) |
| 100 | + |
77 | 101 | (def all-images
|
78 | 102 | (->>
|
79 |
| - (concat |
80 |
| - (->> (into {} all-prompt-files) |
81 |
| - (vals) |
82 |
| - (mapcat (comp :mcp :metadata)) |
83 |
| - (map (comp :image :container)) |
84 |
| - (into #{})) |
85 |
| - (->> (into {} all-prompt-files) |
86 |
| - (vals) |
87 |
| - (mapcat :functions) |
88 |
| - (map (comp :image :container :function)) |
89 |
| - (into #{}))) |
90 |
| - (into #{}) |
91 |
| - (sort))) |
| 103 | + (concat |
| 104 | + (->> (into {} all-prompt-files) |
| 105 | + (vals) |
| 106 | + (mapcat (comp :mcp :metadata)) |
| 107 | + (map (comp :image :container)) |
| 108 | + (into #{})) |
| 109 | + (->> (into {} all-prompt-files) |
| 110 | + (vals) |
| 111 | + (mapcat :functions) |
| 112 | + (map (comp :image :container :function)) |
| 113 | + (into #{}))) |
| 114 | + (into #{}) |
| 115 | + (sort))) |
92 | 116 |
|
93 | 117 | ;;
|
94 | 118 | (markdown-parser/parse-markdown (slurp "prompts/examples/sequentialthinking.md")))
|
0 commit comments