brag-sheet: add insert/update script, simplify SKILL.md

This commit is contained in:
Connor Rhodes 2026-05-22 16:23:31 -05:00
parent 37002b305e
commit eb8da9611e
2 changed files with 118 additions and 41 deletions

View file

@ -18,55 +18,26 @@ Each document has the following fields:
| `context` | `string` | Your own notes explaining the project/situation context where this feedback came from | | `context` | `string` | Your own notes explaining the project/situation context where this feedback came from |
| `tags` | `array[string]` | Tags for categorization. Default: `["work"]`. Can include additional tags like `"personal"`, etc. | | `tags` | `array[string]` | Tags for categorization. Default: `["work"]`. Can include additional tags like `"personal"`, etc. |
## Connection ## Script
Use the MongoDB connection from the `mongodb` skill. Connection string: All inserts and updates go through `scripts/brag_sheet.py`. Run it with `uv`:
```
mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563
```
## How to Add an Entry
When the user provides positive feedback they want to save:
1. **Collect the information** from the user:
- `note`: The kudos/feedback text. This is usually provided verbatim (e.g., an email, Slack message, or verbal feedback someone gave them).
- `context`: Background from the user about the project, situation, or relationship context. Ask for this if not provided.
- `tags`: Default to `["work"]` unless the user specifies otherwise.
2. **Insert the document** using an inline Python script with `uv`:
```python
from pymongo import MongoClient
from datetime import datetime
client = MongoClient("mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563")
db = client["notes"]
collection = db["brag_sheet"]
result = collection.insert_one({
"date": datetime.now(),
"note": "<the kudos text>",
"context": "<the user's context about the project>",
"tags": ["work"]
})
print(f"Inserted: {result.inserted_id}")
client.close()
```
Run it via:
```bash ```bash
cat <<'PYEOF' | uv run --with pymongo python - # Add a new entry
<script here> uv run ~/notes/skills/brag-sheet/scripts/brag_sheet.py add "<note>" "<context>" [--tags tag1,tag2]
PYEOF
# Update an existing entry by doc ID
uv run ~/notes/skills/brag-sheet/scripts/brag_sheet.py update <doc_id> [--note "..."] [--context "..."] [--tags tag1,tag2]
``` ```
- `note`: The kudos/feedback text, verbatim.
- `context`: Background on the project or situation.
- `tags`: Comma-separated. Defaults to `work` if omitted.
## What to Ask the User ## What to Ask the User
When the user says "add this to my brag sheet" or similar: When the user says "add this to my brag sheet" or similar:
- The `note` text is usually provided directly by the user. - The `note` text is usually provided directly by the user.
- If the user doesn't provide `context`, ask: "What's the context for this feedback?" or "What project or situation was this from?" - If the user doesn't provide `context`, ask: "What's the context for this feedback?" or "What project or situation was this from?"
- If the user doesn't specify tags, default to `["work"]`. - If the user doesn't specify tags, default to `work`.

View file

@ -0,0 +1,106 @@
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = ["pymongo"]
# ///
"""Log entries to the notes.brag_sheet MongoDB collection.
Usage:
brag_sheet.py add "<note>" "<context>" [--tags tag1,tag2]
brag_sheet.py update <doc_id> [--note "..."] [--context "..."] [--tags tag1,tag2]
"""
import sys
from datetime import datetime
from bson import ObjectId
from pymongo import MongoClient
MONGO_URI = "mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563"
def parse_tags(args, i):
raw = args[i + 1]
return [t.strip() for t in raw.split(",") if t.strip()], i + 2
def handle_add(args):
if len(args) < 2:
print("Usage: brag_sheet.py add \"<note>\" \"<context>\" [--tags tag1,tag2]")
sys.exit(1)
note = args[0]
context = args[1]
tags = ["work"]
i = 2
while i < len(args):
if args[i] == "--tags" and i + 1 < len(args):
tags, i = parse_tags(args, i)
else:
print(f"Error: unknown argument '{args[i]}'")
sys.exit(1)
client = MongoClient(MONGO_URI)
result = client["notes"]["brag_sheet"].insert_one({
"date": datetime.now(),
"note": note,
"context": context,
"tags": tags,
})
print(f"Inserted: {result.inserted_id}")
client.close()
def handle_update(args):
if not args:
print("Usage: brag_sheet.py update <doc_id> [--note ...] [--context ...] [--tags tag1,tag2]")
sys.exit(1)
doc_id = args.pop(0)
updates = {}
i = 0
while i < len(args):
if args[i] == "--note" and i + 1 < len(args):
updates["note"] = args[i + 1]; i += 2
elif args[i] == "--context" and i + 1 < len(args):
updates["context"] = args[i + 1]; i += 2
elif args[i] == "--tags" and i + 1 < len(args):
updates["tags"], i = parse_tags(args, i)
else:
print(f"Error: unknown argument '{args[i]}'")
sys.exit(1)
if not updates:
print("Error: no fields to update")
sys.exit(1)
client = MongoClient(MONGO_URI)
result = client["notes"]["brag_sheet"].update_one(
{"_id": ObjectId(doc_id)},
{"$set": updates}
)
if result.matched_count:
print(f"Updated {doc_id}: {list(updates.keys())}")
else:
print(f"Error: document {doc_id} not found")
client.close()
def main():
args = sys.argv[1:]
if not args:
print(__doc__)
sys.exit(1)
cmd = args.pop(0)
if cmd == "add":
handle_add(args)
elif cmd == "update":
handle_update(args)
else:
print(f"Error: unknown command '{cmd}'. Use 'add' or 'update'.")
sys.exit(1)
if __name__ == "__main__":
main()