@seanyao/roll 3.608.1 → 3.610.1

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.
package/lib/i18n.sh DELETED
@@ -1,211 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Roll i18n engine — US-I18N-001.
3
- #
4
- # Provides:
5
- # _i18n_resolve_lang — resolve user's language per precedence
6
- # msg <key> [args...] — look up message catalog with EN fallback
7
- # _i18n_set <lang> <key> <value> — fill the catalog (used by modules)
8
- #
9
- # Storage is bash 3.2-compatible (macOS default ships 3.2): each catalog entry
10
- # is held in a plain variable named `MSG_<LANG>_<key>`, looked up via indirect
11
- # reference. Bash 4 assoc arrays would be cleaner but break macOS default bash
12
- # (see AGENTS.md §4: single bash script, no runtime).
13
- #
14
- # Precedence: ROLL_LANG env > ~/.roll/config.yaml `lang` > LC_ALL > LANG
15
- # > (macOS) AppleLanguages > 'en'.
16
- # Decision: value starting with `zh` → "zh", everything else → "en".
17
-
18
- # Fill the catalog. Modules call this at source-time:
19
- # _i18n_set en hello "Hello, %s!"
20
- # _i18n_set zh hello "你好,%s!"
21
- # No subshell forks: lang uppercasing uses a case statement (bash 3.2-safe;
22
- # ${var^^} requires bash 4+), key sanitization uses inline param-expansion.
23
- _i18n_set() {
24
- local lang="$1" key="$2" val="$3"
25
- local upper safe varname
26
- case "$lang" in
27
- en|EN) upper=EN ;;
28
- zh|ZH) upper=ZH ;;
29
- *) upper="$(printf '%s' "$lang" | tr '[:lower:]' '[:upper:]')" ;;
30
- esac
31
- safe="${key//[^A-Za-z0-9_]/_}" # inline param-expansion — no subshell fork
32
- varname="MSG_${upper}_${safe}"
33
- printf -v "$varname" '%s' "$val"
34
- export "$varname"
35
- }
36
-
37
- # Decide "zh" or "en" from a free-form locale string.
38
- _i18n_classify() {
39
- case "${1:-}" in
40
- zh*) echo zh ;;
41
- *) echo en ;;
42
- esac
43
- }
44
-
45
- # Resolve the active language. Caches in ROLL_LANG_RESOLVED so later calls are
46
- # free.
47
- _i18n_resolve_lang() {
48
- if [[ -n "${ROLL_LANG_RESOLVED:-}" ]]; then
49
- echo "$ROLL_LANG_RESOLVED"
50
- return
51
- fi
52
-
53
- local lang=""
54
-
55
- if [[ -n "${ROLL_LANG:-}" ]]; then
56
- lang=$(_i18n_classify "$ROLL_LANG")
57
- fi
58
-
59
- if [[ -z "$lang" && -n "${ROLL_CONFIG:-}" && -f "${ROLL_CONFIG}" ]]; then
60
- local cfg
61
- cfg=$(grep -E '^lang:' "$ROLL_CONFIG" 2>/dev/null | head -1 \
62
- | sed 's/^lang:[[:space:]]*//' \
63
- | sed 's/[[:space:]]*#.*$//' \
64
- | sed 's/[[:space:]]*$//')
65
- [[ -n "$cfg" ]] && lang=$(_i18n_classify "$cfg")
66
- fi
67
-
68
- if [[ -z "$lang" && -n "${LC_ALL:-}" ]]; then
69
- lang=$(_i18n_classify "$LC_ALL")
70
- fi
71
-
72
- if [[ -z "$lang" && -n "${LANG:-}" ]]; then
73
- lang=$(_i18n_classify "$LANG")
74
- fi
75
-
76
- if [[ -z "$lang" ]] && command -v defaults >/dev/null 2>&1; then
77
- local apple
78
- apple=$(defaults read -g AppleLanguages 2>/dev/null | head -2 | tail -1 \
79
- | tr -d ' ",()' | head -1 || true)
80
- [[ -n "$apple" ]] && lang=$(_i18n_classify "$apple")
81
- fi
82
-
83
- [[ -z "$lang" ]] && lang="en"
84
-
85
- ROLL_LANG_RESOLVED="$lang"
86
- echo "$lang"
87
- }
88
-
89
- # Look up message catalog entry. Falls back to EN, then to the key itself so
90
- # missing translations stay visible without crashing the caller.
91
- msg() {
92
- local key="$1"; shift || true
93
- local lang safe
94
- # FIX: avoid subshell forks — check cached value first, inline key sanitize
95
- if [[ -n "${ROLL_LANG_RESOLVED:-}" ]]; then
96
- lang="$ROLL_LANG_RESOLVED"
97
- else
98
- lang=$(_i18n_resolve_lang)
99
- fi
100
- safe="${key//[^A-Za-z0-9_]/_}" # FIX: inline — no subshell fork
101
-
102
- local zh_var="MSG_ZH_${safe}"
103
- local en_var="MSG_EN_${safe}"
104
- local tmpl=""
105
-
106
- if [[ "$lang" == "zh" && -n "${!zh_var:-}" ]]; then
107
- tmpl="${!zh_var}"
108
- elif [[ -n "${!en_var:-}" ]]; then
109
- tmpl="${!en_var}"
110
- else
111
- tmpl="$key"
112
- fi
113
-
114
- # shellcheck disable=SC2059 — template comes from our own catalog
115
- printf "$tmpl" "$@"
116
- echo
117
- }
118
-
119
- # Look up message catalog entry with an explicit language, bypassing ROLL_LANG env.
120
- # Usage: msg_lang <lang> <key> [printf-args...]
121
- # Useful when the caller tracks language independently of the process env (e.g.
122
- # _loop_schedule_desc passes an explicit lang= parameter).
123
- msg_lang() {
124
- local lang="$1" key="$2"; shift 2 || true
125
- local upper safe varname tmpl
126
- case "$lang" in
127
- en|EN) upper=EN ;;
128
- zh|ZH) upper=ZH ;;
129
- *) upper="$(printf '%s' "$lang" | tr '[:lower:]' '[:upper:]')" ;;
130
- esac
131
- safe="${key//[^A-Za-z0-9_]/_}"
132
- varname="MSG_${upper}_${safe}"
133
- tmpl="${!varname:-}"
134
- if [[ -z "$tmpl" ]]; then
135
- varname="MSG_EN_${safe}"
136
- tmpl="${!varname:-$key}"
137
- fi
138
- # shellcheck disable=SC2059 — template comes from our own catalog
139
- printf "$tmpl" "$@"
140
- echo
141
- }
142
-
143
- # ── CJK display-width helpers (US-I18N-006) ──────────────────────────────
144
- # Compute visual display width of a string (CJK fullwidth = 2 cells,
145
- # ASCII = 1 cell). Delegates to python3 which is already a dependency.
146
- _strw() {
147
- python3 -c "
148
- import sys
149
- from unicodedata import east_asian_width
150
- s = sys.argv[1]
151
- w = sum(2 if east_asian_width(c) in ('F','W') else 1 for c in s)
152
- print(w)
153
- " "$1"
154
- }
155
-
156
- # Left-pad a string to a target visual display width (CJK-aware).
157
- _pad_l() {
158
- local s="$1" target="$2"
159
- local sw
160
- sw=$(_strw "$s")
161
- local pad=$((target - sw))
162
- if ((pad <= 0)); then
163
- printf '%s' "$s"
164
- else
165
- printf '%s%*s' "$s" "$pad" ''
166
- fi
167
- }
168
-
169
- # Right-pad a string to a target visual display width (CJK-aware).
170
- _pad_r() {
171
- local s="$1" target="$2"
172
- local sw
173
- sw=$(_strw "$s")
174
- local pad=$((target - sw))
175
- if ((pad <= 0)); then
176
- printf '%s' "$s"
177
- else
178
- printf '%*s%s' "$pad" '' "$s"
179
- fi
180
- }
181
-
182
- # ── Load per-command message catalogs (US-I18N-002) ──
183
- # Source all lib/i18n/*.sh files (skip self). Called once at bin/roll startup.
184
- _i18n_load_catalogs() {
185
- # FIX: guard — skip re-load when catalogs already loaded in this shell.
186
- # Each bats test sources bin/roll in its own subshell so the guard resets
187
- # automatically; but within a single shell (e.g. integration tests) this
188
- # prevents 2.6s of catalog I/O on every subsequent source.
189
- [[ -n "${_I18N_CATALOGS_LOADED:-}" ]] && return 0
190
- local i18n_dir
191
- i18n_dir="$(dirname "${BASH_SOURCE[0]:-$0}")/i18n"
192
- if [[ -d "$i18n_dir" ]]; then
193
- local f
194
- # Load per-command catalogs
195
- for f in "$i18n_dir"/*.sh; do
196
- [[ -f "$f" ]] || continue
197
- # shellcheck source=/dev/null
198
- source "$f"
199
- done
200
- # Load skill catalogs (US-I18N-003)
201
- if [[ -d "$i18n_dir/skills" ]]; then
202
- for f in "$i18n_dir/skills"/*.sh; do
203
- [[ -f "$f" ]] || continue
204
- # shellcheck source=/dev/null
205
- source "$f"
206
- done
207
- fi
208
- fi
209
- _I18N_CATALOGS_LOADED=1
210
- }
211
- _i18n_load_catalogs
@@ -1,393 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Render a one-cycle exit summary block for the loop's .command window (US-LOOP-040).
3
-
4
- When a `roll loop` cycle ends, the macOS `.command` Terminal window that was
5
- attached to the tmux session is left showing only a `press enter to close`
6
- prompt. The full Cycle Phase Breakdown / runs.jsonl data already exists on disk
7
- but the user has to scroll back through tmux scrollback or open
8
- ``~/.shared/roll/loop/cron-<slug>.log`` to see what the cycle did.
9
-
10
- This helper renders a compact ``─── Cycle <CYCLE_ID> Summary ───`` block to
11
- stdout, consumed by the ``.command`` shell *before* the `press enter` prompt.
12
- It is a pure read-side view: it never writes new files and never mutates loop
13
- state.
14
-
15
- Five signals (per the US-LOOP-040 issue):
16
-
17
- 1. result — runs.jsonl latest row's ``status`` + ``built[]`` + ``tcr_count``
18
- (idle cycle → ``idle: no story picked``)
19
- 2. ci — newest ``ci`` event outcome from events.ndjson tail
20
- (``ok``→green, ``red``→red, ``heal-attempting`` passthrough,
21
- no event → ``ci: n/a``)
22
- 3. todo — count of ``📋 Todo`` lines in .roll/backlog.md
23
- 4. phases — runs.jsonl ``phases`` map, top 5 by duration desc
24
- 5. alerts — raw failure / alert text placeholder
25
-
26
- US-LOOP-041 layers failure / alert *highlighting* on top of the US-LOOP-040
27
- renderer. The relevant signal lines are flagged with a severity prefix and
28
- ANSI colour:
29
-
30
- * RED + ``✗`` — runs.jsonl ``status`` is ``failed`` / ``aborted``; the latest
31
- ``ci`` outcome is ``red``; or the events tail has a ``cycle_end`` whose
32
- outcome is not ``ok`` / ``idle``.
33
- * YELLOW + ``⚠`` — latest ``ci`` outcome is ``heal-attempting``; an
34
- ``ALERT-<slug>.md`` exists and is non-empty; or ``tcr_count == 0`` while
35
- ``built[]`` is non-empty (suspected zero-diff).
36
- * default colour, no prefix — a fully green cycle (built/idle + ci green +
37
- no alert).
38
-
39
- ANSI escapes are only emitted when stdout is a TTY (``sys.stdout.isatty()``)
40
- and ``NO_COLOR`` is unset (see https://no-color.org). Pipes, redirects and
41
- test captures get plain text — no escape codes are written.
42
-
43
- Data-source priority: runs.jsonl latest matching row > events.ndjson tail >
44
- fall back to the cron log's last 30 lines. Any missing source degrades
45
- silently — the renderer never errors and never blocks `press enter`.
46
-
47
- When no usable data exists at all (idle/aborted early-exit, runs.jsonl not yet
48
- flushed) it prints a single
49
- ``(summary unavailable — see log: <cron-log>)`` line instead.
50
-
51
- Invocation::
52
-
53
- python3 loop-exit-summary.py \
54
- --runs <runs.jsonl> \
55
- --events <events.ndjson> \
56
- --backlog <.roll/backlog.md> \
57
- --cron-log <cron-<slug>.log> \
58
- --alert <ALERT-<slug>.md> \
59
- [--cycle-id <id>] [--color {auto,always,never}]
60
-
61
- All paths are optional; a missing / unreadable file is treated as absent.
62
- """
63
-
64
- from __future__ import annotations
65
-
66
- import argparse
67
- import json
68
- import os
69
- import sys
70
- from typing import Any, Dict, List, Optional
71
-
72
-
73
- def _read_last_json_line(path: Optional[str], cycle_id: str = "") -> Optional[Dict[str, Any]]:
74
- """Return the last well-formed JSON object from a .jsonl file.
75
-
76
- When ``cycle_id`` is given, prefer the last row whose ``cycle_id`` matches;
77
- otherwise fall back to the last parseable row. Returns None when the file
78
- is absent, empty, or has no parseable rows.
79
- """
80
- if not path or not os.path.isfile(path):
81
- return None
82
- last: Optional[Dict[str, Any]] = None
83
- matched: Optional[Dict[str, Any]] = None
84
- try:
85
- with open(path, "r", encoding="utf-8", errors="replace") as fh:
86
- for line in fh:
87
- line = line.strip()
88
- if not line:
89
- continue
90
- try:
91
- obj = json.loads(line)
92
- except (ValueError, TypeError):
93
- continue
94
- if not isinstance(obj, dict):
95
- continue
96
- last = obj
97
- if cycle_id and obj.get("cycle_id") == cycle_id:
98
- matched = obj
99
- except OSError:
100
- return None
101
- return matched if matched is not None else last
102
-
103
-
104
- def _read_json_lines(path: Optional[str]) -> List[Dict[str, Any]]:
105
- """Return all well-formed JSON objects from a .ndjson file (in order)."""
106
- out: List[Dict[str, Any]] = []
107
- if not path or not os.path.isfile(path):
108
- return out
109
- try:
110
- with open(path, "r", encoding="utf-8", errors="replace") as fh:
111
- for line in fh:
112
- line = line.strip()
113
- if not line:
114
- continue
115
- try:
116
- obj = json.loads(line)
117
- except (ValueError, TypeError):
118
- continue
119
- if isinstance(obj, dict):
120
- out.append(obj)
121
- except OSError:
122
- return out
123
- return out
124
-
125
-
126
- def _latest_ci_outcome(events: List[Dict[str, Any]]) -> Optional[str]:
127
- """Newest ``ci`` event outcome from an events stream, or None."""
128
- for ev in reversed(events):
129
- if ev.get("stage") == "ci":
130
- outcome = ev.get("outcome")
131
- if outcome:
132
- return str(outcome)
133
- return None
134
-
135
-
136
- def _latest_cycle_end_outcome(events: List[Dict[str, Any]]) -> Optional[str]:
137
- """Newest ``cycle_end`` event outcome from an events stream, or None."""
138
- for ev in reversed(events):
139
- if ev.get("stage") == "cycle_end":
140
- outcome = ev.get("outcome")
141
- if outcome:
142
- return str(outcome)
143
- return None
144
-
145
-
146
- def _alert_active(path: Optional[str]) -> bool:
147
- """True when an ALERT-<slug>.md file exists and has non-whitespace content."""
148
- if not path or not os.path.isfile(path):
149
- return False
150
- try:
151
- with open(path, "r", encoding="utf-8", errors="replace") as fh:
152
- return bool(fh.read().strip())
153
- except OSError:
154
- return False
155
-
156
-
157
- # ── ANSI colouring (US-LOOP-041) ─────────────────────────────────────────────
158
- # Severity ranks: 0 = none/green, 1 = warn (yellow), 2 = fail (red).
159
- _SEV_NONE = 0
160
- _SEV_WARN = 1
161
- _SEV_FAIL = 2
162
-
163
- _ANSI = {_SEV_WARN: "\033[33m", _SEV_FAIL: "\033[31m"}
164
- _ANSI_RESET = "\033[0m"
165
- _PREFIX = {_SEV_NONE: "", _SEV_WARN: "⚠ ", _SEV_FAIL: "✗ "}
166
-
167
-
168
- def _color_enabled(mode: str) -> bool:
169
- """Decide whether ANSI escapes should be emitted.
170
-
171
- ``always`` forces colour, ``never`` forces plain text, ``auto`` (default)
172
- honours NO_COLOR (https://no-color.org) and only colours a real TTY.
173
- """
174
- if mode == "always":
175
- return True
176
- if mode == "never":
177
- return False
178
- if os.environ.get("NO_COLOR") is not None:
179
- return False
180
- try:
181
- return bool(sys.stdout.isatty())
182
- except (ValueError, AttributeError):
183
- return False
184
-
185
-
186
- def _decorate(text: str, sev: int, color: bool) -> str:
187
- """Apply severity prefix + (optional) ANSI colour to a single line.
188
-
189
- The leading indentation is preserved; the prefix and colour wrap only the
190
- non-indented payload so columns still line up.
191
- """
192
- if sev == _SEV_NONE:
193
- return text
194
- stripped = text.lstrip(" ")
195
- indent = text[: len(text) - len(stripped)]
196
- payload = _PREFIX[sev] + stripped
197
- if color:
198
- payload = _ANSI[sev] + payload + _ANSI_RESET
199
- return indent + payload
200
-
201
-
202
- def _count_todo(path: Optional[str]) -> Optional[int]:
203
- """Count lines bearing the 📋 Todo marker in backlog.md. None if absent."""
204
- if not path or not os.path.isfile(path):
205
- return None
206
- count = 0
207
- try:
208
- with open(path, "r", encoding="utf-8", errors="replace") as fh:
209
- for line in fh:
210
- if "📋" in line and "Todo" in line:
211
- count += 1
212
- except OSError:
213
- return None
214
- return count
215
-
216
-
217
- def _tail_lines(path: Optional[str], n: int) -> List[str]:
218
- """Last ``n`` non-empty lines of a text file, or [] when absent."""
219
- if not path or not os.path.isfile(path):
220
- return []
221
- try:
222
- with open(path, "r", encoding="utf-8", errors="replace") as fh:
223
- lines = [ln.rstrip("\n") for ln in fh]
224
- except OSError:
225
- return []
226
- return lines[-n:]
227
-
228
-
229
- def _fmt_ci(outcome: Optional[str]) -> str:
230
- if outcome is None:
231
- return "ci: n/a"
232
- mapping = {"ok": "green", "green": "green", "red": "red",
233
- "heal-attempting": "heal-attempting"}
234
- return "ci: " + mapping.get(outcome, outcome)
235
-
236
-
237
- def _fmt_result(row: Dict[str, Any]) -> str:
238
- status = row.get("status", "")
239
- built = row.get("built") or []
240
- tcr = row.get("tcr_count", 0)
241
- if status == "idle" or (not built and status in ("", "idle")):
242
- return "idle: no story picked"
243
- if built:
244
- built_str = " ".join(str(b) for b in built)
245
- return "built: {0} · tcr commits: {1}".format(built_str, tcr)
246
- # non-idle terminal with no built[] (failed/aborted/blocked/orphan)
247
- return "{0} · tcr commits: {1}".format(status or "unknown", tcr)
248
-
249
-
250
- def _fmt_phases(phases: Dict[str, Any], limit: int = 5) -> List[str]:
251
- rows: List[tuple] = []
252
- for name, dur in phases.items():
253
- try:
254
- rows.append((int(dur), str(name)))
255
- except (ValueError, TypeError):
256
- continue
257
- rows.sort(key=lambda r: (-r[0], r[1]))
258
- out = []
259
- for dur, name in rows[:limit]:
260
- out.append(" {0:<22} {1:>5}s".format(name, dur))
261
- return out
262
-
263
-
264
- def _result_severity(row: Dict[str, Any]) -> int:
265
- """Severity for the result line (US-LOOP-041)."""
266
- status = str(row.get("status", ""))
267
- if status in ("failed", "aborted"):
268
- return _SEV_FAIL
269
- built = row.get("built") or []
270
- tcr = row.get("tcr_count", 0)
271
- if built and tcr == 0: # suspected zero-diff: built something but no commit
272
- return _SEV_WARN
273
- return _SEV_NONE
274
-
275
-
276
- def _ci_severity(outcome: Optional[str]) -> int:
277
- """Severity for the ci line (US-LOOP-041)."""
278
- if outcome == "red":
279
- return _SEV_FAIL
280
- if outcome == "heal-attempting":
281
- return _SEV_WARN
282
- return _SEV_NONE
283
-
284
-
285
- def render(runs: Optional[str], events: Optional[str], backlog: Optional[str],
286
- cron_log: Optional[str], cycle_id: str = "",
287
- alert: Optional[str] = None, color: bool = False) -> str:
288
- """Build the summary block as a string.
289
-
290
- ``color`` toggles ANSI escapes; severity prefixes (``✗`` / ``⚠``) are
291
- always applied to flagged lines regardless of ``color`` (US-LOOP-041).
292
- """
293
- row = _read_last_json_line(runs, cycle_id)
294
- ev_list = _read_json_lines(events)
295
- ci_outcome = _latest_ci_outcome(ev_list)
296
- cycle_end_outcome = _latest_cycle_end_outcome(ev_list)
297
- alert_on = _alert_active(alert)
298
- todo = _count_todo(backlog)
299
-
300
- # Source priority: a usable runs.jsonl row is the primary feed. With no
301
- # row AND no events, fall back to the cron log's tail; if even that is
302
- # empty, emit the single "unavailable" placeholder line.
303
- have_primary = row is not None
304
- have_events = bool(ev_list)
305
-
306
- cid = cycle_id or (row.get("cycle_id") if row else "") or "unknown"
307
- lines: List[str] = []
308
- title = "─── Cycle {0} Summary ───".format(cid)
309
-
310
- if not have_primary and not have_events:
311
- tail = _tail_lines(cron_log, 30)
312
- if not tail:
313
- log_hint = cron_log or "~/.shared/roll/loop/cron-<slug>.log"
314
- return "(summary unavailable — see log: {0})".format(log_hint)
315
- # Degraded view: header + raw cron tail so the user still sees output.
316
- lines.append(title)
317
- lines.append(" (runs.jsonl + events unavailable — showing cron log tail)")
318
- for ln in tail:
319
- lines.append(" " + ln)
320
- return "\n".join(lines)
321
-
322
- lines.append(title)
323
-
324
- # cycle_end fail severity applies to the result line when it's worse than
325
- # what the runs.jsonl status alone implies.
326
- cycle_end_sev = _SEV_NONE
327
- if cycle_end_outcome is not None and cycle_end_outcome not in ("ok", "idle"):
328
- cycle_end_sev = _SEV_FAIL
329
-
330
- # 1. result
331
- if row is not None:
332
- result_sev = max(_result_severity(row), cycle_end_sev)
333
- lines.append(_decorate(" " + _fmt_result(row), result_sev, color))
334
- else:
335
- lines.append(_decorate(" result: n/a", cycle_end_sev, color))
336
-
337
- # 2. ci
338
- lines.append(_decorate(" " + _fmt_ci(ci_outcome),
339
- _ci_severity(ci_outcome), color))
340
-
341
- # 3. todo
342
- if todo is not None:
343
- lines.append(" todo remaining: {0}".format(todo))
344
- else:
345
- lines.append(" todo remaining: n/a")
346
-
347
- # 4. phases (top 5 by duration desc)
348
- phases = (row.get("phases") if row else None) or {}
349
- if isinstance(phases, dict) and phases:
350
- phase_rows = _fmt_phases(phases)
351
- if phase_rows:
352
- lines.append(" phases (top 5 by time):")
353
- lines.extend(phase_rows)
354
-
355
- # 5. alerts / failure highlight (US-LOOP-041)
356
- alerts = (row.get("alerts") if row else None) or []
357
- if isinstance(alerts, list) and alerts:
358
- lines.append(_decorate(" alerts:", _SEV_FAIL, color))
359
- for a in alerts:
360
- lines.append(_decorate(" " + str(a), _SEV_FAIL, color))
361
- if alert_on:
362
- lines.append(_decorate(" alert: ALERT file active — see log",
363
- _SEV_WARN, color))
364
-
365
- return "\n".join(lines)
366
-
367
-
368
- def main(argv: Optional[List[str]] = None) -> int:
369
- parser = argparse.ArgumentParser(
370
- description="Render a loop cycle exit summary block.")
371
- parser.add_argument("--runs", default=None, help="path to runs.jsonl")
372
- parser.add_argument("--events", default=None, help="path to events.ndjson")
373
- parser.add_argument("--backlog", default=None, help="path to .roll/backlog.md")
374
- parser.add_argument("--cron-log", default=None, help="path to cron-<slug>.log")
375
- parser.add_argument("--cycle-id", default="", help="cycle id to prefer")
376
- parser.add_argument("--alert", default=None, help="path to ALERT-<slug>.md")
377
- parser.add_argument("--color", choices=("auto", "always", "never"),
378
- default="auto", help="ANSI colour mode (default: auto)")
379
- args = parser.parse_args(argv)
380
-
381
- try:
382
- color = _color_enabled(args.color)
383
- out = render(args.runs, args.events, args.backlog,
384
- args.cron_log, args.cycle_id,
385
- alert=args.alert, color=color)
386
- except Exception: # noqa: BLE001 — silent fallback per AC: never error
387
- return 0
388
- sys.stdout.write(out + "\n")
389
- return 0
390
-
391
-
392
- if __name__ == "__main__":
393
- sys.exit(main())