Skip to content

Commit 69f21ef

Browse files
author
Colin McNeil
committed
First working flow
1 parent 86b7e85 commit 69f21ef

File tree

6 files changed

+85
-22
lines changed

6 files changed

+85
-22
lines changed

functions/read_files/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine:latest
2+
3+
# Add jq and bash
4+
RUN apk add --no-cache bash jq fd
5+
6+
COPY scripts/read.sh /read.sh
7+
8+
RUN chmod +x /read.sh
9+
10+
ENTRYPOINT ["/read.sh"]

functions/read_files/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
```sh
3+
docker build . -t vonwig/read_files
4+
docker run --mount type=bind,source=$PWD,target=/project --workdir /project vonwig/read_files '{"files":["Dockerfile"]}'
5+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
JSON_ARGS=$1
3+
4+
# Read file paths array
5+
FILE_PATHS=$(echo $JSON_ARGS | jq -r '.files[]')
6+
7+
for FILE_PATH in $FILE_PATHS; do
8+
echo -e "Content for \`$FILE_PATH\`:\n\n\`\`\`\n"
9+
# If file doesn't exist
10+
if [ ! -f $FILE_PATH ]; then
11+
echo "File $FILE_PATH does not exist"
12+
else
13+
# Print file content
14+
cat $FILE_PATH
15+
fi
16+
echo -e "\n\`\`\`\n\n"
17+
done
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
You are an assistant who specializes in linting projects.
1+
You are an assistant who specializes in linting JS/TS projects with ESLint and git. Follow the steps below.
22

33
The following is a report of the project's usage of ESLint and Typescript:
44

55
{{project.eslint}}
66

7-
If there are no ESLint configuration files found, use StandardJS to lint the project with a consistent config.
8-
9-
When using StandardJS, use typescript only if tsconfigs are reported.
7+
## Pick Linter
8+
If there are no ESLint configuration files found, use StandardJS to lint the project.
109

10+
## Linter Args
11+
When using StandardJS, use typescript arg only if tsconfigs are reported.
1112
If there is an ESLint config, lint the project using the right version of ESLint.
1213

13-
Once you have your report, determine total number of violations. For more than 10 violations, create a branch.
14+
## Lint Steps
15+
16+
Do the following to lint a JS/TS project:
17+
18+
1. Create a new branch with git.
19+
20+
2. Run the linter chosen, fixing violations.
21+
22+
3. Determine total number of remaining violations after autofix.
1423

15-
For less than 10 violations, complain about them.
24+
4. Fix the remaining violations
25+
You must fix files with the following steps:
26+
- For less than 10 violations, use `complain`.
27+
- For more than 10 violations, use `read_files` to read violating files, and use `write_files` to fix them.
28+

prompts/eslint/020_user_prompt.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
Lint my project's JS/TS files.
1+
Lint my project's JS/TS files. Use branch linting-eslint or a different one if it exists.
2+
3+
Report what you did, broken down by each tool.

prompts/eslint/README.md

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,40 @@ functions:
5454
- command
5555
- args
5656
container:
57-
image: vonwig/git:latest
58-
- name: git-files
59-
description: Handles git files
57+
image: vonwig/git:local
58+
- name: write_files
59+
description: Write a set of files to my project
6060
parameters:
6161
type: object
6262
properties:
63-
command:
64-
type: string
65-
description: The git command to use `add`, `rm`, or `mv`.
66-
args:
67-
type: string
68-
description: The args to use after the command
69-
required:
70-
- command
71-
- args
63+
files:
64+
type: array
65+
items:
66+
type: object
67+
properties:
68+
path:
69+
type: string
70+
description: the relative path to the file that should be written
71+
content:
72+
type: string
73+
description: the content that should be written to a file
74+
executable:
75+
type: boolean
76+
description: whether to make the file executable
77+
container:
78+
image: vonwig/function_write_files:latest
79+
- name: read_files
80+
description: Reads a set of files back
81+
parameters:
82+
type: object
83+
properties:
84+
files:
85+
type: array
86+
items:
87+
type: string
88+
description: Relative path to a file to read.
7289
container:
73-
image: vonwig/git:latest
90+
image: vonwig/read_files:latest
7491
- name: complain
7592
description: Complain about a file
7693
parameters:
@@ -90,11 +107,10 @@ functions:
90107
description: The row or column
91108
edit:
92109
type: string
93-
description: The edit to make
110+
description: Code to insert between start_location and end_location which will resolve the violation. Do not include ignore comments.
94111
required:
95112
- start_location
96113
- end_location
97-
- edit
98114
container:
99115
image: alpine:latest
100116
entrypoint:

0 commit comments

Comments
 (0)