Add prodev_tasks.py script and update skill with DB integration

This commit is contained in:
Connor Rhodes 2026-05-22 16:08:43 +00:00
parent d7dfb6c0e2
commit 2df14f1694
3 changed files with 75 additions and 2 deletions

View file

@ -0,0 +1,55 @@
#!/usr/bin/env python3
"""Manage prodev expense entries in wip.agent_tasks on DocDB.
Usage:
prodev_tasks.py create "<note>"
prodev_tasks.py update <document_id> "<note>"
prodev_tasks.py list
"""
import sys
from pymongo import MongoClient
URI = "mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563?tls=true&tlsAllowInvalidCertificates=true"
DB = "wip"
COLL = "agent_tasks"
def get_collection():
client = MongoClient(URI, serverSelectionTimeoutMS=10000)
return client[DB][COLL], client
def create(note):
coll, client = get_collection()
result = coll.insert_one({"note": note, "type": "prodev expense", "status": "todo"})
print(result.inserted_id)
client.close()
def update(doc_id, note):
coll, client = get_collection()
result = coll.update_one({"_id": doc_id}, {"$set": {"note": note}})
print(f"matched={result.matched_count} modified={result.modified_count}")
client.close()
def list_all():
from bson import ObjectId
coll, client = get_collection()
for doc in coll.find({"type": "prodev expense"}):
print(f"{doc['_id']} | {doc['status']} | {doc['note'][:80]}...")
client.close()
if __name__ == "__main__":
if len(sys.argv) < 2:
print(__doc__)
sys.exit(1)
cmd = sys.argv[1]
if cmd == "create" and len(sys.argv) >= 3:
create(sys.argv[2])
elif cmd == "update" and len(sys.argv) >= 4:
from bson import ObjectId
update(ObjectId(sys.argv[2]), sys.argv[3])
elif cmd == "list":
list_all()
else:
print(__doc__)
sys.exit(1)