diff --git a/README.md b/README.md index bf24b74..918d0c3 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Compatible with Claude Code, Codex, Gemini CLI, Cursor, Copilot, Windsurf, Cline ## Naming 🏷️ -Every first-party skill is named `kvb--` 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--` 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 diff --git a/skills/kvb-coach/SKILL.md b/skills/kvb-coach/SKILL.md new file mode 100644 index 0000000..04c9f8b --- /dev/null +++ b/skills/kvb-coach/SKILL.md @@ -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 /.state/coach.json like|dislike|forget "" +coach.py --profile done "" [--at ] +coach.py --profile 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. diff --git a/skills/kvb-coach/scripts/coach.py b/skills/kvb-coach/scripts/coach.py new file mode 100755 index 0000000..981752c --- /dev/null +++ b/skills/kvb-coach/scripts/coach.py @@ -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 : record a preference; one replaces the other. + forget : drop a preference. + done [--at ]: log that the operator did it. + show [--now ] [--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()) diff --git a/skills/kvb-git-branch-gc/SKILL.md b/skills/kvb-git-branch-gc/SKILL.md index 8ec6cb2..123de4d 100644 --- a/skills/kvb-git-branch-gc/SKILL.md +++ b/skills/kvb-git-branch-gc/SKILL.md @@ -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 diff --git a/skills/kvb-org-matrix/SKILL.md b/skills/kvb-org-matrix/SKILL.md index b512ff9..2f1fd12 100644 --- a/skills/kvb-org-matrix/SKILL.md +++ b/skills/kvb-org-matrix/SKILL.md @@ -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 diff --git a/tests/test_coach.py b/tests/test_coach.py new file mode 100644 index 0000000..a8a7dbe --- /dev/null +++ b/tests/test_coach.py @@ -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() diff --git a/tests/test_naming.py b/tests/test_naming.py index 4741ca0..b501d33 100644 --- a/tests/test_naming.py +++ b/tests/test_naming.py @@ -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]+)*$")