-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66ce4ce
commit 515bb6f
Showing
11 changed files
with
292 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
# syntax = docker/dockerfile:1.4 | ||
FROM nixos/nix:2.21.1@sha256:3f6c77ee4d2c82e472e64e6cd7087241dc391421a0b42c22e6849c586d5398d9 AS builder | ||
|
||
WORKDIR /tmp/build | ||
RUN mkdir /tmp/nix-store-closure | ||
|
||
# ignore SC2046 because the output of nix-store -qR will never have spaces - this is safe here | ||
# hadolint ignore=SC2046 | ||
RUN --mount=type=cache,target=/nix,from=nixos/nix:2.21.1,source=/nix \ | ||
--mount=type=cache,target=/root/.cache \ | ||
--mount=type=bind,target=/tmp/build \ | ||
<<EOF | ||
nix \ | ||
--extra-experimental-features "nix-command flakes" \ | ||
--option filter-syscalls false \ | ||
--extra-trusted-substituters "https://cache.iog.io" \ | ||
--extra-trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \ | ||
--show-trace \ | ||
--log-format raw \ | ||
build . --out-link /tmp/output/result | ||
cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure | ||
EOF | ||
|
||
FROM scratch | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /tmp/nix-store-closure /nix/store | ||
COPY --from=builder /tmp/output/ /app/ | ||
|
||
ENTRYPOINT ["/app/result/bin/entrypoint"] | ||
CMD ["--help"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
description = "fasttext"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, ...}@inputs: | ||
|
||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
}; | ||
|
||
in rec | ||
{ | ||
packages = rec { | ||
|
||
# this derivation just contains the init.clj script | ||
scripts = pkgs.stdenv.mkDerivation { | ||
name = "scripts"; | ||
src = ./.; | ||
installPhase = '' | ||
cp init.clj $out | ||
''; | ||
}; | ||
|
||
# the script must have gh in the PATH | ||
default = pkgs.writeShellScriptBin "entrypoint" '' | ||
export PATH=${pkgs.lib.makeBinPath [pkgs.clj-kondo]} | ||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
${pkgs.babashka}/bin/bb ${scripts} "$@" | ||
''; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(ns init | ||
(:require | ||
[babashka.fs :as fs] | ||
[babashka.process] | ||
[cheshire.core])) | ||
|
||
(try | ||
(let [[json-string & args] *command-line-args* | ||
{llm-args :args} (cheshire.core/parse-string json-string true)] | ||
(let [{:keys [out err] :as p} (-> (apply babashka.process/process | ||
{:out :string :err :string} | ||
"clj-kondo" | ||
(concat llm-args | ||
["--config" (pr-str | ||
{:output {:format :json}})])) | ||
(deref))] | ||
(let [dir (fs/file "/thread/clj-kondo")] | ||
(fs/create-dirs dir) | ||
(spit (fs/file dir "lint.json") out)) | ||
(println out) | ||
(when (not (= 0 (:exit p))) | ||
(binding [*out* *err*] | ||
(println err) | ||
(System/exit (:exit p)))))) | ||
(catch Throwable t | ||
(binding [*out* *err*] | ||
(println (str t)) | ||
(System/exit 1)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Background | ||
|
||
The `curl` function has one parameter. | ||
|
||
* `args`: the args to send to the image | ||
|
||
## Usage | ||
|
||
This function should be given a rw bind mount for the root of a project. | ||
|
||
```sh | ||
docker run --rm \ | ||
--mount type=bind,source=/Users/slim/docker/labs-ai-tools-for-devs,target=/project \ | ||
--workdir /project \ | ||
vonwig/clj-kondo:latest '{"args": ["--lint","."]}' | jq . | ||
``` | ||
|
||
## Build | ||
|
||
```sh | ||
docker build -t vonwig/clj-kondo:latest . | ||
``` | ||
|
||
```sh | ||
# docker:command=build | ||
|
||
docker buildx build \ | ||
--builder hydrobuild \ | ||
--platform linux/amd64,linux/arm64 \ | ||
--tag vonwig/clj-kondo:latest \ | ||
--file Dockerfile \ | ||
--push . | ||
docker pull vonwig/clj-kondo:latest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Lint the clojure code in this project by passing the arguments `--lint .`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
extractors: | ||
- name: go-linguist | ||
- name: project-facts | ||
model: gpt-4 | ||
stream: true | ||
functions: | ||
- name: clj-kondo | ||
description: "lint clojure code" | ||
parameters: | ||
type: object | ||
properties: | ||
args: | ||
type: array | ||
description: "the arguments to pass to the linter" | ||
items: | ||
type: string | ||
container: | ||
image: vonwig/clj-kondo:latest | ||
--- | ||
|
||
# Background | ||
|
||
Ask about violations in a project that contains clojure code. | ||
|
||
## Running the tool | ||
|
||
```sh | ||
docker run --rm \ | ||
-it \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
--mount type=volume,source=docker-prompts,target=/prompts \ | ||
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \ | ||
--mount type=bind,source=/Users/slim/docker/labs-ai-tools-for-devs/prompts,target=/app/local \ | ||
--workdir /app \ | ||
vonwig/prompts:local run \ | ||
/Users/slim/docker/labs-ai-tools-for-devs \ | ||
jimclark106 \ | ||
"$(uname -o)" \ | ||
local/clj-kondo \ | ||
--pat "$(cat ~/.secrets/dockerhub-pat-ai-tools-for-devs.txt)" \ | ||
--thread-id "clj-kondo" \ | ||
--save-thread-volume | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
extractors: | ||
- name: go-linguist | ||
- name: docker-lsp | ||
model: gpt-4 | ||
stream: true | ||
functions: | ||
- name: curl | ||
description: "Run a curl command" | ||
parameters: | ||
type: object | ||
properties: | ||
args: | ||
type: string | ||
description: "The arguments to pass to curl" | ||
container: | ||
image: vonwig/curl:latest | ||
--- | ||
|
||
# Background | ||
|
||
* read tl/dr examples | ||
* read man pages | ||
|
||
After ragging the above content, do we know enough about curl to create and run curl examples. | ||
|
||
Also, what about defining outcomes and having the tool verify that we actually ran this correctly and got the expected results? | ||
|
||
At the end, we should report the command line, and the version of curl that we used. | ||
|
||
## Running the tool | ||
|
||
```sh | ||
DIR=$PWD | ||
docker run --rm -it \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
--mount type=volume,source=docker-prompts,target=/prompts \ | ||
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \ | ||
--mount type=bind,source=/Users/slim/docker/labs-make-runbook/prompts,target=/my-prompts \ | ||
--workdir /my-prompts \ | ||
vonwig/prompts:latest run \ | ||
$DIR \ | ||
$USER \ | ||
"$(uname -o)" \ | ||
project_type | ||
# "github:docker/labs-make-runbook?ref=main&path=prompts/curl" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters