From 2828a14eaa05bd8bcc3b381125f9b539b95587c5 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 29 Apr 2025 02:48:35 -0400 Subject: Simple budget report This isn't an agent yet but it shows the power of just `llm` - I'll need to work on the full agent framework next. --- BudgetReport.sh | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 BudgetReport.sh diff --git a/BudgetReport.sh b/BudgetReport.sh new file mode 100755 index 0000000..65be630 --- /dev/null +++ b/BudgetReport.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# +set -euo pipefail +tempdir=$(mktemp --tmpdir -d "budget.report.XXX") +#trap 'rm -rf "$tempdir"' EXIT +pushd "$tempdir" + +# generate budget report +(cd /home/ben/fund ; \ + eval "$(direnv export bash 2>/dev/null)" ; \ + hledger @budget.args -O csv | csv2md) > budget.md + +# generate analysis +today=$(date +%Y-%m-%d) +month=$(date +%Y-%m) +llm -m claude -s "Today is $today. +This is a budget report for Ben and Kate's household as CSV data. +The 'Account' column is the abbreviated account name. +The 'budget' column is how much we budgeted for this month. +The '$month' column is how much we actually spent so far this month. +Create a report that summarizes how much we have spent so far. +Make recommendations to help us stay under budget for the rest of the month. +Identify opportunities to save money or to make room in the budget. +Be concise and to the point. +Don't offer follow-up tasks, this is a one-off report, not a conversation. + +Account names are abbreviated like so: +- 'ex' means an expense account +- 'ex:us:need' are necessary operating expenses, these are consistent + month-to-month and we don't have much room to reduce them in most cases +- 'ex:us:need:home' are mostly-fixed utilities, can't really change these +- 'ex:us:need:home:pool' is only active during the summer += 'ex:us:need:auto' varies slightly month-to-month, but we cannot change it +- 'ex:us:want' are discretionary spending accounts, we have the most room for + modification here +- 'ex:me' are Ben's personal expenses +- 'li' means a liability, these are mostly consistent and must be paid + +" < budget.md > analysis.md + + +subject="Budget Report for $today" + +cat analysis.md <(echo) <(echo) budget.md > email.md +pandoc --standalone --metadata title="$subject" \ + -f markdown_mmd -t html -i email.md -o email.html + +email_args=( + --to ben@bensima.com + --to katesima21@gmail.com + --from ben@bensima.com + --smtp-server bensima.com + --subject "$subject" + --body-text "$(realpath email.md)" + --body-html "$(realpath email.html)" +) +popd +Biz/EmailAgent.py "${email_args[@]}" --password-file <(pass ben@bensima.com) -- cgit v1.2.3