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,167 @@
|
|
|
1
|
+
"""Panel recipes for ``comitia panel``: ``panels:`` in ``.comitia.yml`` or ``.crossby.yml``.
|
|
2
|
+
|
|
3
|
+
``PanelLeadConfig``, ``PanelMemberConfig`` and ``PanelConfig`` are copied from crossby
|
|
4
|
+
v0.71.0 (``crossby/models/config.py``). ``.comitia.yml`` comes first; a project that
|
|
5
|
+
still keeps its panels in ``.crossby.yml``, where ``crossby panel`` read them, works too.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any, Literal
|
|
13
|
+
|
|
14
|
+
import yaml
|
|
15
|
+
from pydantic import BaseModel, ConfigDict, Field, ValidationError, model_validator
|
|
16
|
+
|
|
17
|
+
from comitia import store
|
|
18
|
+
from comitia.settings import SETTINGS_FILE, SettingsError, load_settings
|
|
19
|
+
|
|
20
|
+
CROSSBY_FILE = ".crossby.yml"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class PanelLeadConfig(BaseModel):
|
|
24
|
+
"""``panels.<name>.lead``: the agent that holds the goal."""
|
|
25
|
+
|
|
26
|
+
model_config = ConfigDict(extra="forbid")
|
|
27
|
+
|
|
28
|
+
# A person leads instead of an agent (comitia panel reads the terminal).
|
|
29
|
+
human: bool = False
|
|
30
|
+
tool: str | None = None
|
|
31
|
+
model: str | None = None
|
|
32
|
+
effort: str | None = None
|
|
33
|
+
# The lead's folder, relative to the project root.
|
|
34
|
+
folder: str = "."
|
|
35
|
+
|
|
36
|
+
@model_validator(mode="after")
|
|
37
|
+
def _tool_or_human(self) -> PanelLeadConfig:
|
|
38
|
+
if self.human == (self.tool is not None):
|
|
39
|
+
raise ValueError("set either tool or human: true")
|
|
40
|
+
return self
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class PanelMemberConfig(BaseModel):
|
|
44
|
+
"""``panels.<name>.members[]``: one read-only member.
|
|
45
|
+
|
|
46
|
+
With ``persona_folder`` comitia provisions that folder in the tool's own
|
|
47
|
+
layout (``instructions`` becomes its instruction file, ``skills`` its
|
|
48
|
+
skills, ``files`` maps material paths to source files). Otherwise the
|
|
49
|
+
member answers from ``folder`` and ``instructions`` travels in the
|
|
50
|
+
envelope.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
model_config = ConfigDict(extra="forbid")
|
|
54
|
+
|
|
55
|
+
id: str
|
|
56
|
+
name: str | None = None
|
|
57
|
+
# A person takes this seat instead of an agent.
|
|
58
|
+
human: bool = False
|
|
59
|
+
tool: str | None = None
|
|
60
|
+
model: str | None = None
|
|
61
|
+
effort: str | None = None
|
|
62
|
+
folder: str = "."
|
|
63
|
+
persona_folder: str | None = None
|
|
64
|
+
instructions: str | None = None
|
|
65
|
+
skills: list[str] = Field(default_factory=list)
|
|
66
|
+
files: dict[str, str] = Field(default_factory=dict)
|
|
67
|
+
|
|
68
|
+
@model_validator(mode="after")
|
|
69
|
+
def _tool_or_human(self) -> PanelMemberConfig:
|
|
70
|
+
if self.human == (self.tool is not None):
|
|
71
|
+
raise ValueError("set either tool or human: true")
|
|
72
|
+
if self.human and (self.persona_folder or self.instructions or self.skills or self.files):
|
|
73
|
+
raise ValueError("a human member takes no folder, instructions, skills or files")
|
|
74
|
+
return self
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class PanelConfig(BaseModel):
|
|
78
|
+
"""``panels.<name>``: a recipe for ``comitia panel``."""
|
|
79
|
+
|
|
80
|
+
model_config = ConfigDict(extra="forbid")
|
|
81
|
+
|
|
82
|
+
lead: PanelLeadConfig
|
|
83
|
+
members: list[PanelMemberConfig]
|
|
84
|
+
visibility: Literal["private", "shared"] = "private"
|
|
85
|
+
max_rounds: int = Field(default=5, ge=1)
|
|
86
|
+
concurrency: int = Field(default=4, ge=1)
|
|
87
|
+
timeout: float = Field(default=1800.0, gt=0)
|
|
88
|
+
turn_timeout: float = Field(default=600.0, gt=0)
|
|
89
|
+
# A file whose text replaces the lead's opening notice wording.
|
|
90
|
+
notice: str | None = None
|
|
91
|
+
require_blocked: list[str] = Field(default_factory=list)
|
|
92
|
+
# Seconds a human seat may take to reply.
|
|
93
|
+
human_timeout: float = Field(default=1800.0, gt=0)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class PanelsError(Exception):
|
|
97
|
+
"""The file that names the panels cannot be read, or a panel in it is not valid."""
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass(frozen=True)
|
|
101
|
+
class Panels:
|
|
102
|
+
"""The panel recipes a project names, and where they came from."""
|
|
103
|
+
|
|
104
|
+
recipes: dict[str, PanelConfig]
|
|
105
|
+
# The file they were read from; None when no file names any.
|
|
106
|
+
source: Path | None
|
|
107
|
+
# The folder each recipe's paths are relative to: its file's.
|
|
108
|
+
root: Path
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def load_panels(start: Path) -> Panels:
|
|
112
|
+
"""The panels of the project ``start`` is in.
|
|
113
|
+
|
|
114
|
+
``panels:`` in ``.comitia.yml`` at the project root, when it has any; otherwise
|
|
115
|
+
in the nearest ``.crossby.yml`` at or above ``start``, as ``crossby panel`` found it.
|
|
116
|
+
"""
|
|
117
|
+
project = store.project_root(start)
|
|
118
|
+
try:
|
|
119
|
+
settings = load_settings(project)
|
|
120
|
+
except SettingsError as exc:
|
|
121
|
+
raise PanelsError(str(exc)) from None
|
|
122
|
+
if settings.panels:
|
|
123
|
+
path = project / SETTINGS_FILE
|
|
124
|
+
return Panels(_validated(settings.panels, path), path, project)
|
|
125
|
+
found = _crossby_file(start)
|
|
126
|
+
if found is None:
|
|
127
|
+
return Panels({}, None, start)
|
|
128
|
+
block = _read(found).get("panels") or {}
|
|
129
|
+
if not isinstance(block, dict):
|
|
130
|
+
raise PanelsError(f"{found}: `panels` must be a mapping of panel names to recipes.")
|
|
131
|
+
return Panels(_validated(block, found), found, found.parent)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _crossby_file(start: Path) -> Path | None:
|
|
135
|
+
for folder in (start, *start.parents):
|
|
136
|
+
candidate = folder / CROSSBY_FILE
|
|
137
|
+
if candidate.exists() or candidate.is_symlink():
|
|
138
|
+
return candidate
|
|
139
|
+
return None
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _read(path: Path) -> dict[str, Any]:
|
|
143
|
+
try:
|
|
144
|
+
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
|
145
|
+
except (OSError, UnicodeDecodeError) as exc:
|
|
146
|
+
raise PanelsError(f"{path} cannot be read: {exc}") from None
|
|
147
|
+
except yaml.YAMLError as exc:
|
|
148
|
+
raise PanelsError(f"{path} is not valid YAML: {exc}") from None
|
|
149
|
+
if data is None:
|
|
150
|
+
return {}
|
|
151
|
+
if not isinstance(data, dict):
|
|
152
|
+
raise PanelsError(f"{path} must be a mapping.")
|
|
153
|
+
return data
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _validated(block: dict[str, Any], path: Path) -> dict[str, PanelConfig]:
|
|
157
|
+
recipes: dict[str, PanelConfig] = {}
|
|
158
|
+
for name, value in block.items():
|
|
159
|
+
try:
|
|
160
|
+
recipes[str(name)] = PanelConfig.model_validate(value)
|
|
161
|
+
except ValidationError as exc:
|
|
162
|
+
problems = "; ".join(
|
|
163
|
+
f"{'.'.join(str(part) for part in error['loc']) or 'panel'}: {error['msg']}"
|
|
164
|
+
for error in exc.errors()
|
|
165
|
+
)
|
|
166
|
+
raise PanelsError(f"{path}: panel `{name}` is not valid: {problems}") from None
|
|
167
|
+
return recipes
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"""Console class — all terminal message functions.
|
|
2
|
+
|
|
3
|
+
All output respects Rich markup and goes to the appropriate stream
|
|
4
|
+
(stdout for info, stderr for errors/warnings).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import contextlib
|
|
10
|
+
from typing import TYPE_CHECKING, Any
|
|
11
|
+
|
|
12
|
+
from rich.console import Console as RichConsole
|
|
13
|
+
from rich.theme import Theme
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from collections.abc import Generator
|
|
17
|
+
|
|
18
|
+
# Semantic color palette — ~35 entries
|
|
19
|
+
_theme = Theme(
|
|
20
|
+
{
|
|
21
|
+
# Primary
|
|
22
|
+
"success": "#2ecc71 bold",
|
|
23
|
+
"error": "#e74c3c bold",
|
|
24
|
+
"warning": "#f39c12 bold",
|
|
25
|
+
"info": "dim",
|
|
26
|
+
# Progress
|
|
27
|
+
"step": "#7c8aff",
|
|
28
|
+
"step.count": "#7c8aff bold",
|
|
29
|
+
"hint": "dim italic",
|
|
30
|
+
"detail": "default",
|
|
31
|
+
# Structure
|
|
32
|
+
"header.rule": "#6366f1",
|
|
33
|
+
"header.title": "#6366f1 bold",
|
|
34
|
+
"banner.border": "#6366f1",
|
|
35
|
+
"banner.text": "bold",
|
|
36
|
+
# State badges
|
|
37
|
+
"badge.open": "#2ecc71",
|
|
38
|
+
"badge.closed": "#95a5a6",
|
|
39
|
+
"badge.in_progress": "#f39c12",
|
|
40
|
+
"badge.active": "#2ecc71",
|
|
41
|
+
"badge.stale": "#e67e22",
|
|
42
|
+
"badge.stale_empty": "#95a5a6",
|
|
43
|
+
"badge.stale_merged": "#9b59b6",
|
|
44
|
+
"badge.stale_remote_gone": "#e74c3c",
|
|
45
|
+
"badge.draft": "#95a5a6 italic",
|
|
46
|
+
"badge.planned": "#3498db",
|
|
47
|
+
"badge.unplanned": "#7f8c8d",
|
|
48
|
+
# Task
|
|
49
|
+
"task.number": "#3498db bold",
|
|
50
|
+
"task.title": "default",
|
|
51
|
+
"task.complexity.easy": "#2ecc71",
|
|
52
|
+
"task.complexity.medium": "#f39c12",
|
|
53
|
+
"task.complexity.complex": "#e74c3c",
|
|
54
|
+
"task.complexity.very_complex": "#e74c3c bold",
|
|
55
|
+
# Git
|
|
56
|
+
"git.branch": "#e67e22",
|
|
57
|
+
"git.commit": "#95a5a6",
|
|
58
|
+
"git.path": "dim",
|
|
59
|
+
"git.conflict": "#e74c3c bold",
|
|
60
|
+
# AI tools
|
|
61
|
+
"ai.claude": "#d97706",
|
|
62
|
+
"ai.copilot": "#6366f1",
|
|
63
|
+
"ai.antigravity-cli": "#3b82f6",
|
|
64
|
+
"ai.codex": "#10b981",
|
|
65
|
+
# Prompts
|
|
66
|
+
"prompt.selected": "#7c8aff bold",
|
|
67
|
+
"prompt.option": "default",
|
|
68
|
+
"prompt.cursor": "#7c8aff bold",
|
|
69
|
+
"prompt.dimmed": "dim",
|
|
70
|
+
# Panels
|
|
71
|
+
"panel.border": "#6366f1",
|
|
72
|
+
"panel.title": "#6366f1 bold",
|
|
73
|
+
# URLs
|
|
74
|
+
"url": "#3498db underline",
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class Console:
|
|
80
|
+
"""Unified CLI output."""
|
|
81
|
+
|
|
82
|
+
# Symbol constants (matching Bash _UI_* constants)
|
|
83
|
+
OK = "\u2713" # ✓
|
|
84
|
+
ERR = "\u2717" # ✗
|
|
85
|
+
WARN = "!" # clean bang
|
|
86
|
+
ARROW = "\u2192" # →
|
|
87
|
+
INFO = "\u00b7" # · subtle dot
|
|
88
|
+
STEP = "\u25b8" # ▸ right triangle
|
|
89
|
+
BULLET = "\u00b7" # ·
|
|
90
|
+
|
|
91
|
+
def __init__(self) -> None:
|
|
92
|
+
self.out = RichConsole(theme=_theme, stderr=False)
|
|
93
|
+
self.err = RichConsole(theme=_theme, stderr=True)
|
|
94
|
+
|
|
95
|
+
# ------------------------------------------------------------------
|
|
96
|
+
# Original methods (unchanged signatures)
|
|
97
|
+
# ------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
def success(self, message: str) -> None:
|
|
100
|
+
"""Green checkmark line to stdout."""
|
|
101
|
+
self.out.print(f" [success]{self.OK}[/] {message}")
|
|
102
|
+
|
|
103
|
+
def error(self, message: str) -> None:
|
|
104
|
+
"""Red error line to stderr."""
|
|
105
|
+
self.err.print(f" [error]{self.ERR} Error:[/] {message}")
|
|
106
|
+
|
|
107
|
+
def warn(self, message: str) -> None:
|
|
108
|
+
"""Yellow warning line to stderr."""
|
|
109
|
+
self.err.print(f" [warning]{self.WARN}[/] {message}")
|
|
110
|
+
|
|
111
|
+
def info(self, message: str) -> None:
|
|
112
|
+
"""Info line to stdout."""
|
|
113
|
+
self.out.print(f" [info]{self.INFO}[/] {message}")
|
|
114
|
+
|
|
115
|
+
def step(self, message: str) -> None:
|
|
116
|
+
"""Step indicator with [●] bullet to stdout."""
|
|
117
|
+
self.out.print(f" [step]{self.STEP}[/] {message}")
|
|
118
|
+
|
|
119
|
+
def step_n(self, n: int, total: int, message: str) -> None:
|
|
120
|
+
"""Numbered step: [n/total] text."""
|
|
121
|
+
self.out.print(f" [step.count]\\[{n}/{total}][/] {message}")
|
|
122
|
+
|
|
123
|
+
def hint(self, message: str) -> None:
|
|
124
|
+
"""Dim hint text with → arrow."""
|
|
125
|
+
self.out.print(f"[hint] {self.ARROW} {message}[/]")
|
|
126
|
+
|
|
127
|
+
def empty(self) -> None:
|
|
128
|
+
"""Print a blank line."""
|
|
129
|
+
self.out.print()
|
|
130
|
+
|
|
131
|
+
def detail(self, message: str) -> None:
|
|
132
|
+
"""Indented detail line (continuation under info/step)."""
|
|
133
|
+
self.out.print(f"[dim] {message}[/]")
|
|
134
|
+
|
|
135
|
+
def raw(self, text: str) -> None:
|
|
136
|
+
"""Print raw text without any formatting or word-wrapping.
|
|
137
|
+
|
|
138
|
+
Uses Python's built-in print() instead of Rich's Console.print()
|
|
139
|
+
to avoid Rich inserting line breaks in JSON output.
|
|
140
|
+
"""
|
|
141
|
+
print(text)
|
|
142
|
+
|
|
143
|
+
def section(self, title: str) -> None:
|
|
144
|
+
"""Bold section heading (minor sub-headings)."""
|
|
145
|
+
self.out.print(f"[header.title]{title}[/]")
|
|
146
|
+
|
|
147
|
+
def header(self, title: str, width: int = 62) -> None:
|
|
148
|
+
"""Bold section heading with ─── Title ──── separator."""
|
|
149
|
+
from rich.rule import Rule
|
|
150
|
+
|
|
151
|
+
self.out.print()
|
|
152
|
+
self.out.print(
|
|
153
|
+
Rule(title=title, style="header.rule", characters="\u2500"),
|
|
154
|
+
)
|
|
155
|
+
self.out.print()
|
|
156
|
+
|
|
157
|
+
def banner(self, message: str, width: int = 62) -> None:
|
|
158
|
+
"""Full-width separator + announcement — now uses a panel."""
|
|
159
|
+
from rich.panel import Panel
|
|
160
|
+
|
|
161
|
+
self.out.print()
|
|
162
|
+
self.out.print(
|
|
163
|
+
Panel(
|
|
164
|
+
f" [banner.text]{message}[/]",
|
|
165
|
+
border_style="banner.border",
|
|
166
|
+
padding=(0, 1),
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
def badge(self, label: str, style: str = "info") -> None:
|
|
171
|
+
"""Inline [ LABEL ] tag (no newline)."""
|
|
172
|
+
self.out.print(f"[{style}]\\[ {label.upper()} ][/]", end="")
|
|
173
|
+
|
|
174
|
+
def plain(self, message: str) -> None:
|
|
175
|
+
"""Plain text to stdout."""
|
|
176
|
+
self.out.print(message, highlight=False)
|
|
177
|
+
|
|
178
|
+
# ------------------------------------------------------------------
|
|
179
|
+
# New methods — Phase 1b
|
|
180
|
+
# ------------------------------------------------------------------
|
|
181
|
+
|
|
182
|
+
@contextlib.contextmanager
|
|
183
|
+
def status(self, message: str) -> Generator[None, None, None]:
|
|
184
|
+
"""Context-manager spinner for long operations.
|
|
185
|
+
|
|
186
|
+
Falls back to a plain info line when not a TTY.
|
|
187
|
+
"""
|
|
188
|
+
if not self.out.is_terminal:
|
|
189
|
+
self.info(message)
|
|
190
|
+
yield
|
|
191
|
+
return
|
|
192
|
+
from rich.status import Status
|
|
193
|
+
|
|
194
|
+
with Status(f" {message}", console=self.out, spinner="dots"):
|
|
195
|
+
yield
|
|
196
|
+
|
|
197
|
+
def panel(
|
|
198
|
+
self,
|
|
199
|
+
content: str,
|
|
200
|
+
title: str | None = None,
|
|
201
|
+
border_style: str = "panel.border",
|
|
202
|
+
) -> None:
|
|
203
|
+
"""Bordered card for summaries."""
|
|
204
|
+
from rich.panel import Panel
|
|
205
|
+
|
|
206
|
+
self.out.print()
|
|
207
|
+
self.out.print(
|
|
208
|
+
Panel(
|
|
209
|
+
content,
|
|
210
|
+
title=f"[panel.title]{title}[/]" if title else None,
|
|
211
|
+
border_style=border_style,
|
|
212
|
+
padding=(1, 2),
|
|
213
|
+
)
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
def rule(self, title: str = "", style: str = "header.rule") -> None:
|
|
217
|
+
"""Horizontal separator."""
|
|
218
|
+
from rich.rule import Rule
|
|
219
|
+
|
|
220
|
+
self.out.print()
|
|
221
|
+
self.out.print(Rule(title=title, style=style, characters="\u2500"))
|
|
222
|
+
|
|
223
|
+
def kv(self, key: str, value: str, key_style: str = "dim") -> None:
|
|
224
|
+
"""Aligned key-value pair for metadata display."""
|
|
225
|
+
self.out.print(f" [{key_style}]{key:<14}[/] {value}")
|
|
226
|
+
|
|
227
|
+
def error_with_fix(
|
|
228
|
+
self,
|
|
229
|
+
msg: str,
|
|
230
|
+
fix: str,
|
|
231
|
+
command: str | None = None,
|
|
232
|
+
) -> None:
|
|
233
|
+
"""Error + suggested fix + optional runnable command."""
|
|
234
|
+
self.error(msg)
|
|
235
|
+
self.hint(fix)
|
|
236
|
+
if command:
|
|
237
|
+
self.out.print(f" [prompt.dimmed]$ {command}[/]")
|
|
238
|
+
|
|
239
|
+
def summary_table(
|
|
240
|
+
self,
|
|
241
|
+
rows: list[tuple[str, str]],
|
|
242
|
+
title: str | None = None,
|
|
243
|
+
) -> None:
|
|
244
|
+
"""Two-column label:value summary table."""
|
|
245
|
+
from rich.table import Table
|
|
246
|
+
|
|
247
|
+
table = Table(
|
|
248
|
+
show_header=False,
|
|
249
|
+
box=None,
|
|
250
|
+
padding=(0, 2),
|
|
251
|
+
title=title,
|
|
252
|
+
title_style="header.title",
|
|
253
|
+
)
|
|
254
|
+
table.add_column("Key", style="dim", no_wrap=True)
|
|
255
|
+
table.add_column("Value")
|
|
256
|
+
for key, value in rows:
|
|
257
|
+
table.add_row(key, value)
|
|
258
|
+
self.out.print(table)
|
|
259
|
+
|
|
260
|
+
def dep_tree(
|
|
261
|
+
self,
|
|
262
|
+
edges: list[tuple[str, str, str]],
|
|
263
|
+
titles: dict[str, str],
|
|
264
|
+
) -> None:
|
|
265
|
+
"""Visual dependency graph using Rich Tree.
|
|
266
|
+
|
|
267
|
+
Args:
|
|
268
|
+
edges: List of (from_id, to_id, reason) tuples.
|
|
269
|
+
titles: Map of issue id to title.
|
|
270
|
+
"""
|
|
271
|
+
from rich.tree import Tree
|
|
272
|
+
|
|
273
|
+
tree = Tree("[header.title]Dependency Graph[/]")
|
|
274
|
+
|
|
275
|
+
# Group edges by 'from' task
|
|
276
|
+
grouped: dict[str, list[tuple[str, str]]] = {}
|
|
277
|
+
for from_id, to_id, reason in edges:
|
|
278
|
+
grouped.setdefault(from_id, []).append((to_id, reason))
|
|
279
|
+
|
|
280
|
+
for from_id, deps in grouped.items():
|
|
281
|
+
from_label = f"[task.number]#{from_id}[/] {titles.get(from_id, '')}"
|
|
282
|
+
branch = tree.add(from_label)
|
|
283
|
+
for to_id, reason in deps:
|
|
284
|
+
to_label = f"[task.number]#{to_id}[/] {titles.get(to_id, '')}"
|
|
285
|
+
if reason:
|
|
286
|
+
to_label += f" [dim]({reason})[/]"
|
|
287
|
+
branch.add(to_label)
|
|
288
|
+
|
|
289
|
+
self.out.print(tree)
|
|
290
|
+
|
|
291
|
+
def markdown(self, text: str) -> None:
|
|
292
|
+
"""Render markdown text."""
|
|
293
|
+
from rich.markdown import Markdown
|
|
294
|
+
|
|
295
|
+
self.out.print(Markdown(text))
|
|
296
|
+
|
|
297
|
+
def badge_str(self, label: str, variant: str = "open") -> str:
|
|
298
|
+
"""Return a styled state badge string for inline use.
|
|
299
|
+
|
|
300
|
+
Variant maps to badge.* theme entries. The label is wrapped in
|
|
301
|
+
literal square brackets, e.g. "[OPEN]" or "[PLANNED]".
|
|
302
|
+
"""
|
|
303
|
+
style = f"badge.{variant}"
|
|
304
|
+
return f"[{style}]\\[{label.upper()}\\][/]"
|
|
305
|
+
|
|
306
|
+
def issue_ref(self, number: str, title: str = "") -> str:
|
|
307
|
+
"""Return a styled #N Title reference string."""
|
|
308
|
+
ref = f"[task.number]#{number}[/]"
|
|
309
|
+
if title:
|
|
310
|
+
ref += f" {title}"
|
|
311
|
+
return ref
|
|
312
|
+
|
|
313
|
+
def git_ref(self, branch: str) -> str:
|
|
314
|
+
"""Return a styled branch name string."""
|
|
315
|
+
return f"[git.branch]{branch}[/]"
|
|
316
|
+
|
|
317
|
+
@contextlib.contextmanager
|
|
318
|
+
def progress(
|
|
319
|
+
self,
|
|
320
|
+
total: int,
|
|
321
|
+
description: str = "",
|
|
322
|
+
) -> Generator[Any, None, None]:
|
|
323
|
+
"""Progress bar for multi-step operations.
|
|
324
|
+
|
|
325
|
+
Falls back to plain text when not a TTY.
|
|
326
|
+
|
|
327
|
+
Usage:
|
|
328
|
+
with console.progress(10, "Processing") as advance:
|
|
329
|
+
for i in range(10):
|
|
330
|
+
do_work()
|
|
331
|
+
advance()
|
|
332
|
+
"""
|
|
333
|
+
if not self.out.is_terminal:
|
|
334
|
+
self.info(description)
|
|
335
|
+
|
|
336
|
+
def _noop() -> None:
|
|
337
|
+
pass
|
|
338
|
+
|
|
339
|
+
yield _noop
|
|
340
|
+
return
|
|
341
|
+
|
|
342
|
+
from rich.progress import (
|
|
343
|
+
BarColumn,
|
|
344
|
+
MofNCompleteColumn,
|
|
345
|
+
Progress,
|
|
346
|
+
TextColumn,
|
|
347
|
+
TimeElapsedColumn,
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
with Progress(
|
|
351
|
+
TextColumn(" {task.description}"),
|
|
352
|
+
BarColumn(),
|
|
353
|
+
MofNCompleteColumn(),
|
|
354
|
+
TimeElapsedColumn(),
|
|
355
|
+
console=self.out,
|
|
356
|
+
) as progress:
|
|
357
|
+
task = progress.add_task(description, total=total)
|
|
358
|
+
|
|
359
|
+
def advance() -> None:
|
|
360
|
+
progress.advance(task)
|
|
361
|
+
|
|
362
|
+
yield advance
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
# Singleton instance for convenience
|
|
366
|
+
console = Console()
|