ac94227b94
- SQLite: tasks with subtasks and time tracking, subscriptions + payments, routines + history, reminder log. All rules in core.Ops (tested: ops/tests). - brain: free text → JSON actions via the local claude CLI (Haiku, the subscription); only whitelisted operations are applied, nothing is deleted. - Telegram bot (owner only): text and voice (faster-whisper on the VM), /today /tasks /subs /routines /stop, morning digest and daily reminders with Done/Paid/Tomorrow. - HTTP API for BroV (bearer token): agenda, tasks, subs, routines, say, action. - deploy/install.sh: user brovops, venv, systemd; a proxy-only mihomo (127.0.0.1:7890, checksum-verified) so Telegram and Claude work from Russia without a VPN on the VM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.7 KiB
Python
71 lines
2.7 KiB
Python
"""SQLite storage for BroV Ops: tasks (with subtasks and time tracking), subscriptions
|
|
with their payments, routines with their history, and a log of sent reminders."""
|
|
import sqlite3
|
|
|
|
SCHEMA = """
|
|
CREATE TABLE IF NOT EXISTS tasks (
|
|
id INTEGER PRIMARY KEY,
|
|
parent_id INTEGER REFERENCES tasks(id) ON DELETE CASCADE,
|
|
title TEXT NOT NULL,
|
|
notes TEXT NOT NULL DEFAULT '',
|
|
client TEXT NOT NULL DEFAULT '', -- saga / planet9 / home / …
|
|
status TEXT NOT NULL DEFAULT 'todo', -- todo | doing | done
|
|
due TEXT, -- YYYY-MM-DD
|
|
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
done_at TEXT
|
|
);
|
|
CREATE TABLE IF NOT EXISTS time_entries (
|
|
id INTEGER PRIMARY KEY,
|
|
task_id INTEGER NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
|
|
started TEXT NOT NULL, -- ISO datetime, UTC
|
|
stopped TEXT
|
|
);
|
|
CREATE TABLE IF NOT EXISTS subscriptions (
|
|
id INTEGER PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
amount REAL NOT NULL DEFAULT 0,
|
|
currency TEXT NOT NULL DEFAULT 'RUB',
|
|
period TEXT NOT NULL DEFAULT 'month', -- day | week | month | year
|
|
every INTEGER NOT NULL DEFAULT 1, -- every N periods
|
|
next_date TEXT NOT NULL, -- YYYY-MM-DD of the next charge
|
|
remind_days INTEGER NOT NULL DEFAULT 3,
|
|
notes TEXT NOT NULL DEFAULT '',
|
|
active INTEGER NOT NULL DEFAULT 1
|
|
);
|
|
CREATE TABLE IF NOT EXISTS payments (
|
|
id INTEGER PRIMARY KEY,
|
|
sub_id INTEGER NOT NULL REFERENCES subscriptions(id) ON DELETE CASCADE,
|
|
paid_on TEXT NOT NULL,
|
|
amount REAL NOT NULL
|
|
);
|
|
CREATE TABLE IF NOT EXISTS routines (
|
|
id INTEGER PRIMARY KEY,
|
|
title TEXT NOT NULL,
|
|
every_days INTEGER NOT NULL,
|
|
next_date TEXT NOT NULL,
|
|
notes TEXT NOT NULL DEFAULT '',
|
|
active INTEGER NOT NULL DEFAULT 1
|
|
);
|
|
CREATE TABLE IF NOT EXISTS routine_log (
|
|
id INTEGER PRIMARY KEY,
|
|
routine_id INTEGER NOT NULL REFERENCES routines(id) ON DELETE CASCADE,
|
|
done_on TEXT NOT NULL,
|
|
note TEXT NOT NULL DEFAULT ''
|
|
);
|
|
CREATE TABLE IF NOT EXISTS reminders_sent (
|
|
kind TEXT NOT NULL, -- task | sub | routine | digest
|
|
ref INTEGER NOT NULL,
|
|
day TEXT NOT NULL, -- YYYY-MM-DD the reminder was sent for
|
|
PRIMARY KEY (kind, ref, day)
|
|
);
|
|
"""
|
|
|
|
|
|
def connect(path: str) -> sqlite3.Connection:
|
|
con = sqlite3.connect(path, check_same_thread=False, isolation_level=None)
|
|
con.row_factory = sqlite3.Row
|
|
con.execute("PRAGMA foreign_keys = ON")
|
|
con.execute("PRAGMA journal_mode = WAL")
|
|
con.executescript(SCHEMA)
|
|
return con
|