From d3a5dc2b31294dbebfa290247c29d48e2e34c58a Mon Sep 17 00:00:00 2001 From: Colin McNeil Date: Wed, 24 Jul 2024 17:43:26 -0400 Subject: [PATCH 1/2] Pylint --- functions/pylint/Dockerfile | 16 +++++++++++++ functions/pylint/lint.sh | 18 +++++++++++++++ functions/pylint/output_format.sh | 35 +++++++++++++++++++++++++++++ prompts/pylint/010_system_prompt.md | 1 + prompts/pylint/020_user_prompt.md | 4 ++++ prompts/pylint/README.md | 7 ++++++ 6 files changed, 81 insertions(+) create mode 100644 functions/pylint/Dockerfile create mode 100644 functions/pylint/lint.sh create mode 100644 functions/pylint/output_format.sh create mode 100644 prompts/pylint/010_system_prompt.md create mode 100644 prompts/pylint/020_user_prompt.md create mode 100644 prompts/pylint/README.md diff --git a/functions/pylint/Dockerfile b/functions/pylint/Dockerfile new file mode 100644 index 0000000..43bda06 --- /dev/null +++ b/functions/pylint/Dockerfile @@ -0,0 +1,16 @@ +FROM python:alpine3.20 + +# Install pylint +RUN pip install pylint + +# Install bash and jq +RUN apk add --no-cache bash jq + +# Copy the lint script +COPY lint.sh /lint.sh +RUN chmod +x /lint.sh + +COPY output_format.sh /output_format.sh +RUN chmod +x /output_format.sh + +ENTRYPOINT [ "/lint.sh" ] \ No newline at end of file diff --git a/functions/pylint/lint.sh b/functions/pylint/lint.sh new file mode 100644 index 0000000..9f6ea95 --- /dev/null +++ b/functions/pylint/lint.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +JSON_ARGS=$1 + +args=$(echo $JSON_ARGS | jq -r '.args') +output_format=$(echo $JSON_ARGS | jq -r '.output_format') + +# If no args or args is "null" +if [ -z "$args" ] || [ "$args" == "null" ]; then + args="." +fi + +# If no output_format or output_format is "null" +if [ -z "$output_format" ] || [ "$output_format" == "null" ]; then + output_format="summary" +fi + +pylint --recursive=y --output-format=json $args | /output_format.sh "$output_format" \ No newline at end of file diff --git a/functions/pylint/output_format.sh b/functions/pylint/output_format.sh new file mode 100644 index 0000000..d91ce5d --- /dev/null +++ b/functions/pylint/output_format.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +INPUT=$(cat) +FORMAT=$1 + +if [ "$FORMAT" == "json" ]; then + echo "$INPUT" + exit 0 +fi + +MESSAGES=$(echo "$INPUT" | jq -r -c '.[]') + +if [ "$FORMAT" == "summary" ]; then + + TOTAL_MESSAGES=$(echo "$MESSAGES" | wc -l) + + TOTAL_AFFECTED_FILES=$(echo $INPUT | jq -r '.[].path' | sort | uniq | wc -l) + echo "Ran pylint and found $TOTAL_MESSAGES messages across $TOTAL_AFFECTED_FILES files." + exit +fi + +for MESSAGE in $MESSAGES; do + MESSAGE_TYPE=$(echo "$MESSAGE" | jq -r '.type') + MESSAGE_LINE=$(echo "$MESSAGE" | jq -r '.line') + MESSAGE_COLUMN=$(echo "$MESSAGE" | jq -r '.column') + MESSAGE_PATH=$(echo "$MESSAGE" | jq -r '.path') + MESSAGE_FILE=$(echo "$MESSAGE" | jq -r '.file') + MESSAGE_SYMBOL=$(echo "$MESSAGE" | jq -r '.symbol') + MESSAGE_MESSAGE=$(echo "$MESSAGE" | jq -r '.message') + # If condensed + if [ "$FORMAT" == "condensed" ]; then + echo "$MESSAGE_TYPE: $MESSAGE_CODE" + continue + fi +done \ No newline at end of file diff --git a/prompts/pylint/010_system_prompt.md b/prompts/pylint/010_system_prompt.md new file mode 100644 index 0000000..ed2bce5 --- /dev/null +++ b/prompts/pylint/010_system_prompt.md @@ -0,0 +1 @@ +You are an assistant who specializes in running pylint. \ No newline at end of file diff --git a/prompts/pylint/020_user_prompt.md b/prompts/pylint/020_user_prompt.md new file mode 100644 index 0000000..52de8d8 --- /dev/null +++ b/prompts/pylint/020_user_prompt.md @@ -0,0 +1,4 @@ + +Lint python files in my project. + +Report the response. \ No newline at end of file diff --git a/prompts/pylint/README.md b/prompts/pylint/README.md new file mode 100644 index 0000000..114a546 --- /dev/null +++ b/prompts/pylint/README.md @@ -0,0 +1,7 @@ +--- +functions: + - name: pylint + description: Runs pylint against current project + container: + image: vonwig/pylint:latest +--- From 8d3de8578dd2e5347244048bf626cb1727a834d4 Mon Sep 17 00:00:00 2001 From: Colin McNeil Date: Fri, 26 Jul 2024 10:26:01 -0400 Subject: [PATCH 2/2] tee_sitter and pylint image updates --- prompts/pylint/020_user_prompt.md | 2 +- prompts/pylint/README.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/prompts/pylint/020_user_prompt.md b/prompts/pylint/020_user_prompt.md index 52de8d8..9813db1 100644 --- a/prompts/pylint/020_user_prompt.md +++ b/prompts/pylint/020_user_prompt.md @@ -1,4 +1,4 @@ -Lint python files in my project. +Lint python files in my project using 'condensed' . Report the response. \ No newline at end of file diff --git a/prompts/pylint/README.md b/prompts/pylint/README.md index 114a546..3fc8275 100644 --- a/prompts/pylint/README.md +++ b/prompts/pylint/README.md @@ -2,6 +2,12 @@ functions: - name: pylint description: Runs pylint against current project + parameters: + type: object + properties: + output_format: + type: string + description: The output level to use. `summary` | `json` | `condensed` | `complaints` container: image: vonwig/pylint:latest ---