horo-teamkit 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. horo_teamkit-0.2.0/LICENSE +21 -0
  2. horo_teamkit-0.2.0/PKG-INFO +122 -0
  3. horo_teamkit-0.2.0/README.md +102 -0
  4. horo_teamkit-0.2.0/pyproject.toml +42 -0
  5. horo_teamkit-0.2.0/setup.cfg +4 -0
  6. horo_teamkit-0.2.0/src/hermes_teamkit/__init__.py +37 -0
  7. horo_teamkit-0.2.0/src/hermes_teamkit/audit.py +58 -0
  8. horo_teamkit-0.2.0/src/hermes_teamkit/board.py +210 -0
  9. horo_teamkit-0.2.0/src/hermes_teamkit/checkpoint.py +110 -0
  10. horo_teamkit-0.2.0/src/hermes_teamkit/cli.py +225 -0
  11. horo_teamkit-0.2.0/src/hermes_teamkit/config.py +95 -0
  12. horo_teamkit-0.2.0/src/hermes_teamkit/gate.py +113 -0
  13. horo_teamkit-0.2.0/src/hermes_teamkit/hooks.py +121 -0
  14. horo_teamkit-0.2.0/src/hermes_teamkit/review.py +598 -0
  15. horo_teamkit-0.2.0/src/hermes_teamkit/setup.py +418 -0
  16. horo_teamkit-0.2.0/src/hermes_teamkit/skills/LICENSE-superpowers +21 -0
  17. horo_teamkit-0.2.0/src/hermes_teamkit/skills/card-plans/SKILL.md +37 -0
  18. horo_teamkit-0.2.0/src/hermes_teamkit/skills/card-writing/SKILL.md +22 -0
  19. horo_teamkit-0.2.0/src/hermes_teamkit/skills/owner-ops/SKILL.md +25 -0
  20. horo_teamkit-0.2.0/src/hermes_teamkit/skills/research-gates/SKILL.md +27 -0
  21. horo_teamkit-0.2.0/src/hermes_teamkit/skills/verify-before-done/SKILL.md +35 -0
  22. horo_teamkit-0.2.0/src/hermes_teamkit/templates/custom.md +1 -0
  23. horo_teamkit-0.2.0/src/hermes_teamkit/templates/dev/architect.md +1 -0
  24. horo_teamkit-0.2.0/src/hermes_teamkit/templates/dev/developer.md +1 -0
  25. horo_teamkit-0.2.0/src/hermes_teamkit/templates/dev/ops.md +1 -0
  26. horo_teamkit-0.2.0/src/hermes_teamkit/templates/dev/qa.md +4 -0
  27. horo_teamkit-0.2.0/src/hermes_teamkit/templates/dev/reviewer.md +4 -0
  28. horo_teamkit-0.2.0/src/hermes_teamkit/templates/owner.md +29 -0
  29. horo_teamkit-0.2.0/src/hermes_teamkit/templates/research/analyst.md +1 -0
  30. horo_teamkit-0.2.0/src/hermes_teamkit/templates/research/critic.md +1 -0
  31. horo_teamkit-0.2.0/src/hermes_teamkit/templates/research/engineer.md +1 -0
  32. horo_teamkit-0.2.0/src/hermes_teamkit/templates/research/explorer.md +1 -0
  33. horo_teamkit-0.2.0/src/hermes_teamkit/templates/research/pi-extra.md +8 -0
  34. horo_teamkit-0.2.0/src/hermes_teamkit/templates/research/replicator.md +1 -0
  35. horo_teamkit-0.2.0/src/hermes_teamkit/templates/shared.md +24 -0
  36. horo_teamkit-0.2.0/src/hermes_teamkit/templates/trio/coder.md +1 -0
  37. horo_teamkit-0.2.0/src/hermes_teamkit/templates/trio/verifier.md +4 -0
  38. horo_teamkit-0.2.0/src/hermes_teamkit/tools.py +324 -0
  39. horo_teamkit-0.2.0/src/hermes_teamkit/web/index.html +162 -0
  40. horo_teamkit-0.2.0/src/hermes_teamkit/web.py +246 -0
  41. horo_teamkit-0.2.0/src/horo_teamkit.egg-info/PKG-INFO +122 -0
  42. horo_teamkit-0.2.0/src/horo_teamkit.egg-info/SOURCES.txt +51 -0
  43. horo_teamkit-0.2.0/src/horo_teamkit.egg-info/dependency_links.txt +1 -0
  44. horo_teamkit-0.2.0/src/horo_teamkit.egg-info/entry_points.txt +2 -0
  45. horo_teamkit-0.2.0/src/horo_teamkit.egg-info/top_level.txt +1 -0
  46. horo_teamkit-0.2.0/tests/test_audit.py +41 -0
  47. horo_teamkit-0.2.0/tests/test_board.py +84 -0
  48. horo_teamkit-0.2.0/tests/test_checkpoint.py +68 -0
  49. horo_teamkit-0.2.0/tests/test_gate.py +68 -0
  50. horo_teamkit-0.2.0/tests/test_hooks.py +46 -0
  51. horo_teamkit-0.2.0/tests/test_review.py +158 -0
  52. horo_teamkit-0.2.0/tests/test_setup.py +184 -0
  53. horo_teamkit-0.2.0/tests/test_tools.py +61 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 istale
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: horo-teamkit
3
+ Version: 0.2.0
4
+ Summary: Run a team of Hermes profiles on one kanban board, with a harness-run completion gate, anti-silencing, strategy checkpoints and audit.
5
+ Author: istale
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/iscodesnippet2/horo-teamkit
8
+ Keywords: hermes,agents,kanban,multi-agent,quality-gate
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Dynamic: license-file
20
+
21
+ # horo-teamkit
22
+
23
+ [繁體中文](README.zh-TW.md)
24
+
25
+ Run a team of [horo-next](https://pypi.org/project/horo-next/) (Hermes) profiles on one kanban board — and make the harness, not the model, decide when work is done.
26
+
27
+ > Agents may explain a failure. They may not explain it away.
28
+ > The system must notice when the current approach has stopped working.
29
+
30
+ horo-teamkit is a horo-next plugin (horo-next 0.23.x only). It sets up roles, routes reviews, escalates stuck work to an owner, and adds deterministic controls that a model cannot talk its way past:
31
+
32
+ - **Completion gate** — `kanban_request_review` and `kanban_complete` run your checks (lint, types, tests) in the card's workspace first. A failing check blocks the call and hands back the output plus a failure fingerprint.
33
+ - **Anti-silencing** — relative to a recorded base commit, new `# noqa` / `type: ignore` / `pytest.mark.skip` markers, edits to check config files, or fewer test functions are blocked unless the owner waives that card.
34
+ - **Strategy checkpoint** — when the same command failure (same fingerprint) repeats 3 times on one card or session, the agent is told to change hypothesis or stop and report, and the owner gets a card. At 6, `terminal` is paused for that card until it is blocked or the owner decides. Works in kanban workers and in `hermes -z` oneshot sessions.
35
+ - **`teamkit audit`** — a read-only replay: did every done card pass the gate before completion, has the check list changed since, does it still pass now?
36
+
37
+ What it does **not** do, and what we could and could not measure, is in [BENCHMARK.md](BENCHMARK.md). Short version: on our local-model benchmark the baseline team did not make the mistakes these controls target, so we have no before/after evidence that teamkit improves outcomes — only tests showing the controls fire.
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ pip install horo-teamkit # same environment as horo-next; no dependencies, does not touch horo-next
43
+ hermes plugins enable teamkit # enable in the default home so `hermes teamkit` appears
44
+ hermes teamkit init --board dev --preset trio --prefix dev- --workdir ~/proj \
45
+ --check "ruff check ." --check "python3 -m pytest -q" # prints the plan
46
+ hermes teamkit init ... --yes # applies it
47
+ ```
48
+
49
+ - Do not install with `pip install -e` or from `~/Documents`, `~/Desktop`, `~/Downloads` on macOS: a launchd gateway cannot read those folders and the plugin silently fails to load (`No module named 'hermes_teamkit'` in the log).
50
+ - **Restart the gateway after installing or upgrading.** Workers — and `hermes -z` sessions, which run inside the gateway — keep the plugin version the gateway loaded at startup.
51
+
52
+ `init` only prints a plan unless you pass `--yes`. It creates the board, one profile per role with a SOUL.md (existing SOULs are kept unless `--force-soul`), sets each profile's `agent.max_turns=250`, `approvals.single_query_mode=deny`, memory on, teamkit enabled, enables teamkit in the default home (skip with `--no-default-home`), and writes the board's `teamkit.yaml`. Every overwritten file is backed up as `*.bak-teamkit-<time>`. Re-running `init` only fills in what is missing.
53
+
54
+ Then:
55
+
56
+ 1. Give each profile its own `model`, `fallback_providers` and `.env` (profiles do not read the default home's `.env`).
57
+ 2. `hermes teamkit doctor --board dev` and fix every FAIL.
58
+ 3. Run `hermes teamkit tick --board dev` periodically (e.g. cron every 5 minutes); idle wake-ups and crash escalation depend on it.
59
+ 4. Restart the gateway.
60
+
61
+ ## Presets
62
+
63
+ | preset | owner | reviewer | other roles |
64
+ |---|---|---|---|
65
+ | `dev` | orchestrator | reviewer | architect, developer, qa, ops |
66
+ | `research` | pi | critic | analyst, engineer, explorer, replicator |
67
+ | `trio` | planner | verifier | coder |
68
+
69
+ Add roles with `hermes teamkit add-role --board dev --name dev-coder-b --like coder --yes` (`--creator` lets the role open cards; there is exactly one owner per board).
70
+
71
+ ## Enforced rules
72
+
73
+ Only in processes where teamkit is enabled.
74
+
75
+ | Rule | How |
76
+ |---|---|
77
+ | Reviews go to the reviewer | `kanban_request_review` without a reviewer gets `teamkit.yaml`'s reviewer |
78
+ | Only the owner and `card_creators` open cards | others' `kanban_create` is blocked; they propose cards in `metadata.proposed_cards` |
79
+ | Cards use the template | with `require_template: true`, `kanban_create` is blocked in favour of `teamkit_open_card` |
80
+ | No direct commits to protected branches | `git commit` in a `terminal` command on a branch in `protected_branches` is blocked |
81
+ | Blocked cards escalate to the owner | `kanban_task_blocked` opens (or comments on) an owner card |
82
+ | Crashed workers escalate | `tick` opens an owner card for cards stopped after crashed / gave_up / timed_out |
83
+ | Idle boards wake the owner | `tick` opens one owner card per idle period longer than `idle_seconds` |
84
+ | Completion passes the gate | with `checks` set, review and complete run them first |
85
+ | Checks cannot be loosened | with `gate_base` set, silencing markers, check-config edits and test removal are blocked; owner waives via `gate_waivers` |
86
+ | The same failure is not retried forever | `checkpoint_repeats` (default 3): notice + owner card; at twice that, `terminal` pauses |
87
+
88
+ ## Gate and audit
89
+
90
+ ```bash
91
+ hermes teamkit init --board dev --check "ruff check ." --check "python3 -m pytest -q" --workdir ~/proj --yes
92
+ hermes teamkit audit --board dev # exit 1 if anything is off; --no-rerun to only read records
93
+ ```
94
+
95
+ - Checks run in order (put fast ones first) via the shell in `HERMES_KANBAN_WORKSPACE` — only list commands you trust. With a git `--workdir`, the current HEAD is recorded as `gate_base`.
96
+ - Every decision is appended to the board's `teamkit-events.jsonl` (`gate_pass`, `gate_fail`, `gate_silenced`, `command_fail`, `checkpoint`).
97
+ - The gate guarantees evidence exists, not that it is sufficient: code that passes its own tests but breaks the spec still passes. That still needs a reviewer reading the spec.
98
+
99
+ ## Tools, UI, review
100
+
101
+ - `teamkit_open_card` (five-section cards), `teamkit_ledger_add` / `teamkit_ledger_query` (research ledger with sha256-pinned evidence; the replicator may not be the author), `teamkit_status`.
102
+ - `hermes teamkit ui --board dev` serves a local dashboard (team overview, SOUL editor, 360° review). `hermes teamkit review start|show|apply` runs a review cycle where every comment must cite a card, objective numbers flag inconsistencies, and SOUL edits are proposed line by line, never applied automatically.
103
+
104
+ ## Skills
105
+
106
+ Read with `skill_view("teamkit:<name>")`: `card-writing`, `owner-ops`, `research-gates`. Optional, off by default, adapted from [obra/superpowers](https://github.com/obra/superpowers) (MIT): `verify-before-done` and `card-plans` — `hermes teamkit superpowers on --board dev --yes`.
107
+
108
+ ## Limits
109
+
110
+ - Rules apply only inside processes with teamkit enabled; humans and other profiles are not constrained. `doctor` lists profiles without it.
111
+ - Commit detection only sees `git commit` in `terminal` commands.
112
+ - The strategy checkpoint fingerprints the last lines of a failing command with digits masked. A different command hitting the same wall counts separately, and a different bad idea that fails differently is not caught.
113
+ - A Hermes bug can leave a card stuck in review after rate limiting; `status` lists such cards, fix with `reassign <id> none` then `reassign <id> <reviewer>`.
114
+
115
+ ## Development
116
+
117
+ ```bash
118
+ pip install -e . pytest # outside the macOS-protected folders above if a gateway must load it
119
+ python -m pytest
120
+ ```
121
+
122
+ Benchmark kit and protocol: [`benchmark/`](benchmark/). Release process and trust model: [SECURITY.md](SECURITY.md) and [README.zh-TW.md](README.zh-TW.md#發佈).
@@ -0,0 +1,102 @@
1
+ # horo-teamkit
2
+
3
+ [繁體中文](README.zh-TW.md)
4
+
5
+ Run a team of [horo-next](https://pypi.org/project/horo-next/) (Hermes) profiles on one kanban board — and make the harness, not the model, decide when work is done.
6
+
7
+ > Agents may explain a failure. They may not explain it away.
8
+ > The system must notice when the current approach has stopped working.
9
+
10
+ horo-teamkit is a horo-next plugin (horo-next 0.23.x only). It sets up roles, routes reviews, escalates stuck work to an owner, and adds deterministic controls that a model cannot talk its way past:
11
+
12
+ - **Completion gate** — `kanban_request_review` and `kanban_complete` run your checks (lint, types, tests) in the card's workspace first. A failing check blocks the call and hands back the output plus a failure fingerprint.
13
+ - **Anti-silencing** — relative to a recorded base commit, new `# noqa` / `type: ignore` / `pytest.mark.skip` markers, edits to check config files, or fewer test functions are blocked unless the owner waives that card.
14
+ - **Strategy checkpoint** — when the same command failure (same fingerprint) repeats 3 times on one card or session, the agent is told to change hypothesis or stop and report, and the owner gets a card. At 6, `terminal` is paused for that card until it is blocked or the owner decides. Works in kanban workers and in `hermes -z` oneshot sessions.
15
+ - **`teamkit audit`** — a read-only replay: did every done card pass the gate before completion, has the check list changed since, does it still pass now?
16
+
17
+ What it does **not** do, and what we could and could not measure, is in [BENCHMARK.md](BENCHMARK.md). Short version: on our local-model benchmark the baseline team did not make the mistakes these controls target, so we have no before/after evidence that teamkit improves outcomes — only tests showing the controls fire.
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ pip install horo-teamkit # same environment as horo-next; no dependencies, does not touch horo-next
23
+ hermes plugins enable teamkit # enable in the default home so `hermes teamkit` appears
24
+ hermes teamkit init --board dev --preset trio --prefix dev- --workdir ~/proj \
25
+ --check "ruff check ." --check "python3 -m pytest -q" # prints the plan
26
+ hermes teamkit init ... --yes # applies it
27
+ ```
28
+
29
+ - Do not install with `pip install -e` or from `~/Documents`, `~/Desktop`, `~/Downloads` on macOS: a launchd gateway cannot read those folders and the plugin silently fails to load (`No module named 'hermes_teamkit'` in the log).
30
+ - **Restart the gateway after installing or upgrading.** Workers — and `hermes -z` sessions, which run inside the gateway — keep the plugin version the gateway loaded at startup.
31
+
32
+ `init` only prints a plan unless you pass `--yes`. It creates the board, one profile per role with a SOUL.md (existing SOULs are kept unless `--force-soul`), sets each profile's `agent.max_turns=250`, `approvals.single_query_mode=deny`, memory on, teamkit enabled, enables teamkit in the default home (skip with `--no-default-home`), and writes the board's `teamkit.yaml`. Every overwritten file is backed up as `*.bak-teamkit-<time>`. Re-running `init` only fills in what is missing.
33
+
34
+ Then:
35
+
36
+ 1. Give each profile its own `model`, `fallback_providers` and `.env` (profiles do not read the default home's `.env`).
37
+ 2. `hermes teamkit doctor --board dev` and fix every FAIL.
38
+ 3. Run `hermes teamkit tick --board dev` periodically (e.g. cron every 5 minutes); idle wake-ups and crash escalation depend on it.
39
+ 4. Restart the gateway.
40
+
41
+ ## Presets
42
+
43
+ | preset | owner | reviewer | other roles |
44
+ |---|---|---|---|
45
+ | `dev` | orchestrator | reviewer | architect, developer, qa, ops |
46
+ | `research` | pi | critic | analyst, engineer, explorer, replicator |
47
+ | `trio` | planner | verifier | coder |
48
+
49
+ Add roles with `hermes teamkit add-role --board dev --name dev-coder-b --like coder --yes` (`--creator` lets the role open cards; there is exactly one owner per board).
50
+
51
+ ## Enforced rules
52
+
53
+ Only in processes where teamkit is enabled.
54
+
55
+ | Rule | How |
56
+ |---|---|
57
+ | Reviews go to the reviewer | `kanban_request_review` without a reviewer gets `teamkit.yaml`'s reviewer |
58
+ | Only the owner and `card_creators` open cards | others' `kanban_create` is blocked; they propose cards in `metadata.proposed_cards` |
59
+ | Cards use the template | with `require_template: true`, `kanban_create` is blocked in favour of `teamkit_open_card` |
60
+ | No direct commits to protected branches | `git commit` in a `terminal` command on a branch in `protected_branches` is blocked |
61
+ | Blocked cards escalate to the owner | `kanban_task_blocked` opens (or comments on) an owner card |
62
+ | Crashed workers escalate | `tick` opens an owner card for cards stopped after crashed / gave_up / timed_out |
63
+ | Idle boards wake the owner | `tick` opens one owner card per idle period longer than `idle_seconds` |
64
+ | Completion passes the gate | with `checks` set, review and complete run them first |
65
+ | Checks cannot be loosened | with `gate_base` set, silencing markers, check-config edits and test removal are blocked; owner waives via `gate_waivers` |
66
+ | The same failure is not retried forever | `checkpoint_repeats` (default 3): notice + owner card; at twice that, `terminal` pauses |
67
+
68
+ ## Gate and audit
69
+
70
+ ```bash
71
+ hermes teamkit init --board dev --check "ruff check ." --check "python3 -m pytest -q" --workdir ~/proj --yes
72
+ hermes teamkit audit --board dev # exit 1 if anything is off; --no-rerun to only read records
73
+ ```
74
+
75
+ - Checks run in order (put fast ones first) via the shell in `HERMES_KANBAN_WORKSPACE` — only list commands you trust. With a git `--workdir`, the current HEAD is recorded as `gate_base`.
76
+ - Every decision is appended to the board's `teamkit-events.jsonl` (`gate_pass`, `gate_fail`, `gate_silenced`, `command_fail`, `checkpoint`).
77
+ - The gate guarantees evidence exists, not that it is sufficient: code that passes its own tests but breaks the spec still passes. That still needs a reviewer reading the spec.
78
+
79
+ ## Tools, UI, review
80
+
81
+ - `teamkit_open_card` (five-section cards), `teamkit_ledger_add` / `teamkit_ledger_query` (research ledger with sha256-pinned evidence; the replicator may not be the author), `teamkit_status`.
82
+ - `hermes teamkit ui --board dev` serves a local dashboard (team overview, SOUL editor, 360° review). `hermes teamkit review start|show|apply` runs a review cycle where every comment must cite a card, objective numbers flag inconsistencies, and SOUL edits are proposed line by line, never applied automatically.
83
+
84
+ ## Skills
85
+
86
+ Read with `skill_view("teamkit:<name>")`: `card-writing`, `owner-ops`, `research-gates`. Optional, off by default, adapted from [obra/superpowers](https://github.com/obra/superpowers) (MIT): `verify-before-done` and `card-plans` — `hermes teamkit superpowers on --board dev --yes`.
87
+
88
+ ## Limits
89
+
90
+ - Rules apply only inside processes with teamkit enabled; humans and other profiles are not constrained. `doctor` lists profiles without it.
91
+ - Commit detection only sees `git commit` in `terminal` commands.
92
+ - The strategy checkpoint fingerprints the last lines of a failing command with digits masked. A different command hitting the same wall counts separately, and a different bad idea that fails differently is not caught.
93
+ - A Hermes bug can leave a card stuck in review after rate limiting; `status` lists such cards, fix with `reassign <id> none` then `reassign <id> <reviewer>`.
94
+
95
+ ## Development
96
+
97
+ ```bash
98
+ pip install -e . pytest # outside the macOS-protected folders above if a gateway must load it
99
+ python -m pytest
100
+ ```
101
+
102
+ Benchmark kit and protocol: [`benchmark/`](benchmark/). Release process and trust model: [SECURITY.md](SECURITY.md) and [README.zh-TW.md](README.zh-TW.md#發佈).
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "horo-teamkit"
7
+ version = "0.2.0"
8
+ description = "Run a team of Hermes profiles on one kanban board, with a harness-run completion gate, anti-silencing, strategy checkpoints and audit."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "istale" }]
14
+ keywords = ["hermes", "agents", "kanban", "multi-agent", "quality-gate"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Operating System :: MacOS",
22
+ "Operating System :: POSIX :: Linux",
23
+ ]
24
+ # A plugin: it runs inside an existing horo-next install and brings nothing of
25
+ # its own. horo-next (and the ruamel.yaml it ships) comes from the host; the
26
+ # supported series is checked at load time and by `teamkit doctor`.
27
+ dependencies = []
28
+
29
+ [project.urls]
30
+ Repository = "https://github.com/iscodesnippet2/horo-teamkit"
31
+
32
+ [project.entry-points."hermes_agent.plugins"]
33
+ teamkit = "hermes_teamkit"
34
+
35
+ [tool.setuptools.packages.find]
36
+ where = ["src"]
37
+
38
+ [tool.setuptools.package-data]
39
+ hermes_teamkit = ["templates/*/*.md", "templates/*.md", "skills/*/SKILL.md", "skills/LICENSE-*", "web/*.html"]
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ from importlib import resources
5
+ from pathlib import Path
6
+
7
+ from . import checkpoint, cli, config, hooks, setup, tools
8
+
9
+ __version__ = "0.2.0"
10
+
11
+ TOOLSET = "teamkit"
12
+ SKILLS = ("card-writing", "owner-ops", "research-gates")
13
+
14
+
15
+ def superpowers_on() -> bool:
16
+ try:
17
+ from hermes_cli.kanban_db import get_current_board
18
+
19
+ cfg = config.load(get_current_board())
20
+ return bool(cfg and cfg.get("superpowers") and config.current_profile() in cfg["roles"])
21
+ except Exception:
22
+ return False
23
+
24
+
25
+ def register(ctx) -> None:
26
+ problem = setup.host_problem()
27
+ if problem:
28
+ logging.getLogger(__name__).warning("teamkit: %s", problem)
29
+ for name, schema in tools.SCHEMAS.items():
30
+ ctx.register_tool(name=name, toolset=TOOLSET, schema=schema, handler=tools.HANDLERS[name])
31
+ ctx.register_hook("pre_tool_call", hooks.pre_tool_call)
32
+ ctx.register_hook("transform_tool_result", checkpoint.on_command_result)
33
+ ctx.register_hook("kanban_task_blocked", hooks.on_task_blocked)
34
+ ctx.register_cli_command("teamkit", "多 profile 看板團隊工具", cli.setup_parser, cli.handle)
35
+ root = Path(str(resources.files("hermes_teamkit").joinpath("skills")))
36
+ for skill in SKILLS + (setup.SUPERPOWERS_SKILLS if superpowers_on() else ()):
37
+ ctx.register_skill(skill, root / skill / "SKILL.md")
@@ -0,0 +1,58 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from contextlib import closing
5
+ from typing import Any
6
+
7
+ from . import board as board_ops
8
+ from . import config, gate, review
9
+
10
+
11
+ def audit(board: str, rerun: bool = True) -> dict[str, Any]:
12
+ cfg = config.load(board)
13
+ if cfg is None:
14
+ raise ValueError(f"看板 {board} 沒有 teamkit.yaml")
15
+ checks = list(cfg.get("checks") or [])
16
+ events = review.read_events(board)
17
+ passes: dict[str, list[dict[str, Any]]] = {}
18
+ for e in events:
19
+ if e.get("type") == "gate_pass" and e.get("task"):
20
+ passes.setdefault(e["task"], []).append(e)
21
+ with closing(board_ops.connect(board)) as conn:
22
+ rows = conn.execute(
23
+ "SELECT id, title, assignee, completed_at, workspace_path FROM tasks "
24
+ "WHERE status = 'done' AND (created_by IS NULL OR created_by != ?) ORDER BY completed_at",
25
+ (config.CREATED_BY,),
26
+ ).fetchall()
27
+ cards, findings = [], []
28
+ for task_id, title, assignee, completed_at, path in rows:
29
+ before = [e for e in passes.get(task_id, []) if not completed_at or e["at"] <= completed_at + 5]
30
+ card: dict[str, Any] = {"id": task_id, "title": title, "assignee": assignee, "gate_passed": bool(before)}
31
+ if checks and not before:
32
+ findings.append(f"{task_id} 完成前沒有通過閘門的紀錄({title})")
33
+ recorded = before[-1].get("checks") if before else None
34
+ if recorded is not None and recorded != checks:
35
+ findings.append(f"{task_id} 通過閘門時的檢查清單和現在不同:{recorded} → {checks}")
36
+ if rerun and checks and path and os.path.isdir(path):
37
+ failure = gate.run_checks(path, checks, int(cfg.get("gate_timeout") or 600))
38
+ card["rerun"] = "pass" if failure is None else f"fail: {failure['check']}"
39
+ if failure:
40
+ findings.append(f"{task_id} 現在重跑 `{failure['check']}` 沒通過(指紋 {failure['fingerprint']})")
41
+ cards.append(card)
42
+ waived = list(cfg.get("gate_waivers") or [])
43
+ return {"board": board, "checks": checks, "waivers": waived, "cards": cards, "findings": findings,
44
+ "blocked": sum(1 for e in events if e.get("type") in ("gate_fail", "gate_silenced"))}
45
+
46
+
47
+ def render(data: dict[str, Any]) -> str:
48
+ lines = [f"看板 {data['board']}:檢查 {data['checks'] or '(未設定)'},完成卡 {len(data['cards'])} 張,"
49
+ f"閘門擋下 {data['blocked']} 次"]
50
+ if data["waivers"]:
51
+ lines.append(f"例外卡:{', '.join(data['waivers'])}")
52
+ lines += [f"- {f}" for f in data["findings"]] or ["沒有發現問題。"]
53
+ return "\n".join(lines)
54
+
55
+
56
+ def exit_code(data: dict[str, Any]) -> int:
57
+ return 1 if data["findings"] else 0
58
+
@@ -0,0 +1,210 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import time
5
+ from contextlib import closing
6
+ from typing import Any, Optional
7
+
8
+ from . import config
9
+
10
+ ACTIVE = ("ready", "running", "review")
11
+ WAITING = ("triage", "todo", "scheduled", "blocked")
12
+ CLOSED = ("done", "archived")
13
+
14
+
15
+ def connect(board: str):
16
+ from hermes_cli.kanban_db_connect import connect as kb_connect
17
+
18
+ return kb_connect(board=board)
19
+
20
+
21
+ def _owner_card(conn, board: str, cfg: dict[str, Any], *, title: str, body: str, key: str) -> Optional[str]:
22
+ from hermes_cli.kanban_db import create_task
23
+
24
+ return create_task(
25
+ conn,
26
+ title=title[:200],
27
+ body=body,
28
+ assignee=cfg["owner"],
29
+ created_by=config.CREATED_BY,
30
+ idempotency_key=key,
31
+ max_runtime_seconds=cfg["max_runtime_seconds"],
32
+ board=board,
33
+ )
34
+
35
+
36
+ def escalate_block(board: str, task_id: str, run_id: Optional[int], reason: Optional[str],
37
+ cfg: dict[str, Any]) -> Optional[str]:
38
+ from hermes_cli.kanban_db import get_task
39
+
40
+ if not cfg.get("owner"):
41
+ return None
42
+ with closing(connect(board)) as conn:
43
+ task = get_task(conn, task_id)
44
+ if task is None or task.created_by == config.CREATED_BY or task.assignee == cfg["owner"]:
45
+ return None
46
+ kind = getattr(task, "block_kind", None) or "untyped"
47
+ open_card = conn.execute(
48
+ "SELECT id FROM tasks WHERE created_by=? AND idempotency_key LIKE ? "
49
+ "AND status NOT IN ('done','archived') LIMIT 1",
50
+ (config.CREATED_BY, f"teamkit-block:{task_id}:%"),
51
+ ).fetchone()
52
+ if open_card:
53
+ from hermes_cli.kanban_db import add_comment
54
+
55
+ add_comment(conn, open_card[0], config.CREATED_BY,
56
+ f"{task_id} 又被擋住(run {run_id},kind {kind}):{reason or '(未提供)'}")
57
+ return open_card[0]
58
+ body = "\n".join([
59
+ f"## 目的\n處理被擋住的卡 {task_id}({task.title})。",
60
+ "## 已知事實",
61
+ f"- assignee: {task.assignee}",
62
+ f"- block kind: {kind}",
63
+ f"- run: {run_id}",
64
+ f"- 原因: {reason or '(未提供)'}",
65
+ "## 做法\n依 block kind 處理:transient 重派一次;dependency 補 parent;"
66
+ "capability 換人或拆掉做不到的部分;needs_input 有授權就決定並寫明,沒有就升級給指示者。",
67
+ f"## 完成條件\n{task_id} 已重新可推進,或已升級並說明需要的決定。",
68
+ "## 回報\n留言在原卡與頂層卡。",
69
+ ])
70
+ return _owner_card(conn, board, cfg, title=f"Owner: {task_id} blocked ({kind}) — {task.title}",
71
+ body=body, key=f"teamkit-block:{task_id}:{run_id or 0}")
72
+
73
+
74
+ def _counts(conn) -> dict[str, int]:
75
+ rows = conn.execute("SELECT status, COUNT(*) FROM tasks GROUP BY status").fetchall()
76
+ return {row[0]: row[1] for row in rows}
77
+
78
+
79
+ FAILED = ("crashed", "gave_up", "timed_out")
80
+
81
+
82
+ def _failed(conn, owner: str) -> list[tuple]:
83
+ rows = conn.execute(
84
+ "SELECT t.id, r.id, r.outcome, t.last_failure_error FROM tasks t "
85
+ "JOIN task_runs r ON r.id = (SELECT MAX(id) FROM task_runs WHERE task_id=t.id) "
86
+ "WHERE t.status='blocked' AND (t.created_by IS NULL OR t.created_by != ?) AND t.assignee != ? "
87
+ f"AND r.outcome IN ({','.join('?' * len(FAILED))})",
88
+ (config.CREATED_BY, owner, *FAILED),
89
+ ).fetchall()
90
+ return [r for r in rows if not conn.execute(
91
+ "SELECT 1 FROM tasks WHERE created_by=? AND (idempotency_key=? OR "
92
+ "(idempotency_key LIKE ? AND status NOT IN ('done','archived'))) LIMIT 1",
93
+ (config.CREATED_BY, f"teamkit-block:{r[0]}:{r[1]}", f"teamkit-block:{r[0]}:%"),
94
+ ).fetchone()]
95
+
96
+
97
+ def tick(board: str, cfg: dict[str, Any], now: Optional[float] = None) -> dict[str, Any]:
98
+ now = time.time() if now is None else now
99
+ result: dict[str, Any] = {"board": board, "action": "none"}
100
+ record_tick(board, now)
101
+ if not cfg.get("owner"):
102
+ result["reason"] = "no owner configured"
103
+ return result
104
+ with closing(connect(board)) as conn:
105
+ failed = _failed(conn, cfg["owner"])
106
+ if failed:
107
+ cards = [escalate_block(board, task_id, run_id,
108
+ f"worker {outcome} 後被 dispatcher 擋下;先看 `hermes kanban log {task_id}` 與該 "
109
+ f"profile 的 logs/managed-worker.log。最後錯誤:{(error or '(無)')[:300]}", cfg)
110
+ for task_id, run_id, outcome, error in failed]
111
+ result.update(action="owner_card", task_ids=[c for c in cards if c])
112
+ return result
113
+ with closing(connect(board)) as conn:
114
+ counts = _counts(conn)
115
+ result["counts"] = counts
116
+ if any(counts.get(s, 0) for s in ACTIVE):
117
+ result["reason"] = "board active"
118
+ return result
119
+ if not any(counts.get(s, 0) for s in WAITING):
120
+ result["reason"] = "nothing waiting"
121
+ return result
122
+ open_owner = conn.execute(
123
+ "SELECT id FROM tasks WHERE assignee=? AND created_by=? AND status NOT IN ('done','archived') LIMIT 1",
124
+ (cfg["owner"], config.CREATED_BY),
125
+ ).fetchone()
126
+ if open_owner:
127
+ result["reason"] = f"owner card {open_owner[0]} still open"
128
+ return result
129
+ last = conn.execute(
130
+ "SELECT e.id, e.created_at FROM task_events e JOIN tasks t ON t.id=e.task_id "
131
+ "WHERE t.created_by IS NOT ? ORDER BY e.id DESC LIMIT 1",
132
+ (config.CREATED_BY,),
133
+ ).fetchone()
134
+ if last is None:
135
+ result["reason"] = "no activity yet"
136
+ return result
137
+ key = f"teamkit-idle:{board}:{last[0]}"
138
+ notified = conn.execute("SELECT id FROM tasks WHERE idempotency_key=? LIMIT 1", (key,)).fetchone()
139
+ if notified:
140
+ result["reason"] = f"this idle period already handled by {notified[0]}"
141
+ return result
142
+ idle_for = now - float(last[1])
143
+ if idle_for < cfg["idle_seconds"]:
144
+ result["reason"] = f"idle {int(idle_for)}s < {cfg['idle_seconds']}s"
145
+ return result
146
+ waiting = ", ".join(f"{s}={counts[s]}" for s in WAITING if counts.get(s))
147
+ body = "\n".join([
148
+ "## 目的\n看板閒置,檢查有沒有該推進的工作。",
149
+ f"## 已知事實\n- 閒置 {int(idle_for)} 秒\n- 等待中: {waiting or '無'}",
150
+ "## 做法\n先補審查通過但還沒驗收的變更與逾時卡的交接,再推進開著的目標卡;沒有目標卡就完成本卡。",
151
+ "## 完成條件\n每張等待中的卡都有下一步,或已寫明為何等待。",
152
+ "## 回報\n完成摘要列出推進了哪些卡。",
153
+ ])
154
+ task_id = _owner_card(conn, board, cfg, title=f"Owner: board {board} is idle", body=body,
155
+ key=key)
156
+ result.update(action="owner_card", task_id=task_id)
157
+ return result
158
+
159
+
160
+ def tick_record_path(board: str):
161
+ return config.board_path(board) / "teamkit-tick.json"
162
+
163
+
164
+ def record_tick(board: str, now: float) -> None:
165
+ path = tick_record_path(board)
166
+ path.parent.mkdir(parents=True, exist_ok=True)
167
+ path.write_text(json.dumps({"at": now}), encoding="utf-8")
168
+
169
+
170
+ def last_tick(board: str) -> Optional[float]:
171
+ try:
172
+ return float(json.loads(tick_record_path(board).read_text(encoding="utf-8"))["at"])
173
+ except (OSError, ValueError, KeyError, TypeError):
174
+ return None
175
+
176
+
177
+ def status(board: str, cfg: Optional[dict[str, Any]], now: Optional[float] = None) -> dict[str, Any]:
178
+ now = time.time() if now is None else now
179
+ out: dict[str, Any] = {"board": board, "configured": cfg is not None}
180
+ if cfg is not None:
181
+ out.update(owner=cfg.get("owner"), reviewer=cfg.get("reviewer"),
182
+ card_creators=sorted(config.creators(cfg)), roles=list(cfg.get("roles") or []))
183
+ with closing(connect(board)) as conn:
184
+ out["counts"] = _counts(conn)
185
+ out["running"] = [
186
+ {"id": r[0], "assignee": r[1], "minutes": int((now - (r[2] or now)) / 60), "title": r[3]}
187
+ for r in conn.execute(
188
+ "SELECT id, assignee, started_at, title FROM tasks WHERE status='running' ORDER BY started_at")
189
+ ]
190
+ out["blocked"] = [
191
+ {"id": r[0], "assignee": r[1], "kind": r[2], "title": r[3]}
192
+ for r in conn.execute("SELECT id, assignee, block_kind, title FROM tasks WHERE status='blocked'")
193
+ ]
194
+ stale_review = []
195
+ for r in conn.execute("SELECT id, assignee, title FROM tasks WHERE status='review'"):
196
+ ev = conn.execute("SELECT kind, created_at FROM task_events WHERE task_id=? ORDER BY id DESC LIMIT 1",
197
+ (r[0],)).fetchone()
198
+ if ev and now - float(ev[1]) > 1800:
199
+ stale_review.append({"id": r[0], "assignee": r[1], "last_event": ev[0],
200
+ "minutes": int((now - float(ev[1])) / 60), "title": r[2]})
201
+ out["stale_review"] = stale_review
202
+ if cfg is not None:
203
+ allowed = config.creators(cfg) | {config.CREATED_BY, "user", None}
204
+ out["foreign_cards"] = [
205
+ {"id": r[0], "created_by": r[1], "title": r[2]}
206
+ for r in conn.execute("SELECT id, created_by, title FROM tasks WHERE status NOT IN ('done','archived')")
207
+ if r[1] not in allowed
208
+ ]
209
+ out["last_tick"] = last_tick(board)
210
+ return out