Skip to content

Commit 680b4ee

Browse files
Move some of the function definitions to the registry
* only the ones that are being re-used have been moved for now
1 parent 41120bc commit 680b4ee

13 files changed

+107
-214
lines changed

functions/registry.edn

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,34 @@
6666
:description "the file path"}}},
6767
:container {:image "vonwig/bb:latest",
6868
:command ["{{raw|safe}}"
69-
"(slurp (:path args))"]}}]}
69+
"(slurp (:path args))"]}}
70+
{:name "sqlite",
71+
:description "run the sqlite command",
72+
:parameters {:type "object",
73+
:properties {:database {:type "string",
74+
:description "the path to the database"},
75+
:sql {:type "string",
76+
:description "the sql statement to run"}}},
77+
:container {:image "vonwig/sqlite:latest",
78+
:command ["{{database}}" "{{sql|safe}}"]}}
79+
{:name "run-javascript-sandbox",
80+
:description "execute javascript code",
81+
:parameters {:type "object",
82+
:properties {:javascript {:type "string",
83+
:description "the javascript code to run"}}},
84+
:container {:image "vonwig/javascript-runner",
85+
:command ["{{javascript|safe}}"]}}
86+
{:name "delete_folder",
87+
:description "Runs rm -rf on a folder",
88+
:parameters {:type "object",
89+
:properties {:path {:type "string",
90+
:description "Path of the folder to delete"}}},
91+
:container {:image "vonwig/bash_alpine",
92+
:command ["rm -rf {{path|safe}}"]}}
93+
{:name "cat_file",
94+
:description "Runs cat on a file",
95+
:parameters {:type "object",
96+
:properties {:path {:type "string",
97+
:description "Path of the folder to delete"}}},
98+
:container {:image "vonwig/bash_alpine",
99+
:command ["cat {{path|safe}}"]}}]}

functions/registry.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,56 @@ registry:
117117
command:
118118
- "{{raw|safe}}"
119119
- "(slurp (:path args))"
120+
- name: sqlite
121+
description: run the sqlite command
122+
parameters:
123+
type: object
124+
properties:
125+
database:
126+
type: string
127+
description: the path to the database
128+
sql:
129+
type: string
130+
description: the sql statement to run
131+
container:
132+
image: vonwig/sqlite:latest
133+
command:
134+
- "{{database}}"
135+
- "{{sql|safe}}"
136+
- name: run-javascript-sandbox
137+
description: execute javascript code
138+
parameters:
139+
type: object
140+
properties:
141+
javascript:
142+
type: string
143+
description: the javascript code to run
144+
container:
145+
image: vonwig/javascript-runner
146+
command:
147+
- "{{javascript|safe}}"
148+
- name: delete_folder
149+
description: Runs rm -rf on a folder
150+
parameters:
151+
type: object
152+
properties:
153+
path:
154+
type: string
155+
description: Path of the folder to delete
156+
container:
157+
image: vonwig/bash_alpine
158+
command:
159+
- "rm -rf {{path|safe}}"
160+
- name: cat_file
161+
description: Runs cat on a file
162+
parameters:
163+
type: object
164+
properties:
165+
path:
166+
type: string
167+
description: Path of the folder to delete
168+
container:
169+
image: vonwig/bash_alpine
170+
command:
171+
- "cat {{path|safe}}"
120172

prompts/pylint/2-make-db-schema.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
11
---
22
tools:
33
- name: sqlite
4-
description: run the sqlite command
5-
parameters:
6-
type: object
7-
properties:
8-
database:
9-
type: string
10-
description: the path to the database
11-
sql:
12-
type: string
13-
description: the sql statement to run
14-
container:
15-
image: vonwig/sqlite:latest
16-
command:
17-
- "{{database}}"
18-
- "{{sql}}"
194
- name: delete_folder
20-
description: Runs rm -rf on a folder
21-
parameters:
22-
type: object
23-
properties:
24-
path:
25-
type: string
26-
description: Path of the folder to delete
27-
container:
28-
image: vonwig/bash_alpine
29-
command:
30-
- "rm -rf {{path|safe}}"
315
---
326

337
# prompt user

prompts/pylint/3-generate-violation-insert.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
---
22
tools:
33
- name: run-javascript-sandbox
4-
description: execute javascript code
5-
parameters:
6-
type: object
7-
properties:
8-
javascript:
9-
type: string
10-
description: the javascript code to run
11-
container:
12-
image: vonwig/javascript-runner
13-
command:
14-
- "{{javascript|safe}}"
154
---
165

176
# prompt user
Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,8 @@
11
---
22
tools:
33
- name: sqlite
4-
description: run the sqlite command
5-
parameters:
6-
type: object
7-
properties:
8-
database:
9-
type: string
10-
description: the path to the database
11-
container:
12-
image: vonwig/sqlite:latest
13-
command:
14-
- "{{database}}"
15-
- ".read /thread/insert.sql"
164
---
175

