prodev skill: add price/vendor/product_type fields to DB entries

This commit is contained in:
Connor Rhodes 2026-05-22 16:22:22 +00:00
parent 2df14f1694
commit c556d5fecd
2 changed files with 63 additions and 24 deletions

View file

@ -23,29 +23,35 @@ When Connor needs to justify a training, tool, book, course, or other profession
- Resource name or URL (visit the URL to get accurate details) - Resource name or URL (visit the URL to get accurate details)
- Specific topics it covers - Specific topics it covers
2. Write a single, direct paragraph. 2. **Research the resource.** If Connor provides a URL, fetch the page to get accurate details about contents, format, and topics. Also try to extract:
- **Price** — look for pricing on the page
- **Vendor** — identify the creator/company selling it
- **Product type** — classify it (e.g., `educational course`, `book`, `subscription`, `conference`, `tool`)
3. Do not ask follow-up questions or offer alternatives — just produce the paragraph. If any of these cannot be determined from the URL, ask Connor as a follow-up before proceeding.
3. Write a single, direct paragraph.
4. Save the file to `~/notes/Inbox/agent/`. Use the format `YYMMDD-pro-dev-[short-name].md`. 4. Save the file to `~/notes/Inbox/agent/`. Use the format `YYMMDD-pro-dev-[short-name].md`.
5. **Create a database entry** using the script: 5. **Create a database entry** using the script:
```bash ```bash
uv run --with pymongo ~/notes/skills/professional-development-business-case/scripts/prodev_tasks.py create "<paragraph>" uv run --with pymongo ~/notes/skills/professional-development-business-case/scripts/prodev_tasks.py create "<paragraph>" --price <price> --vendor "<vendor>" --product-type "<product type>"
``` ```
This inserts into `wip.agent_tasks` with `type: "prodev expense"` and `status: "todo"`. Save the returned document ID. This inserts into `wip.agent_tasks` with `type: "prodev expense"`, `status: "todo"`, and metadata fields `price`, `vendor`, `product_type`. Save the returned document ID.
6. **If Connor asks to update the wording**, update both the saved file AND the database entry: 6. **If Connor asks to update the wording**, update both the saved file AND the database entry:
```bash ```bash
uv run --with pymongo ~/notes/skills/professional-development-business-case/scripts/prodev_tasks.py update <document_id> "<updated_paragraph>" uv run --with pymongo ~/notes/skills/professional-development-business-case/scripts/prodev_tasks.py update <document_id> "<updated_paragraph>"
``` ```
You can also update individual metadata fields with `--price`, `--vendor`, `--product-type`.
## Database Commands ## Database Commands
The script supports three commands: The script supports three commands:
- `create "<note>"` — insert a new prodev expense entry - `create "<note>" [--price PRICE] [--vendor VENDOR] [--product-type TYPE]` — insert a new prodev expense entry
- `update <doc_id> "<note>"` — update the note for an existing entry - `update <doc_id> "<note>" [--price PRICE] [--vendor VENDOR] [--product-type TYPE]` — update the note and/or metadata for an existing entry
- `list` — list all prodev expense entries - `list` — list all prodev expense entries with price, vendor, and product type
## Rules ## Rules

View file

@ -2,12 +2,13 @@
"""Manage prodev expense entries in wip.agent_tasks on DocDB. """Manage prodev expense entries in wip.agent_tasks on DocDB.
Usage: Usage:
prodev_tasks.py create "<note>" prodev_tasks.py create "<note>" [--price PRICE] [--vendor VENDOR] [--product-type TYPE]
prodev_tasks.py update <document_id> "<note>" prodev_tasks.py update <document_id> "<note>" [--price PRICE] [--vendor VENDOR] [--product-type TYPE]
prodev_tasks.py list prodev_tasks.py list
""" """
import sys import sys
import argparse
from pymongo import MongoClient from pymongo import MongoClient
URI = "mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563?tls=true&tlsAllowInvalidCertificates=true" URI = "mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563?tls=true&tlsAllowInvalidCertificates=true"
@ -18,15 +19,29 @@ def get_collection():
client = MongoClient(URI, serverSelectionTimeoutMS=10000) client = MongoClient(URI, serverSelectionTimeoutMS=10000)
return client[DB][COLL], client return client[DB][COLL], client
def create(note): def create(note, price=None, vendor=None, product_type=None):
coll, client = get_collection() coll, client = get_collection()
result = coll.insert_one({"note": note, "type": "prodev expense", "status": "todo"}) doc = {"note": note, "type": "prodev expense", "status": "todo"}
if price is not None:
doc["price"] = float(price)
if vendor is not None:
doc["vendor"] = vendor
if product_type is not None:
doc["product_type"] = product_type
result = coll.insert_one(doc)
print(result.inserted_id) print(result.inserted_id)
client.close() client.close()
def update(doc_id, note): def update(doc_id, note, price=None, vendor=None, product_type=None):
coll, client = get_collection() coll, client = get_collection()
result = coll.update_one({"_id": doc_id}, {"$set": {"note": note}}) sets = {"note": note}
if price is not None:
sets["price"] = float(price)
if vendor is not None:
sets["vendor"] = vendor
if product_type is not None:
sets["product_type"] = product_type
result = coll.update_one({"_id": doc_id}, {"$set": sets})
print(f"matched={result.matched_count} modified={result.modified_count}") print(f"matched={result.matched_count} modified={result.modified_count}")
client.close() client.close()
@ -34,22 +49,40 @@ def list_all():
from bson import ObjectId from bson import ObjectId
coll, client = get_collection() coll, client = get_collection()
for doc in coll.find({"type": "prodev expense"}): for doc in coll.find({"type": "prodev expense"}):
print(f"{doc['_id']} | {doc['status']} | {doc['note'][:80]}...") price = doc.get("price", "?")
vendor = doc.get("vendor", "?")
ptype = doc.get("product_type", "?")
print(f"{doc['_id']} | ${price} | {vendor} | {ptype} | {doc['status']} | {doc['note'][:60]}...")
client.close() client.close()
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) < 2: parser = argparse.ArgumentParser(description="Manage prodev expense entries")
print(__doc__) sub = parser.add_subparsers(dest="cmd")
sys.exit(1)
cmd = sys.argv[1] p_create = sub.add_parser("create")
if cmd == "create" and len(sys.argv) >= 3: p_create.add_argument("note")
create(sys.argv[2]) p_create.add_argument("--price", default=None)
elif cmd == "update" and len(sys.argv) >= 4: p_create.add_argument("--vendor", default=None)
p_create.add_argument("--product-type", default=None)
p_update = sub.add_parser("update")
p_update.add_argument("doc_id")
p_update.add_argument("note")
p_update.add_argument("--price", default=None)
p_update.add_argument("--vendor", default=None)
p_update.add_argument("--product-type", default=None)
sub.add_parser("list")
args = parser.parse_args()
if args.cmd == "create":
create(args.note, args.price, args.vendor, args.product_type)
elif args.cmd == "update":
from bson import ObjectId from bson import ObjectId
update(ObjectId(sys.argv[2]), sys.argv[3]) update(ObjectId(args.doc_id), args.note, args.price, args.vendor, args.product_type)
elif cmd == "list": elif args.cmd == "list":
list_all() list_all()
else: else:
print(__doc__) parser.print_help()
sys.exit(1) sys.exit(1)