Skip to content

Commit 546a373

Browse files
Update bootstrap for cursor rules
1 parent 4bd8170 commit 546a373

File tree

4 files changed

+41
-11
lines changed

4 files changed

+41
-11
lines changed

prompts/bootstrap.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ tools:
2121
- -c
2222
- "echo \"{{content|safe}}\" >> /prompts/{{name}}.md"
2323
- name: write_files
24+
- name: read-file
2425
```
2526
26-
# prompt
27+
# xprompt
2728
2829
Take the following description of a task I'd like to complete, and extract the schema for a set of tool definitions that I'll need
2930
in order to run that task. The tool definitions should be in yaml and each tool should have a name, a description, and an openapi schema
@@ -33,3 +34,6 @@ moustache templates. The final yaml definition should be written into a code blo
3334

3435
> add a tool that fetches all GitHub Issues from a public repository using curl. We do not need a token.
3536

37+
# prompt
38+
39+
Read in the file tools.md and then bootstrap the tool definition with the name 'github-issues'

src/docker.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@
466466
{:image "vonwig/websocat:latest",
467467
:stdin
468468
{:content
469-
"{\"id\":1,\"method\":\"Page.navigate\",\"params\":{\"url\":\"https://www.docker.com\"}}"},
469+
"Page.navigate {\"url\":\"https://www.docker.com\"}"},
470470
:command
471471
["-n1"
472472
"--jsonrpc"

src/jsonrpc/db.clj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
(def db* (atom {}))
1111

12-
(defn get-prompt-data
12+
(defn get-prompt-data
1313
"register is a coll of prompt file ref maps"
1414
[{:keys [register] :as opts}]
1515
(->> register
@@ -86,6 +86,21 @@
8686
(constantly (or (:mcp.prompts/static db) {})))))))
8787
(logger/info "resources are " (:mcp.prompts/resources @db*)))
8888

89+
(defn update-prompt [opts s content]
90+
(logger/info (format "update prompt %s with content %s" s content))
91+
(let [m (prompts/get-prompts
92+
(assoc opts :prompt-content content))]
93+
(swap! db* (fn [db]
94+
(-> db
95+
(update-in [:mcp.prompts/registry s] (constantly m))
96+
(update-in [:mcp.prompts/static s] (constantly m))
97+
(update [:mcp.prompts/resources] (fnil merge merge {}) (extract-resources m)))))))
98+
99+
(comment
100+
(println @db*)
101+
(-> @db* :mcp.prompts/registry (get "github-issues"))
102+
(update-prompt {} "github-issues" (slurp "prompts/examples/github_issues.md")))
103+
89104
(defn registry-refs
90105
"parse refs from the registry.yaml file - these are dynamic"
91106
[f]

src/jsonrpc/server.clj

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@
117117
(logger/info "prompts/get " name)
118118
(let [{:keys [prompt-function description] :as m}
119119
(get
120-
(->> @db*
121-
:mcp.prompts/registry
122-
vals
123-
(mapcat :mcp/prompt-registry)
124-
(into {}))
125-
name)]
120+
(->> @db*
121+
:mcp.prompts/registry
122+
vals
123+
(mapcat :mcp/prompt-registry)
124+
(into {}))
125+
name)]
126126
{:description description
127127
:messages (prompt-function (or arguments {}))}))
128128

@@ -377,6 +377,10 @@
377377
:server server}]
378378
(swap! db* merge {:log-path log-path} (dissoc opts :in))
379379
;; register static prompts
380+
(doseq [[s content] (->> (fs/list-dir "/Users/slim/docker/labs-ai-tools-for-devs/prompts")
381+
(filter (fn [f] (= "md" (fs/extension f))))
382+
(map (fn [f] [(string/replace (fs/file-name (fs/file f)) #"\.md" "") (slurp (fs/file f))])))]
383+
(db/update-prompt opts s content))
380384
(db/add-refs
381385
(concat
382386
(->> (:register opts)
@@ -392,15 +396,22 @@
392396
:volumes ["docker-prompts:/prompts"]
393397
:command ["-e" "create" "-e" "modify" "-e" "delete" "-q" "-m" "/prompts"]}
394398
(fn [line]
395-
(logger/info "registry changed" line)
399+
(logger/info "change event" line)
396400
(let [[_dir _event f] (string/split line #"\s+")]
397401
(when (= f "registry.yaml")
398402
(try
399403
(db/add-refs (logger/trace (into [] (db/registry-refs registry))))
400404
(producer/publish-tool-list-changed producer {})
401405
(producer/publish-prompt-list-changed producer {})
402406
(catch Throwable t
403-
(logger/error t "unable to parse registry.yaml")))))))]
407+
(logger/error t "unable to parse registry.yaml"))))
408+
(when (string/ends-with? f ".md")
409+
(try
410+
(db/update-prompt opts (string/replace f #"\.md" "") (slurp (str "/prompts/" f)))
411+
(producer/publish-tool-list-changed producer {})
412+
(producer/publish-prompt-list-changed producer {})
413+
(catch Throwable t
414+
(logger/error t "unable to parse " f)))))))]
404415
(shutdown/schedule-container-shutdown
405416
(fn []
406417
(logger/info "inotifywait shutting down")

0 commit comments

Comments
 (0)