Skip to content

Commit 367a1cc

Browse files
For explain_dockerfile, mount just the file we're analyzing
1 parent a45905f commit 367a1cc

File tree

6 files changed

+25
-14
lines changed

6 files changed

+25
-14
lines changed

prompts/examples/explain_dockerfile.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ tools:
1414
parameters:
1515
type: object
1616
properties:
17-
project:
18-
type: string
19-
description: absolute path in the project root
2017
path:
2118
type: string
2219
description: Path of the folder to delete
2320
container:
2421
image: vonwig/bash_alpine
2522
mounts:
26-
- "{{project|safe}}:/workdir:ro"
27-
workdir: /workdir
23+
- "{{path|safe}}:/dockerfile:ro"
2824
command:
29-
- "cat {{path|safe}}"
25+
- "cat /dockerfile"
3026
prompt-format: "django"
27+
arguments:
28+
- name: path
29+
description: path to the Dockerfile to explain
30+
required: true
3131
---
3232

3333
# prompt user
3434

35-
Start by fetching the ./Dockerfile in the project root at /Users/slim/docker/labs-ai-tools-for-devs.
35+
Start by fetching the Dockerfile located at /dockerfile.
3636

3737
After fetching the Dockerfile contents, explain the Dockerfile line by line.
3838

src/git.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
(when ref [ref]))}
7272
(if (string/starts-with? (str dir) "/prompts")
7373
{:workdir (str dir)
74-
:volumes ["docker-prompts-git:/git"]
75-
:mounts ["docker-prompts:/prompts:rw"]}
74+
:volumes ["docker-prompts-git:/git"
75+
"docker-prompts:/prompts:rw"]}
7676
{:host-dir (str dir)
7777
:volumes ["docker-prompts-git:/git"]}))))
7878

src/script.clj

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
(ns script)
22

33
(defmacro read [path]
4-
`(slurp ~path))
4+
(slurp path))
5+
6+
(comment
7+
(macroexpand '(read "src/volumes/collect.clj")))

src/tools.clj

+4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
{:mounts (->> (-> definition :container :mounts)
7272
(map (fn [s] (first (interpolate arg-context s))))
7373
(into []))})
74+
(when (-> definition :container :volumes)
75+
{:volumes (->> (-> definition :container :volumes)
76+
(map (fn [s] (first (interpolate arg-context s))))
77+
(into []))})
7478
;; workdirs in a container definition will always override ones
7579
;; set in the metadata
7680
(when-let [wd (or

src/volumes.clj

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
(->
4949
(docker/run-container
5050
{:image "vonwig/bb:latest"
51-
:volumes ["/Users/slim/slimslenderslacks/flask-nix-example:/project"]
51+
:volumes ["/Users/slim:/project"]
5252
:workdir "/project"
5353
:command [(json/generate-string
54-
{:thread-id "blah"})
55-
"{}"]})
54+
{:directory "/project"})
55+
(script/read "src/volumes/collect.clj")]})
5656
:pty-output
57-
(json/parse-string keyword)))
57+
#_(json/parse-string keyword)))
5858

src/volumes/collect.clj

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"pass in args"
44
(def args {:directory "/Users/slim"}))
55

6+
(require '[clojure.java.io :as io])
7+
(require '[babashka.fs :as fs])
8+
(require '[cheshire.core :as json])
9+
610
(defn file->bytes [path]
711
(with-open [in (io/input-stream path)
812
out (java.io.ByteArrayOutputStream.)]

0 commit comments

Comments
 (0)