feat(kvb-coach): coach the operator's next step and remember what they enjoy
🧪 Test / 🧪 Lock + lint (push) Canceled after 0s
🧪 Test / 🧪 Lock + lint (push) Canceled after 0s
kvb-coach reads the situation (local time, hours at work today, the profile, open operator commands from kvb-org-operator, delegable kvb-org-rasci tasks) and suggests at most one next step per area: psyche, body, sleep, food, the operator's own tasks, and tasks to delegate to agents; short, friendly, with emojis, ordered by what the situation needs and biased to what the operator likes. It runs kvb-think-listen often to learn preferences. coach.py keeps the host-local profile in the gitignored .state/ of the skills repository: likes and dislikes per area (one replaces the other), a capped done-log, and the hours since the last activity per area; tests/test_coach.py covers it. General wellbeing only, no medical advice. Operator order 2026-11-03; two descriptions trimmed for the listing budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c30103b43
commit
57c3322076
7 files changed
+286
-9
No files matched your search
@@ -0,0 +1,66 @@
|
||||
"""Exercise coach.py: preferences flip between like and dislike, the log feeds hours since."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT = REPO_ROOT / "skills" / "kvb-coach" / "scripts" / "coach.py"
|
||||
|
||||
|
||||
class TestCoach(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
self.profile = Path(self.tmp.name) / "state" / "coach.json"
|
||||
|
||||
def _run(self, *args: str) -> subprocess.CompletedProcess:
|
||||
return subprocess.run(
|
||||
[sys.executable, str(SCRIPT), "--profile", str(self.profile), *args],
|
||||
check=False,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
def _show(self, now: str) -> dict:
|
||||
result = self._run("show", "--now", now, "--json")
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
return {row["area"]: row for row in json.loads(result.stdout)}
|
||||
|
||||
def test_a_dislike_replaces_a_like_and_forget_drops_it(self):
|
||||
self._run("like", "body", "Laufen")
|
||||
self._run("like", "body", "Laufen")
|
||||
self._run("like", "body", "Yoga")
|
||||
self._run("dislike", "body", "Laufen")
|
||||
body = self._show("2026-11-03T18:00:00+00:00")["body"]
|
||||
self.assertEqual(body["likes"], ["Yoga"])
|
||||
self.assertEqual(body["dislikes"], ["Laufen"])
|
||||
self._run("forget", "body", "Laufen")
|
||||
self.assertEqual(self._show("2026-11-03T18:00:00+00:00")["body"]["dislikes"], [])
|
||||
|
||||
def test_the_latest_done_per_area_gives_the_hours_since(self):
|
||||
self._run("done", "food", "Frühstück", "--at", "2026-11-03T08:00:00+00:00")
|
||||
self._run("done", "food", "Mittagessen", "--at", "2026-11-03T12:30:00+00:00")
|
||||
self._run("done", "sleep", "Nacht", "--at", "2026-11-02T23:00:00+00:00")
|
||||
rows = self._show("2026-11-03T18:00:00+00:00")
|
||||
self.assertEqual((rows["food"]["last"], rows["food"]["hours_ago"]), ("Mittagessen", 5.5))
|
||||
self.assertEqual(rows["sleep"]["hours_ago"], 19.0)
|
||||
self.assertIsNone(rows["psyche"]["last"])
|
||||
|
||||
def test_invalid_input_exits_2_and_keeps_the_profile(self):
|
||||
self.assertEqual(self._run("like", "work", "x").returncode, 2)
|
||||
self.assertEqual(self._run("done", "body", "x", "--at", "gestern").returncode, 2)
|
||||
self.assertFalse(self.profile.exists())
|
||||
self.profile.parent.mkdir(parents=True)
|
||||
self.profile.write_text("{broken", encoding="utf-8")
|
||||
self.assertEqual(self._run("show").returncode, 2)
|
||||
self.assertEqual(self.profile.read_text(encoding="utf-8"), "{broken")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -11,7 +11,7 @@ SKILLS = REPO_ROOT / "skills"
|
||||
README = REPO_ROOT / "README.md"
|
||||
CATEGORIES = ("think", "create", "code", "ci", "git", "check", "org", "skill")
|
||||
UNCATEGORIZED = frozenset(
|
||||
{"kvb-cleanup", "kvb-dream", "kvb-help", "kvb-optimize", "kvb-transcend"}
|
||||
{"kvb-cleanup", "kvb-coach", "kvb-dream", "kvb-help", "kvb-optimize", "kvb-transcend"}
|
||||
)
|
||||
SPEC = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*$")
|
||||
SCHEMA = re.compile(rf"^kvb-(?:{'|'.join(CATEGORIES)})-[a-z0-9]+(?:-[a-z0-9]+)*$")
|
||||
|
||||
Reference in new issue
Block a user