Add airport address alias to log-work-expense skill

This commit is contained in:
Connor Rhodes 2026-05-20 17:52:08 -05:00
parent bda05feab1
commit f473c09a26
2 changed files with 50 additions and 4 deletions

View file

@ -25,7 +25,7 @@ Log work expenses into `wip.work_expenses` via `scripts/log_expense.py`.
4. **Insert via script** — Run the script once **per entry**: 4. **Insert via script** — Run the script once **per entry**:
```bash ```bash
uv run --with pymongo ~/notes/skills/log-work-expense/scripts/log_expense.py <type> <account> <date> "<note>" <s2_url_1> [s2_url_2] uv run --with pymongo ~/notes/skills/log-work-expense/scripts/log_expense.py <type> <account> <date> "<note>" <s2_url_1> [s2_url_2] [--route "stop1|stop2"]
``` ```
- **Meal receipts**: Run once per receipt (1 file each). - **Meal receipts**: Run once per receipt (1 file each).
@ -33,6 +33,23 @@ uv run --with pymongo ~/notes/skills/log-work-expense/scripts/log_expense.py <ty
The script enforces file counts and rejects invalid input. The script enforces file counts and rejects invalid input.
### Mileage Routes
For mileage entries, always include `--route` with the destination address(es). Separate multiple stops with `|`. Home (`11600 Minda Cir Austin, TX 78758`) is automatically prepended and appended — only provide the intermediate stop(s).
- **One address**: `--route "123 Main St Austin, TX"` → route becomes `[home, "123 Main St Austin, TX", home]`
- **Multiple addresses**: `--route "123 Main St Austin, TX|456 Elm St Austin, TX"` → route becomes `[home, "123 Main St Austin, TX", "456 Elm St Austin, TX", home]`
If the user doesn't specify an address, ask for it.
#### Shorthand Aliases
When the user says a shorthand, expand it to the full address before building the route:
| Shorthand | Full Address |
|-----------|-------------|
| `airport` or `AUS` | `3201 Presidential Blvd, Austin, TX 78719` |
5. **Confirm** — Brief summary of what was logged. 5. **Confirm** — Brief summary of what was logged.
## Notes ## Notes

View file

@ -2,13 +2,15 @@
"""Log work expenses to MongoDB (wip.work_expenses). """Log work expenses to MongoDB (wip.work_expenses).
Usage: Usage:
python log_expense.py <type> <account> <date> <note> <s2_url_1> [s2_url_2] python log_expense.py <type> <account> <date> <note> <s2_url_1> [s2_url_2] [--route stop1,stop2,...]
type: "meal" or "mileage" type: "meal" or "mileage"
account: e.g. "LTISD" account: e.g. "LTISD"
date: YYYY-MM-DD date: YYYY-MM-DD
note: free-text context (quote if it has spaces) note: free-text context (quote if it has spaces)
s2_url: one or more S2 URLs of uploaded files s2_url: one or more S2 URLs of uploaded files
--route: comma-separated list of stops (mileage only). Home address is
automatically prepended and appended.
Rules enforced: Rules enforced:
- meal: exactly 1 file per invocation - meal: exactly 1 file per invocation
@ -16,12 +18,32 @@ Rules enforced:
""" """
import sys import sys
from datetime import datetime
from pymongo import MongoClient from pymongo import MongoClient
HOME = "11600 Minda Cir Austin, TX 78758"
ALIASES = {
"airport": "3201 Presidential Blvd, Austin, TX 78719",
"aus": "3201 Presidential Blvd, Austin, TX 78719",
}
def main(): def main():
args = sys.argv[1:] args = sys.argv[1:]
route_stops = None
if "--route" in args:
idx = args.index("--route")
args.pop(idx)
if idx >= len(args):
print("Error: --route requires a value")
sys.exit(1)
route_val = args.pop(idx)
route_stops = [s.strip() for s in route_val.split("|") if s.strip()]
route_stops = [ALIASES.get(s.lower(), s) for s in route_stops]
route_stops = [HOME] + route_stops + [HOME]
if len(args) < 5: if len(args) < 5:
print("Usage: log_expense.py <type> <account> <date> <note> <s2_url_1> [s2_url_2]") print('Usage: log_expense.py <type> <account> <date> <note> <s2_url_1> [s2_url_2] [--route stop1|stop2]')
sys.exit(1) sys.exit(1)
exp_type = args[0] exp_type = args[0]
@ -42,19 +64,26 @@ def main():
print(f"Error: mileage entries must have exactly 2 files (start + end odometer), got {len(files)}") print(f"Error: mileage entries must have exactly 2 files (start + end odometer), got {len(files)}")
sys.exit(1) sys.exit(1)
if route_stops is not None and exp_type != "mileage":
print("Error: --route is only valid for mileage entries")
sys.exit(1)
client = MongoClient("mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563?tls=true&tlsAllowInvalidCertificates=true") client = MongoClient("mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563?tls=true&tlsAllowInvalidCertificates=true")
db = client["wip"] db = client["wip"]
col = db["work_expenses"] col = db["work_expenses"]
doc = { doc = {
"files": files, "files": files,
"date": date, "date": datetime.strptime(date, "%Y-%m-%d"),
"type": exp_type, "type": exp_type,
"account": account, "account": account,
"note": note, "note": note,
"status": "todo" "status": "todo"
} }
if route_stops is not None:
doc["route"] = route_stops
result = col.insert_one(doc) result = col.insert_one(doc)
print(f"Inserted {exp_type} for {account} on {date}: {result.inserted_id}") print(f"Inserted {exp_type} for {account} on {date}: {result.inserted_id}")