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
@@ -9,7 +9,7 @@ Compatible with Claude Code, Codex, Gemini CLI, Cursor, Copilot, Windsurf, Cline
|
||||
|
||||
## Naming 🏷️
|
||||
|
||||
Every first-party skill is named `kvb-<category>-<name>` with one of these categories: `think`, `create`, `code`, `ci`, `git`, `check`, `org`, `skill`. Only `kvb-cleanup`, `kvb-help` and the collectors `kvb-dream`, `kvb-optimize` and `kvb-transcend` stand without a category. Names use `a-z`, `0-9` and single hyphens, at most 64 characters, and equal their directory name. `tests/test_naming.py` enforces all of it, including that the organigram below lists every skill under its category.
|
||||
Every first-party skill is named `kvb-<category>-<name>` with one of these categories: `think`, `create`, `code`, `ci`, `git`, `check`, `org`, `skill`. Only `kvb-cleanup`, `kvb-coach`, `kvb-help` and the collectors `kvb-dream`, `kvb-optimize` and `kvb-transcend` stand without a category. Names use `a-z`, `0-9` and single hyphens, at most 64 characters, and equal their directory name. `tests/test_naming.py` enforces all of it, including that the organigram below lists every skill under its category.
|
||||
|
||||
## Organigram 🏛️
|
||||
|
||||
@@ -76,6 +76,7 @@ flowchart LR
|
||||
none --> transcend_all[kvb-transcend]
|
||||
none --> dream_all[kvb-dream]
|
||||
none --> optimize_all[kvb-optimize]
|
||||
none --> coach_all[kvb-coach]
|
||||
```
|
||||
|
||||
## Skill map 🗺️
|
||||
@@ -158,6 +159,7 @@ flowchart LR
|
||||
transcend[kvb-transcend]
|
||||
dream[kvb-dream]
|
||||
optimize[kvb-optimize]
|
||||
coach[kvb-coach]
|
||||
end
|
||||
|
||||
commit_req -.-> commit_next
|
||||
@@ -240,6 +242,9 @@ flowchart LR
|
||||
optimize --> refactor
|
||||
optimize --> tune
|
||||
optimize --> gaps
|
||||
coach --> active_listening
|
||||
coach --> operator
|
||||
coach --> rasci
|
||||
autoskill --> autotune
|
||||
autotune --> essence
|
||||
transcend --> skill_transcend
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
name: kvb-coach
|
||||
description: >
|
||||
Coach the operator's next step: psyche, body, sleep, food, own and
|
||||
delegable tasks. Trigger on /kvb-coach or "was soll ich tun".
|
||||
---
|
||||
|
||||
Be the operator's coach: short, warm, concrete, with emojis, in the
|
||||
operator's language. Their health comes first; work is one area of six, not
|
||||
the default. Suggestions, never pressure.
|
||||
|
||||
The profile keeps what the operator enjoys, dislikes and last did, host-local
|
||||
in the gitignored `.state/` of the skills repository:
|
||||
|
||||
```bash
|
||||
coach.py --profile <skills repo>/.state/coach.json like|dislike|forget <area> "<thing>"
|
||||
coach.py --profile <same> done <area> "<thing>" [--at <iso>]
|
||||
coach.py --profile <same> show [--json]
|
||||
```
|
||||
|
||||
Areas: `psyche`, `body`, `sleep`, `food`, `tasks`, `delegate`.
|
||||
|
||||
## Step 1: read the situation
|
||||
|
||||
- **Time**: local time and weekday, and how long the operator has been at it
|
||||
today (their first message of the day in the session transcripts).
|
||||
- **Profile**: `coach.py show`: likes, dislikes, hours since the last sleep,
|
||||
meal, workout or break.
|
||||
- **Own tasks**: the open commands of the `kvb-org-operator` skill and the
|
||||
decisions agents wait on.
|
||||
- **Delegable**: what the operator did by hand that an agent could do, and
|
||||
queued `kvb-org-rasci` register tasks without a worker.
|
||||
|
||||
## Step 2: suggest
|
||||
|
||||
At most one line per area, the most urgent first, the whole answer on one
|
||||
screen:
|
||||
|
||||
- 🧠 **Psyche**: a short break, a walk outside, five minutes of meditation or
|
||||
box breathing, a call with a friend, something just for fun.
|
||||
- 💪 **Body**: a workout from the operator's likes (a 20-minute run, a
|
||||
bodyweight circuit, cycling, yoga), stretching neck, hips and back after
|
||||
long sitting, standing up every hour.
|
||||
- 😴 **Sleep**: wind down, screens off, seven to nine hours; a 20-minute nap
|
||||
in the early afternoon.
|
||||
- 🥗 **Food**: water, a real meal with vegetables and protein, a healthy
|
||||
snack instead of sugar, no caffeine late in the day.
|
||||
- ✅ **Your tasks**: the one step only the operator can take that unblocks
|
||||
the most.
|
||||
- 🤖 **Delegate**: what an agent can take over, with the skill or command
|
||||
that does it.
|
||||
|
||||
The situation sets the order: late evening puts sleep first, hours without
|
||||
a break put moving first, a meal more than five hours ago puts food first.
|
||||
Prefer what the operator likes, never offer a dislike, and do not repeat the
|
||||
last tip of an area. Close with one encouraging line.
|
||||
|
||||
## Step 3: listen and remember
|
||||
|
||||
Often, not every time: when the profile is empty, after a declined
|
||||
suggestion, and every few runs, run the `kvb-think-listen` skill with one
|
||||
short `AskUserQuestion` (what they enjoy, what fits right now, what to
|
||||
avoid). Record the answers with `like` and `dislike`, and what the operator
|
||||
reports having done with `done`.
|
||||
|
||||
## Rules
|
||||
|
||||
- The operator decides: no guilt, no nagging, a declined tip stays off for
|
||||
the day.
|
||||
- General wellbeing, no medical advice: pain, illness or lasting exhaustion
|
||||
get one kind pointer to a doctor.
|
||||
- The profile never leaves the host: not into commits, memory files or peer
|
||||
messages.
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Keep the operator's coaching profile: likes, dislikes and when what was done.
|
||||
|
||||
Args:
|
||||
--profile: path of the profile JSON file.
|
||||
like|dislike <area> <thing>: record a preference; one replaces the other.
|
||||
forget <area> <thing>: drop a preference.
|
||||
done <area> <thing> [--at <iso>]: log that the operator did it.
|
||||
show [--now <iso>] [--json]: likes, dislikes and the last logged activity
|
||||
per area with the hours since.
|
||||
|
||||
Exit codes:
|
||||
0 done, 2 usage error.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
AREAS = ("psyche", "body", "sleep", "food", "tasks", "delegate")
|
||||
LOG_LIMIT = 500
|
||||
|
||||
|
||||
def fail(message: str) -> None:
|
||||
print(f"coach: {message}", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
def moment(value: str | None) -> datetime.datetime:
|
||||
if value is None:
|
||||
return datetime.datetime.now(datetime.UTC)
|
||||
try:
|
||||
parsed = datetime.datetime.fromisoformat(value)
|
||||
except ValueError:
|
||||
fail(f"{value} is not an ISO timestamp")
|
||||
return parsed if parsed.tzinfo else parsed.replace(tzinfo=datetime.UTC)
|
||||
|
||||
|
||||
def load(path: Path) -> dict:
|
||||
try:
|
||||
data = json.loads(path.read_text(encoding="utf-8"))
|
||||
except FileNotFoundError:
|
||||
return {"likes": {}, "dislikes": {}, "log": []}
|
||||
except ValueError:
|
||||
fail(f"{path} is not valid JSON")
|
||||
return data
|
||||
|
||||
|
||||
def save(path: Path, data: dict) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = path.with_suffix(".tmp")
|
||||
tmp.write_text(
|
||||
json.dumps(data, indent=1, sort_keys=True, ensure_ascii=False), encoding="utf-8"
|
||||
)
|
||||
tmp.replace(path)
|
||||
|
||||
|
||||
def prefer(data: dict, keep: str, area: str, thing: str) -> None:
|
||||
for key in ("likes", "dislikes"):
|
||||
items = data[key].setdefault(area, [])
|
||||
if thing in items:
|
||||
items.remove(thing)
|
||||
if keep:
|
||||
data[keep][area].append(thing)
|
||||
|
||||
|
||||
def summary(data: dict, now: datetime.datetime) -> list[dict]:
|
||||
rows = []
|
||||
for area in AREAS:
|
||||
last = next((e for e in reversed(data["log"]) if e["area"] == area), None)
|
||||
hours = None
|
||||
if last:
|
||||
hours = round((now - moment(last["at"])).total_seconds() / 3600, 1)
|
||||
rows.append(
|
||||
{
|
||||
"area": area,
|
||||
"likes": data["likes"].get(area, []),
|
||||
"dislikes": data["dislikes"].get(area, []),
|
||||
"last": last["thing"] if last else None,
|
||||
"hours_ago": hours,
|
||||
}
|
||||
)
|
||||
return rows
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--profile", required=True)
|
||||
sub = parser.add_subparsers(dest="cmd", required=True)
|
||||
for name in ("like", "dislike", "forget"):
|
||||
p = sub.add_parser(name)
|
||||
p.add_argument("area", choices=AREAS)
|
||||
p.add_argument("thing")
|
||||
p = sub.add_parser("done")
|
||||
p.add_argument("area", choices=AREAS)
|
||||
p.add_argument("thing")
|
||||
p.add_argument("--at")
|
||||
p = sub.add_parser("show")
|
||||
p.add_argument("--now")
|
||||
p.add_argument("--json", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
path = Path(args.profile)
|
||||
data = load(path)
|
||||
if args.cmd == "show":
|
||||
rows = summary(data, moment(args.now))
|
||||
if args.json:
|
||||
print(json.dumps(rows, indent=1, ensure_ascii=False))
|
||||
return 0
|
||||
for row in rows:
|
||||
last = f"{row['last']} {row['hours_ago']}h ago" if row["last"] else "-"
|
||||
print(
|
||||
f"{row['area']}\tlast: {last}\tlikes: {', '.join(row['likes']) or '-'}"
|
||||
f"\tdislikes: {', '.join(row['dislikes']) or '-'}"
|
||||
)
|
||||
return 0
|
||||
if args.cmd == "done":
|
||||
data["log"].append(
|
||||
{"area": args.area, "thing": args.thing, "at": moment(args.at).isoformat()}
|
||||
)
|
||||
data["log"] = data["log"][-LOG_LIMIT:]
|
||||
else:
|
||||
keep = {"like": "likes", "dislike": "dislikes"}.get(args.cmd, "")
|
||||
prefer(data, keep, args.area, args.thing)
|
||||
save(path, data)
|
||||
print(f"{args.cmd} {args.area} {args.thing}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,10 +1,9 @@
|
||||
---
|
||||
name: kvb-git-branch-gc
|
||||
description: >
|
||||
Remove merged branches and worktrees with `pkgmgr branch gc`: dry run,
|
||||
operator picks from the plan, then apply; unmerged items only one by one.
|
||||
Trigger on /kvb-git-branch-gc, "branches aufräumen", "worktrees aufräumen",
|
||||
"garbage collect".
|
||||
Remove merged branches and worktrees with `pkgmgr branch gc` after a dry
|
||||
run the operator picks from. Trigger on /kvb-git-branch-gc, "branches
|
||||
aufräumen", "worktrees aufräumen".
|
||||
---
|
||||
|
||||
`pkgmgr branch gc` decides what is merged and does the removing; this skill
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
---
|
||||
name: kvb-org-matrix
|
||||
description: >
|
||||
Print one matrix of everything in flight: tasks, workflows, background jobs,
|
||||
with confidence and break risk per item. Trigger on /kvb-org-matrix,
|
||||
"status", "übersicht", "wo stehen wir", or what is done, left or running.
|
||||
One matrix of everything in flight with confidence and break risk per
|
||||
item. Trigger on /kvb-org-matrix, "status", "übersicht", "wo stehen wir".
|
||||
---
|
||||
|
||||
One-shot overview, no side effects: this skill reads state and reports it. It
|
||||
|
||||
@@ -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