Skip to content

Commit

Permalink
feat: Add filename sanitization and logging for AI-generated bash-my-…
Browse files Browse the repository at this point in the history
…aws commands
  • Loading branch information
mbailey committed Dec 4, 2024
1 parent 02c3717 commit a628192
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
12 changes: 12 additions & 0 deletions ai_slop/.bash-my-aws}/ai_slop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# AI Slop Directory

This directory contains outputs from the `bmai` command which generates bash-my-aws functions on the fly.

The term "AI Slop" was coined by Simon Willison (creator of the Python LLM package) to describe
the raw, unfiltered output from AI language models that may need human review before use.

Each file in this directory represents a generated function, named after the prompt that created it.
These files serve as a reference and audit trail of AI-generated commands.

Files are created automatically when you run the `bmai` command to generate missing bash-my-aws
functions.
12 changes: 12 additions & 0 deletions ai_slop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# AI Slop Directory

This directory contains outputs from the `bmai` command which generates bash-my-aws functions on the fly.

"AI Slop" refers to raw, unfiltered output from AI language models that may need human review before use.
Simon Willison (creator of the Python LLM package) popularized this usage in the context of CLI tools.

Each file in this directory represents a generated function, named after the prompt that created it.
These files serve as a reference and audit trail of AI-generated commands.

Files are created automatically when you run the `bmai` command to generate missing bash-my-aws
functions.
9 changes: 8 additions & 1 deletion lib/extras/bmai
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ bmai() {
- Do not provide a preamble or closing comments.
"

# Create a filename by converting the prompt to lowercase, replacing spaces with hyphens,
# and truncating to 50 chars
local filename=$(echo "$*" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | cut -c1-50)

mkdir -p "${BMA_HOME:-$HOME/.bash-my-aws}/ai_slop"

llm prompt \
-s "$(<"${conventions}")" \
"Do not provide a preamble or closing comments. Output only an authentic bash-my-aws command that follows the conventions and does the following: '$@'"
"Do not provide a preamble or closing comments. Output only an authentic bash-my-aws command that follows the conventions and does the following: '$@'" \
| tee "${BMA_HOME:-$HOME/.bash-my-aws}/ai_slop/${filename}"
}

# Execute function with same name as file called unless sourced
Expand Down

0 comments on commit a628192

Please sign in to comment.