comitia 0.1.0__py3-none-any.whl
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.
- comitia/__init__.py +3 -0
- comitia/__main__.py +3 -0
- comitia/api.py +68 -0
- comitia/catalog.py +82 -0
- comitia/cli.py +950 -0
- comitia/control.py +156 -0
- comitia/diffs.py +120 -0
- comitia/discussion/__init__.py +0 -0
- comitia/discussion/api.py +152 -0
- comitia/discussion/cli.py +1254 -0
- comitia/discussion/config.py +167 -0
- comitia/discussion/console.py +366 -0
- comitia/discussion/converse.py +1221 -0
- comitia/discussion/journal.py +382 -0
- comitia/discussion/panel.py +1647 -0
- comitia/discussion/panel_view.py +445 -0
- comitia/discussion/prompts/converse_asker.md +3 -0
- comitia/discussion/prompts/converse_summary.md +27 -0
- comitia/discussion/transcript.py +88 -0
- comitia/engine.py +1223 -0
- comitia/findings.py +270 -0
- comitia/host.py +2067 -0
- comitia/plan.py +957 -0
- comitia/posting.py +328 -0
- comitia/prompts.py +750 -0
- comitia/recipe.py +430 -0
- comitia/report.py +581 -0
- comitia/settings.py +66 -0
- comitia/skill/SKILL.md +75 -0
- comitia/starters/decision-debate.yml +27 -0
- comitia/starters/deep-review.yml +12 -0
- comitia/starters/message-test.yml +15 -0
- comitia/starters/pr-review-light.yml +78 -0
- comitia/starters/pr-review.yml +100 -0
- comitia/starters/prd-review.yml +10 -0
- comitia/store.py +212 -0
- comitia/web/__init__.py +13 -0
- comitia/web/server.py +244 -0
- comitia/web/service.py +679 -0
- comitia/web/static/app.js +1521 -0
- comitia/web/static/index.html +38 -0
- comitia/web/static/styles.css +262 -0
- comitia-0.1.0.dist-info/METADATA +589 -0
- comitia-0.1.0.dist-info/RECORD +48 -0
- comitia-0.1.0.dist-info/WHEEL +4 -0
- comitia-0.1.0.dist-info/entry_points.txt +2 -0
- comitia-0.1.0.dist-info/licenses/LICENSE +21 -0
- comitia-0.1.0.dist-info/licenses/LICENSES/crossby-MIT.txt +21 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
"""What ``comitia panel`` shows on stderr while a panel runs.
|
|
2
|
+
|
|
3
|
+
Every message is printed as it is committed. A heading names its turn, its
|
|
4
|
+
sender and its recipients, and a footer gives its time and any denials. On a
|
|
5
|
+
terminal, one live line also shows what is running now: the tools being
|
|
6
|
+
checked, the lead writing, or each addressed member writing, answered, failed
|
|
7
|
+
or queued. Off a terminal the same moments are printed as plain lines, so a
|
|
8
|
+
log reads in order.
|
|
9
|
+
|
|
10
|
+
A human seat holds the terminal while it is asked. The live line stops and
|
|
11
|
+
anything else to print waits until the reply is in, so nothing is drawn over
|
|
12
|
+
what the person types.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
import sys
|
|
19
|
+
import threading
|
|
20
|
+
import time
|
|
21
|
+
from collections.abc import Callable, Iterator
|
|
22
|
+
from contextlib import contextmanager
|
|
23
|
+
from dataclasses import dataclass, replace
|
|
24
|
+
from functools import partial
|
|
25
|
+
from typing import TYPE_CHECKING, Any
|
|
26
|
+
|
|
27
|
+
from comitia.discussion.cli import _duration, _escape, _stderr
|
|
28
|
+
from comitia.discussion.console import console
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from crossby.api import CliBackend
|
|
32
|
+
from rich.console import RenderableType
|
|
33
|
+
from rich.live import Live
|
|
34
|
+
|
|
35
|
+
from comitia.discussion.journal import ConversationEvent
|
|
36
|
+
from comitia.discussion.panel import Member, PanelSpec
|
|
37
|
+
|
|
38
|
+
# The version inside a tool's own --version text, e.g. "2.1.317 (Claude Code)",
|
|
39
|
+
# "codex-cli 0.166.0", "2026.11.10-731fb78" or "GitHub Copilot CLI 1.0.109.".
|
|
40
|
+
_VERSION = re.compile(r"\d+(?:\.\d+)+(?:[-+][0-9A-Za-z](?:[0-9A-Za-z.-]*[0-9A-Za-z])?)?")
|
|
41
|
+
|
|
42
|
+
_HUMAN_STATUS = {
|
|
43
|
+
"timed_out": "no reply in time",
|
|
44
|
+
"cancelled": "the reply was cancelled",
|
|
45
|
+
"empty": "the reply was empty",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def version_number(text: str | None) -> str | None:
|
|
50
|
+
"""The version in a tool's ``--version`` output, without the words around it."""
|
|
51
|
+
if not text:
|
|
52
|
+
return None
|
|
53
|
+
match = _VERSION.search(text)
|
|
54
|
+
return match.group(0) if match else text.strip()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def backend_label(backend: CliBackend) -> str:
|
|
58
|
+
"""``codex``, or ``codex (gpt-5.5, high effort)`` when a model or effort is set."""
|
|
59
|
+
settings = [backend.model] if backend.model else []
|
|
60
|
+
if backend.effort is not None:
|
|
61
|
+
settings.append(f"{backend.effort.value} effort")
|
|
62
|
+
return backend.tool.value + (f" ({', '.join(settings)})" if settings else "")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def member_label(member: Member) -> str:
|
|
66
|
+
"""``codex``, ``cursor, persona folder``, ``Rui, codex`` or ``Dana, a person``."""
|
|
67
|
+
from crossby.api import CliBackend, OwnedWorkspace
|
|
68
|
+
|
|
69
|
+
parts = [member.name] if member.name else []
|
|
70
|
+
if isinstance(member.backend, CliBackend):
|
|
71
|
+
parts.append(backend_label(member.backend))
|
|
72
|
+
if isinstance(member.workspace, OwnedWorkspace):
|
|
73
|
+
parts.append("persona folder")
|
|
74
|
+
else:
|
|
75
|
+
parts.append("a person")
|
|
76
|
+
return ", ".join(parts)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def show_opening(
|
|
80
|
+
spec: PanelSpec, *, transcript: str, events: str | None, recipe: str | None = None
|
|
81
|
+
) -> None:
|
|
82
|
+
"""Who leads which members, how they answer, the limits, and where the files are."""
|
|
83
|
+
from crossby.api import CliBackend
|
|
84
|
+
|
|
85
|
+
backend = spec.lead.backend
|
|
86
|
+
lead = f"{backend_label(backend)} leads" if isinstance(backend, CliBackend) else "You lead"
|
|
87
|
+
count = len(spec.members)
|
|
88
|
+
_stderr(
|
|
89
|
+
f" [step]▸[/] {_escape(lead)} a {spec.visibility} panel of {count} "
|
|
90
|
+
f"member{'' if count == 1 else 's'}:"
|
|
91
|
+
)
|
|
92
|
+
width = max(len(member.id) for member in spec.members) + 1
|
|
93
|
+
for member in spec.members:
|
|
94
|
+
_stderr(f" [bold]@{member.id:<{width}}[/] {_escape(member_label(member))}")
|
|
95
|
+
if count == 1:
|
|
96
|
+
how = "the member answers"
|
|
97
|
+
elif spec.concurrency >= count:
|
|
98
|
+
how = "members answer in parallel"
|
|
99
|
+
elif spec.concurrency == 1:
|
|
100
|
+
how = "members answer one at a time"
|
|
101
|
+
else:
|
|
102
|
+
how = f"members answer in parallel, {spec.concurrency} at a time"
|
|
103
|
+
if any(not member.human for member in spec.members):
|
|
104
|
+
how += "; agents are read-only"
|
|
105
|
+
_stderr(f"[dim] {how}[/]")
|
|
106
|
+
allowed = spec.max_rounds
|
|
107
|
+
limits = (
|
|
108
|
+
f"up to {allowed} message{'' if allowed == 1 else 's'} to the members, "
|
|
109
|
+
f"{_duration(spec.timeout_seconds)} in all, {_duration(spec.turn_timeout_seconds)} per turn"
|
|
110
|
+
)
|
|
111
|
+
if spec.lead.human or any(member.human for member in spec.members):
|
|
112
|
+
limits += f", {_duration(spec.human_timeout_seconds)} per human reply"
|
|
113
|
+
_stderr(f"[dim] limits: {limits}[/]")
|
|
114
|
+
if recipe is not None:
|
|
115
|
+
_stderr(f"[dim] recipe: {_escape(recipe)}[/]")
|
|
116
|
+
_stderr(f"[dim] transcript: {_escape(transcript)}[/]")
|
|
117
|
+
if events is not None:
|
|
118
|
+
_stderr(f"[dim] events: {_escape(events)}[/]")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@dataclass(frozen=True)
|
|
122
|
+
class _Seat:
|
|
123
|
+
"""One addressed member during a dispatch."""
|
|
124
|
+
|
|
125
|
+
id: str
|
|
126
|
+
state: str # queued, writing, waiting, answered or failed
|
|
127
|
+
since: float | None = None
|
|
128
|
+
seconds: float | None = None
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@dataclass(frozen=True)
|
|
132
|
+
class _Activity:
|
|
133
|
+
"""What the live line shows; replaced whole, never changed in place."""
|
|
134
|
+
|
|
135
|
+
kind: str # checking, lead or members
|
|
136
|
+
since: float
|
|
137
|
+
label: str = ""
|
|
138
|
+
seats: tuple[_Seat, ...] = ()
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def activity_text(activity: _Activity, now: float) -> str:
|
|
142
|
+
"""The live line's text, e.g. ``@ops writing 42s · @design ✓ 14s · @support queued``."""
|
|
143
|
+
if activity.kind == "checking":
|
|
144
|
+
return f"checking {activity.label}… {_duration(now - activity.since)}"
|
|
145
|
+
if activity.kind == "lead":
|
|
146
|
+
return f"{activity.label} is writing… {_duration(now - activity.since)}"
|
|
147
|
+
parts = []
|
|
148
|
+
for seat in activity.seats:
|
|
149
|
+
if seat.state == "writing" and seat.since is not None:
|
|
150
|
+
parts.append(f"@{seat.id} writing {_duration(now - seat.since)}")
|
|
151
|
+
elif seat.state == "waiting" and seat.since is not None:
|
|
152
|
+
parts.append(f"@{seat.id} waiting for a reply {_duration(now - seat.since)}")
|
|
153
|
+
elif seat.state == "answered":
|
|
154
|
+
parts.append(f"@{seat.id} ✓ {_duration(seat.seconds or 0.0)}")
|
|
155
|
+
elif seat.state == "failed":
|
|
156
|
+
parts.append(f"@{seat.id} ✗")
|
|
157
|
+
else:
|
|
158
|
+
parts.append(f"@{seat.id} queued")
|
|
159
|
+
return " · ".join(parts)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class _Line:
|
|
163
|
+
"""The live line: a spinner and the current activity, redrawn by rich."""
|
|
164
|
+
|
|
165
|
+
def __init__(self, view: PanelView) -> None:
|
|
166
|
+
from rich.spinner import Spinner
|
|
167
|
+
|
|
168
|
+
self._view = view
|
|
169
|
+
self._spinner = Spinner("dots", style="step")
|
|
170
|
+
|
|
171
|
+
def __rich__(self) -> RenderableType:
|
|
172
|
+
from rich.text import Text
|
|
173
|
+
|
|
174
|
+
# Read without a lock: rich calls this from its refresh thread, which
|
|
175
|
+
# stopping the live display joins while the view's lock is held.
|
|
176
|
+
activity = self._view.activity
|
|
177
|
+
text = activity_text(activity, time.monotonic()) if activity is not None else ""
|
|
178
|
+
self._spinner.update(text=Text(f" {text}", style="dim"))
|
|
179
|
+
return self._spinner
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class PanelView:
|
|
183
|
+
"""An event sink that shows a panel run on stderr. Safe from any thread.
|
|
184
|
+
|
|
185
|
+
``live`` draws the live line (on a terminal only). ``typed_here`` means a
|
|
186
|
+
person types human seats' replies at this terminal and can see them, so
|
|
187
|
+
their committed messages are not printed a second time.
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
def __init__(self, spec: PanelSpec, *, live: bool, typed_here: bool) -> None:
|
|
191
|
+
self._spec = spec
|
|
192
|
+
self._live_enabled = live
|
|
193
|
+
self._typed_here = typed_here
|
|
194
|
+
self._lock = threading.RLock()
|
|
195
|
+
self._held = 0
|
|
196
|
+
self._deferred: list[Callable[[], None]] = []
|
|
197
|
+
self._live: Live | None = None
|
|
198
|
+
self.activity: _Activity | None = None
|
|
199
|
+
self._versions: dict[str, str | None] = {}
|
|
200
|
+
self._warnings: dict[str, None] = {}
|
|
201
|
+
self._versions_shown = False
|
|
202
|
+
self._announced = threading.Condition()
|
|
203
|
+
self._requests: set[str] = set()
|
|
204
|
+
self._humans = {member.id for member in spec.members if member.human}
|
|
205
|
+
if spec.lead.human:
|
|
206
|
+
self._humans.add("lead")
|
|
207
|
+
self._names = {member.id: member.name for member in spec.members}
|
|
208
|
+
|
|
209
|
+
# -- lifecycle ---------------------------------------------------------
|
|
210
|
+
|
|
211
|
+
def start(self) -> None:
|
|
212
|
+
"""Show that the tools are being checked, until the first turn starts."""
|
|
213
|
+
tools: list[str] = []
|
|
214
|
+
for backend in [self._spec.lead.backend, *(m.backend for m in self._spec.members)]:
|
|
215
|
+
name = getattr(getattr(backend, "tool", None), "value", None)
|
|
216
|
+
if name is not None and name not in tools:
|
|
217
|
+
tools.append(name)
|
|
218
|
+
with self._lock:
|
|
219
|
+
if tools:
|
|
220
|
+
self._set(_Activity("checking", time.monotonic(), label=", ".join(tools)))
|
|
221
|
+
|
|
222
|
+
def close(self) -> None:
|
|
223
|
+
"""Stop the live line and print anything still waiting."""
|
|
224
|
+
with self._lock:
|
|
225
|
+
self._held = 0
|
|
226
|
+
self.activity = None
|
|
227
|
+
self._stop_live()
|
|
228
|
+
deferred, self._deferred = self._deferred, []
|
|
229
|
+
for show in deferred:
|
|
230
|
+
show()
|
|
231
|
+
|
|
232
|
+
@contextmanager
|
|
233
|
+
def hold(self) -> Iterator[None]:
|
|
234
|
+
"""Keep the terminal still while a person types: no live line, no other output."""
|
|
235
|
+
with self._lock:
|
|
236
|
+
self._held += 1
|
|
237
|
+
self._stop_live()
|
|
238
|
+
try:
|
|
239
|
+
yield
|
|
240
|
+
finally:
|
|
241
|
+
with self._lock:
|
|
242
|
+
self._held -= 1
|
|
243
|
+
if self._held == 0:
|
|
244
|
+
deferred, self._deferred = self._deferred, []
|
|
245
|
+
for show in deferred:
|
|
246
|
+
show()
|
|
247
|
+
self._start_live()
|
|
248
|
+
|
|
249
|
+
def wait_announced(self, request_id: str, timeout: float) -> bool:
|
|
250
|
+
"""Whether this view has shown everything up to ``request_id``'s input request.
|
|
251
|
+
|
|
252
|
+
Events reach the view on the journal's dispatcher thread, a moment after
|
|
253
|
+
they happen. A human seat waits for this before prompting, so the
|
|
254
|
+
messages it answers are already on screen above the prompt.
|
|
255
|
+
"""
|
|
256
|
+
deadline = time.monotonic() + timeout
|
|
257
|
+
with self._announced:
|
|
258
|
+
while request_id not in self._requests:
|
|
259
|
+
left = deadline - time.monotonic()
|
|
260
|
+
if left <= 0:
|
|
261
|
+
return False
|
|
262
|
+
self._announced.wait(left)
|
|
263
|
+
return True
|
|
264
|
+
|
|
265
|
+
# -- the sink ----------------------------------------------------------
|
|
266
|
+
|
|
267
|
+
def __call__(self, event: ConversationEvent) -> None:
|
|
268
|
+
from comitia.discussion.journal import EventType
|
|
269
|
+
|
|
270
|
+
data = event.data
|
|
271
|
+
handlers: dict[EventType, Callable[[dict[str, Any]], None]] = {
|
|
272
|
+
EventType.PARTICIPANT_READY: self._ready,
|
|
273
|
+
EventType.TURN_STARTED: self._turn_started,
|
|
274
|
+
EventType.TURN_FINISHED: self._turn_finished,
|
|
275
|
+
EventType.INPUT_REQUESTED: self._input_requested,
|
|
276
|
+
EventType.INPUT_RESOLVED: self._input_resolved,
|
|
277
|
+
EventType.MESSAGE_COMMITTED: self._committed,
|
|
278
|
+
EventType.CONVERSATION_FINISHED: self._finished,
|
|
279
|
+
}
|
|
280
|
+
handler = handlers.get(event.type)
|
|
281
|
+
if handler is not None:
|
|
282
|
+
with self._lock:
|
|
283
|
+
handler(data)
|
|
284
|
+
|
|
285
|
+
def _ready(self, data: dict[str, Any]) -> None:
|
|
286
|
+
self._versions.setdefault(str(data["tool"]), version_number(data.get("version")))
|
|
287
|
+
self._warnings.update(dict.fromkeys(data.get("warnings") or ()))
|
|
288
|
+
|
|
289
|
+
def _turn_started(self, data: dict[str, Any]) -> None:
|
|
290
|
+
self._show_versions()
|
|
291
|
+
participant, now = data["participant"], time.monotonic()
|
|
292
|
+
if participant == "lead":
|
|
293
|
+
turn, tool = data["turn"], data["tool"]
|
|
294
|
+
self._set(_Activity("lead", now, label=f"[{turn}] lead ({tool})"))
|
|
295
|
+
if not self._live_enabled:
|
|
296
|
+
line = f"[step.count]\\[{turn}][/] lead ({_escape(str(tool))}) is writing…"
|
|
297
|
+
self._print(lambda: _stderr(line))
|
|
298
|
+
return
|
|
299
|
+
self._seat(participant, state="writing", since=now)
|
|
300
|
+
|
|
301
|
+
def _turn_finished(self, data: dict[str, Any]) -> None:
|
|
302
|
+
participant = data["participant"]
|
|
303
|
+
if participant == "lead":
|
|
304
|
+
return
|
|
305
|
+
error = data.get("error")
|
|
306
|
+
seconds = float(data.get("duration_seconds") or 0.0)
|
|
307
|
+
self._seat(participant, state="failed" if error else "answered", seconds=seconds)
|
|
308
|
+
if error:
|
|
309
|
+
self._print(lambda: _stderr(f" [warning]![/] @{participant}: {_escape(str(error))}"))
|
|
310
|
+
elif not self._live_enabled:
|
|
311
|
+
self._print(
|
|
312
|
+
lambda: _stderr(f"[dim] @{participant} answered · {_duration(seconds)}[/]")
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
def _input_requested(self, data: dict[str, Any]) -> None:
|
|
316
|
+
self._show_versions()
|
|
317
|
+
participant = data["participant"]
|
|
318
|
+
if data.get("kind") == "lead":
|
|
319
|
+
self._set(None)
|
|
320
|
+
else:
|
|
321
|
+
self._seat(participant, state="waiting", since=time.monotonic())
|
|
322
|
+
with self._announced:
|
|
323
|
+
self._requests.add(str(data["request_id"]))
|
|
324
|
+
self._announced.notify_all()
|
|
325
|
+
|
|
326
|
+
def _input_resolved(self, data: dict[str, Any]) -> None:
|
|
327
|
+
participant, status = data["participant"], data.get("status")
|
|
328
|
+
if participant == "lead":
|
|
329
|
+
return
|
|
330
|
+
seat = self._find(participant)
|
|
331
|
+
since = seat.since if seat is not None else None
|
|
332
|
+
seconds = time.monotonic() - since if since is not None else 0.0
|
|
333
|
+
if status == "answered":
|
|
334
|
+
self._seat(participant, state="answered", seconds=seconds)
|
|
335
|
+
return
|
|
336
|
+
self._seat(participant, state="failed")
|
|
337
|
+
reason = _HUMAN_STATUS.get(str(status), str(status))
|
|
338
|
+
self._print(lambda: _stderr(f" [warning]![/] @{participant}: {_escape(reason)}"))
|
|
339
|
+
|
|
340
|
+
def _committed(self, data: dict[str, Any]) -> None:
|
|
341
|
+
sender = data["participant"]
|
|
342
|
+
recipients = [str(item) for item in data.get("recipients", [])]
|
|
343
|
+
if sender == "lead":
|
|
344
|
+
target = "final answer" if data.get("done") else " ".join(f"@{r}" for r in recipients)
|
|
345
|
+
who = "you" if self._spec.lead.human else self._tool("lead")
|
|
346
|
+
title = f"lead ({who}) → {target}"
|
|
347
|
+
else:
|
|
348
|
+
name, tool = self._names.get(sender), self._tool(sender)
|
|
349
|
+
who = ", ".join(part for part in (name, tool) if part and part != "a person") or tool
|
|
350
|
+
title = f"@{sender} ({who}) → lead"
|
|
351
|
+
typed = sender in self._humans and self._typed_here
|
|
352
|
+
text = str(data.get("text") or "") or "(empty message)"
|
|
353
|
+
footer = [_duration(float(data.get("duration_seconds") or 0.0))]
|
|
354
|
+
footer += [f"denied: {denial}" for denial in data.get("denials", [])]
|
|
355
|
+
if typed:
|
|
356
|
+
footer.insert(0, "typed above")
|
|
357
|
+
heading = f"[step.count]\\[{data['turn']}][/] {_escape(title)}"
|
|
358
|
+
|
|
359
|
+
def show() -> None:
|
|
360
|
+
_stderr(heading)
|
|
361
|
+
if not typed:
|
|
362
|
+
sys.stderr.write(f"\n{text}\n\n")
|
|
363
|
+
sys.stderr.flush()
|
|
364
|
+
_stderr(f"[dim] {_escape(' · '.join(footer))}[/]")
|
|
365
|
+
|
|
366
|
+
self._print(show)
|
|
367
|
+
if sender == "lead" and not data.get("done"):
|
|
368
|
+
seats = tuple(_Seat(member_id, "queued") for member_id in recipients)
|
|
369
|
+
self._set(_Activity("members", time.monotonic(), seats=seats))
|
|
370
|
+
if not self._live_enabled:
|
|
371
|
+
asked = ", ".join(f"@{member_id}" for member_id in recipients)
|
|
372
|
+
self._print(lambda: _stderr(f"[dim] asking {asked}…[/]"))
|
|
373
|
+
elif sender == "lead":
|
|
374
|
+
self._set(None)
|
|
375
|
+
|
|
376
|
+
def _finished(self, _data: dict[str, Any]) -> None:
|
|
377
|
+
self._set(None)
|
|
378
|
+
|
|
379
|
+
# -- helpers -------------------------------------------------------------
|
|
380
|
+
|
|
381
|
+
def _tool(self, participant: str) -> str:
|
|
382
|
+
if participant == "lead":
|
|
383
|
+
backend: Any = self._spec.lead.backend
|
|
384
|
+
else:
|
|
385
|
+
backend = next(m.backend for m in self._spec.members if m.id == participant)
|
|
386
|
+
tool = getattr(getattr(backend, "tool", None), "value", None)
|
|
387
|
+
return str(tool) if tool is not None else "a person"
|
|
388
|
+
|
|
389
|
+
def _show_versions(self) -> None:
|
|
390
|
+
if self._versions_shown or not self._versions:
|
|
391
|
+
return
|
|
392
|
+
self._versions_shown = True
|
|
393
|
+
tools = " · ".join(
|
|
394
|
+
name + (f" {version}" if version else "") for name, version in self._versions.items()
|
|
395
|
+
)
|
|
396
|
+
self._print(lambda: _stderr(f"[dim] tools: {_escape(tools)}[/]"))
|
|
397
|
+
for warning in self._warnings:
|
|
398
|
+
self._print(partial(_stderr, f"[warning] ! {_escape(str(warning))}[/]"))
|
|
399
|
+
|
|
400
|
+
def _find(self, member_id: str) -> _Seat | None:
|
|
401
|
+
activity = self.activity
|
|
402
|
+
if activity is None or activity.kind != "members":
|
|
403
|
+
return None
|
|
404
|
+
return next((seat for seat in activity.seats if seat.id == member_id), None)
|
|
405
|
+
|
|
406
|
+
def _seat(self, member_id: str, **changes: Any) -> None:
|
|
407
|
+
activity = self.activity
|
|
408
|
+
if activity is None or activity.kind != "members":
|
|
409
|
+
return
|
|
410
|
+
seats = tuple(
|
|
411
|
+
replace(seat, **changes) if seat.id == member_id else seat for seat in activity.seats
|
|
412
|
+
)
|
|
413
|
+
self._set(replace(activity, seats=seats))
|
|
414
|
+
|
|
415
|
+
def _set(self, activity: _Activity | None) -> None:
|
|
416
|
+
self.activity = activity
|
|
417
|
+
if activity is None:
|
|
418
|
+
self._stop_live()
|
|
419
|
+
else:
|
|
420
|
+
self._start_live()
|
|
421
|
+
|
|
422
|
+
def _print(self, show: Callable[[], None]) -> None:
|
|
423
|
+
if self._held:
|
|
424
|
+
self._deferred.append(show)
|
|
425
|
+
return
|
|
426
|
+
running = self._live is not None
|
|
427
|
+
self._stop_live()
|
|
428
|
+
show()
|
|
429
|
+
if running or self.activity is not None:
|
|
430
|
+
self._start_live()
|
|
431
|
+
|
|
432
|
+
def _start_live(self) -> None:
|
|
433
|
+
if not self._live_enabled or self._held or self._live is not None:
|
|
434
|
+
return
|
|
435
|
+
if self.activity is None:
|
|
436
|
+
return
|
|
437
|
+
from rich.live import Live
|
|
438
|
+
|
|
439
|
+
self._live = Live(_Line(self), console=console.err, transient=True, refresh_per_second=4)
|
|
440
|
+
self._live.start()
|
|
441
|
+
|
|
442
|
+
def _stop_live(self) -> None:
|
|
443
|
+
if self._live is not None:
|
|
444
|
+
self._live.stop()
|
|
445
|
+
self._live = None
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
You are summarizing a consultation between two AI coding agents. The asker ({asker}) held the goal and asked the questions; the responder ({responder}) never saw the goal and only answered. You are a neutral reader: do not take either side, and do not add conclusions that are not in the transcript.
|
|
2
|
+
|
|
3
|
+
Goal: {goal}
|
|
4
|
+
Stop reason: {stop_reason}
|
|
5
|
+
|
|
6
|
+
Work only from the transcript below. Do not read, modify, create, or delete files, and do not run commands.
|
|
7
|
+
|
|
8
|
+
The asker's final answer is its own judgment, not independent verification. If it rests on claims neither agent checked, say so in the outcome.
|
|
9
|
+
|
|
10
|
+
Write a markdown summary with exactly these sections:
|
|
11
|
+
|
|
12
|
+
## Outcome
|
|
13
|
+
One short paragraph: the asker's conclusion, or where the consultation stopped if there is none.
|
|
14
|
+
|
|
15
|
+
## Key Findings
|
|
16
|
+
Bulleted facts established in the conversation, with the files, lines, or commands cited.
|
|
17
|
+
|
|
18
|
+
## Points of Disagreement
|
|
19
|
+
Where the asker doubted or corrected the responder, and whether it was resolved. Write "None" if there were none.
|
|
20
|
+
|
|
21
|
+
## Open Questions
|
|
22
|
+
What was left unverified or unanswered. Write "None" if nothing was.
|
|
23
|
+
|
|
24
|
+
## Next Steps
|
|
25
|
+
A numbered list of concrete actions to take next, in order.
|
|
26
|
+
|
|
27
|
+
Reply with the summary only, starting at the "## Outcome" heading.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""The transcript model a consultation's summary is built from.
|
|
2
|
+
|
|
3
|
+
Copied from crossby v0.71.0: ``ToolCall``, ``SessionRef``, ``ConversationTurn``
|
|
4
|
+
and ``ConversationTranscript`` from ``crossby/handoff/models.py``, and
|
|
5
|
+
``render_turn`` with its helper ``_short_args`` from
|
|
6
|
+
``crossby/handoff/summarizer.py``.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Any, Literal
|
|
15
|
+
|
|
16
|
+
from crossby.api import AIToolID
|
|
17
|
+
from pydantic import BaseModel, Field
|
|
18
|
+
|
|
19
|
+
Role = Literal["user", "assistant", "tool", "system"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ToolCall(BaseModel):
|
|
23
|
+
"""A single tool/function call recorded in a transcript turn."""
|
|
24
|
+
|
|
25
|
+
name: str
|
|
26
|
+
arguments: dict[str, Any] = Field(default_factory=dict)
|
|
27
|
+
call_id: str | None = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class SessionRef(BaseModel):
|
|
31
|
+
"""Pointer to an on-disk session for a specific tool.
|
|
32
|
+
|
|
33
|
+
``cwd`` is None when the source format does not record it.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
tool_id: AIToolID
|
|
37
|
+
session_id: str
|
|
38
|
+
path: Path
|
|
39
|
+
started_at: datetime
|
|
40
|
+
cwd: Path | None = None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class ConversationTurn(BaseModel):
|
|
44
|
+
"""A single message/event in a conversation transcript."""
|
|
45
|
+
|
|
46
|
+
role: Role
|
|
47
|
+
content: str
|
|
48
|
+
tool_calls: list[ToolCall] = Field(default_factory=list)
|
|
49
|
+
# Associates a tool-result turn with its originating ToolCall.call_id.
|
|
50
|
+
tool_call_id: str | None = None
|
|
51
|
+
file_refs: list[Path] = Field(default_factory=list)
|
|
52
|
+
timestamp: datetime | None = None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ConversationTranscript(BaseModel):
|
|
56
|
+
"""The full transcript returned by every session reader."""
|
|
57
|
+
|
|
58
|
+
session_ref: SessionRef
|
|
59
|
+
turns: list[ConversationTurn] = Field(default_factory=list)
|
|
60
|
+
truncated: bool = False
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def render_turn(turn: ConversationTurn) -> str:
|
|
64
|
+
"""Render a transcript turn for inclusion in the summarizer prompt."""
|
|
65
|
+
header = f"[{turn.role}]"
|
|
66
|
+
if turn.tool_call_id is not None:
|
|
67
|
+
header += f" call_id={turn.tool_call_id}"
|
|
68
|
+
if turn.timestamp is not None:
|
|
69
|
+
header += f" {turn.timestamp.isoformat()}"
|
|
70
|
+
body = turn.content or ""
|
|
71
|
+
tool_calls = ""
|
|
72
|
+
if turn.tool_calls:
|
|
73
|
+
call_lines = []
|
|
74
|
+
for call in turn.tool_calls:
|
|
75
|
+
call_id = f" call_id={call.call_id}" if call.call_id is not None else ""
|
|
76
|
+
call_lines.append(f" - tool_call: {call.name}({_short_args(call.arguments)}){call_id}")
|
|
77
|
+
tool_calls = "\n" + "\n".join(call_lines)
|
|
78
|
+
file_refs = ""
|
|
79
|
+
if turn.file_refs:
|
|
80
|
+
file_refs = "\n files: " + ", ".join(str(p) for p in turn.file_refs)
|
|
81
|
+
return f"{header}\n{body}{tool_calls}{file_refs}".rstrip()
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _short_args(args: dict[str, Any], max_len: int = 200) -> str:
|
|
85
|
+
rendered = json.dumps(args, default=str, sort_keys=True)
|
|
86
|
+
if len(rendered) > max_len:
|
|
87
|
+
return rendered[: max_len - 3] + "..."
|
|
88
|
+
return rendered
|