18-
# volumes
19-
20-
```sh
21-
docker run -it --rm -v thread:/thread \
22-
vonwig/bb:latest \
23-
'{}' \
24-
'(println (slurp "/thread/insert.sql"))'
25-
```
26-
27-
```
28-
docker run -it --rm -v thread:/thread \
29-
vonwig/sqlite:latest \
30-
/thread/db.sqlite \
31-
".schema RANGES"
32-
```
33-
34-
```
35-
docker run -it --rm -v thread:/thread \
36-
vonwig/sqlite:latest \
37-
/thread/db.sqlite \
38-
".schema VIOLATIONS"
39-
```
40-
41-
```
42-
docker run -it --rm -v thread:/thread \
43-
vonwig/sqlite:latest \
44-
/thread/db.sqlite \
45-
".open /thread/insert.sql"
46-
```
47-
48-
```
49-
docker run -it --rm -v thread:/thread \
50-
vonwig/sqlite:latest \
51-
/thread/db.sqlite \
52-
"SELECT * FROM VIOLATIONS INNER JOIN RANGES ON VIOLATIONS.RANGE_ID = RANGES.ID WHERE RANGES.PATH = 'src/app.py'"
53-
```
54-
55-
```
56-
docker run -it --rm -v thread:/thread \
57-
vonwig/sqlite:latest \
58-
/thread/db.sqlite \
59-
"SELECT * FROM RANGES WHERE RANGES.PATH = 'src/app.py'"
60-
```
61-
62-
636
# prompt user
647

65-
Run the sqlite command with the path to the database set to `/thread/db.sqlite`.
66-
8+
Run the sqlite command `.read /thread/insert.sql` in the datbase `/thread/db.sqlite`.

prompts/pylint/5-1-insert-top-level-ranges.md

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,8 @@ tools:
3131
command:
3232
- "while read -r file; do mkdir -p \"{{output_dir|safe}}/$(dirname $file)\" && tree-sitter parse \"$file\" > \"{{output_dir|safe}}/$file.parsed\"; done < {{in_paths_file|safe}}"
3333
- name: delete_folder
34-
description: Runs rm -rf on a folder
35-
parameters:
36-
type: object
37-
properties:
38-
path:
39-
type: string
40-
description: Path of the folder to delete
41-
container:
42-
image: vonwig/bash_alpine
43-
command:
44-
- "rm -rf {{path|safe}}"
4534
- name: run-javascript-sandbox
46-
description: execute javascript code
47-
parameters:
48-
type: object
49-
properties:
50-
javascript:
51-
type: string
52-
description: the javascript code to run
53-
container:
54-
image: vonwig/javascript-runner
55-
command:
56-
- "{{javascript|safe}}"
5735
- name: sqlite
58-
description: run the sqlite command
59-
parameters:
60-
type: object
61-
properties:
62-
database:
63-
type: string
64-
description: the path to the database
65-
sql:
66-
type: string
67-
description: the sql statement to run
68-
container:
69-
image: vonwig/sqlite:latest
70-
command:
71-
- "{{database}}"
72-
- "{{sql}}"
7336
---
7437

7538
# prompt user
@@ -132,4 +95,4 @@ INSERT INTO RANGES (ID, START_LINE, START_COLUMN, END_LINE, END_COLUMN, PATH) va
13295

13396
5. Execute the code in the javascript sandbox.
13497

135-
6. Finally, run `.read /thread/ranges.sql` in `/thread/db.sqlite`
98+
6. Finally, run `.read /thread/ranges.sql` in `/thread/db.sqlite`

prompts/pylint/5-2-insert-code.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,7 @@
11
---
22
tools:
33
- name: sqlite
4-
description: run the sqlite command
5-
parameters:
6-
type: object
7-
properties:
8-
database:
9-
type: string
10-
description: the path to the database
11-
sql:
12-
type: string
13-
description: the sql statement to run
14-
container:
15-
image: vonwig/sqlite:latest
16-
command:
17-
- "{{database}}"
18-
- "{{sql|safe}}"
194
- name: run-javascript-sandbox
20-
description: execute javascript code in node
21-
parameters:
22-
type: object
23-
properties:
24-
javascript:
25-
type: string
26-
description: the javascript code to run
27-
container:
28-
image: vonwig/javascript-runner
29-
command:
30-
- "{{javascript|safe}}"
315
---
326

337
# prompt user

prompts/pylint/6-1-query.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
---
22
tools:
33
- name: sqlite
4-
description: run the sqlite command
5-
parameters:
6-
type: object
7-
properties:
8-
database:
9-
type: string
10-
description: the path to the database
11-
sql:
12-
type: string
13-
description: the sql statement to run
14-
container:
15-
image: vonwig/sqlite:latest
16-
command:
17-
- "{{database}}"
18-
- "{{sql|safe}}"
194
---
205

216
# prompt user
@@ -27,4 +12,4 @@ CREATE TABLE VIOLATIONS (ID INTEGER PRIMARY KEY AUTOINCREMENT, MESSAGE TEXT, TYP
2712
CREATE TABLE RANGES (ID STRING PRIMARY KEY, PATH TEXT, START_LINE INT, END_LINE INT, START_COLUMN INT, END_COLUMN INT);
2813
```
2914

30-
Generate a query to list each the violations by just the violation name `black_listed_name.py` in a readble format, and then run the sqlite command on database `/thread/db.sqlite`.
15+
Generate a query to list each the violations by just the violation name `black_listed_name.py` in a readble format, and then run the sqlite command on database `/thread/db.sqlite`.

prompts/pylint/RUNNIT.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

prompts/pylint/generic_query.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
---
22
tools:
33
- name: sqlite
4-
description: execute SQLite commands
5-
parameters:
6-
type: object
7-
properties:
8-
database:
9-
type: string
10-
description: The path to the SQLite database
11-
sql:
12-
type: string
13-
description: The SQL command to run
14-
container:
15-
image: vonwig/sqlite:latest
16-
command:
17-
- "{{database}}"
18-
- "{{sql|safe}}"
194
---
205

216
# prompt user

0 commit comments

Comments
 (0)