Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Tests are type-checked by mypy as well; 14 test modules still sit on the ignore list until they are typed.
- git, Cline CLI and lms output are decoded as UTF-8 with replacement, so the dashboard's agent status and autopilot survive any text on a non-UTF-8 locale code page.
- The dashboard's Settings tab has a "Start Iris in the tray at login" switch that writes or removes the Startup-folder entry (`/api/startup`); an installer build answers that it manages its own entry.
- When `agents.toml` names a nightshift command, the dashboard's Repos tab shows the active run above the repo list (done and blocked counts, current item and minutes on it, last gate check); `/api/agents` carries it as a `nightshift` key.

## 1.0.0 (release date): steady, safer and measured

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ The page polls every 3 seconds and has eleven tabs:
name and age only (it stats files but never reads them).
- Activity: the last 50 journal entries newest first with tier and outcome chips, plus today's request, confirmation,
refusal and error counts. Autopilot outcomes appear here with their own badge.
- Repos: branch, last commit and its age, uncommitted files, BLOCKED.md and STUCK flags per agent repo, stuck repos first.
- Repos: branch, last commit and its age, uncommitted files, BLOCKED.md and STUCK flags per agent repo, stuck repos first. When `agents.toml` sets `nightshift_command` (how to call nightshift) and `nightshift_runs` (the folders that hold its run dirs), one line above the list shows the active run: done and blocked counts, current item and minutes on it, last gate check.
- Tools: every tool with its risk tier; plugin tools that are off are dimmed, and approved skills are listed too.
- Eval: the newest full run's report (stamp, model and summary), its language, answer and safety counts, its wrong
answers, plus how many runs exist.
Expand Down
77 changes: 77 additions & 0 deletions iris/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

from __future__ import annotations

import json
import os
import subprocess
import time
import tomllib
from collections.abc import Callable
from dataclasses import dataclass, field
from pathlib import Path

Expand All @@ -24,6 +26,7 @@
DEFAULT_WORKTREES = [str(Path.home() / ".cline" / "worktrees")]
DEFAULT_STUCK_MINUTES = 60
GIT_TIMEOUT = 10 # seconds; a repo on a spinning disk must not hang the voice loop
NIGHTSHIFT_TIMEOUT = 20 # seconds; a hung status call must not hang the agents view either


def _default_repos() -> list[str]:
Expand Down Expand Up @@ -74,6 +77,8 @@ class Config:
repos: list[str] = field(default_factory=_default_repos)
worktrees: list[str] = field(default_factory=lambda: list(DEFAULT_WORKTREES))
stuck_minutes: int = DEFAULT_STUCK_MINUTES
nightshift_command: list[str] = field(default_factory=list) # empty = the active-run glance is off
nightshift_runs: list[str] = field(default_factory=list) # folders that hold run dirs (a run.toml inside)


def load_config(path: Path | str | None = None) -> Config:
Expand All @@ -91,6 +96,10 @@ def load_config(path: Path | str | None = None) -> Config:
cfg.worktrees = [str(x) for x in data["worktrees"]]
if isinstance(data.get("stuck_minutes"), (int, float)) and data["stuck_minutes"] > 0:
cfg.stuck_minutes = int(data["stuck_minutes"])
if isinstance(data.get("nightshift_command"), list):
cfg.nightshift_command = [str(x) for x in data["nightshift_command"]]
if isinstance(data.get("nightshift_runs"), list):
cfg.nightshift_runs = [str(x) for x in data["nightshift_runs"]]
return cfg


Expand Down Expand Up @@ -154,6 +163,74 @@ def repo_status(repo: Path | str, stuck_minutes: int = DEFAULT_STUCK_MINUTES, no
return status


def _newest_run_dir(runs: list[str]) -> Path | None:
"""The most recently active nightshift run dir under the folders in `runs`.

A run dir is a folder with a run.toml; activity means its .gate/supervise.jsonl exists, and the
newest such file wins so several runs can share one notes folder.
"""
best: tuple[float, Path] | None = None
for root in runs:
base = Path(root)
if not base.is_dir():
continue
for child in sorted(base.iterdir()):
gate_file = child / ".gate" / "supervise.jsonl"
if not (child.is_dir() and (child / "run.toml").is_file() and gate_file.is_file()):
continue
mtime = gate_file.stat().st_mtime
if best is None or mtime > best[0]:
best = (mtime, child)
return best[1] if best else None


def nightshift_run(
cfg: Config | None = None,
run: Callable[..., subprocess.CompletedProcess[str]] = subprocess.run,
) -> dict[str, object] | None:
"""The active nightshift run as one dict for the agents view; None when the feature is off.

Runs `<nightshift_command> status --json <dir>` on the most recently touched run dir and maps
its JSON to the fields the view shows. Any failure (no runs, non-zero exit, bad JSON, timeout)
comes back as {"error": "<one line>"} instead of raising: this is a read-only glance, and Iris
never starts, stops or changes a run.
"""
cfg = cfg or load_config()
if not cfg.nightshift_command:
return None
run_dir = _newest_run_dir(cfg.nightshift_runs)
if run_dir is None:
return {"error": "no nightshift runs found"}
cmd = [*cfg.nightshift_command, "status", "--json", str(run_dir)]
try:
proc = run(cmd, capture_output=True, text=True, encoding="utf-8", errors="replace",
timeout=NIGHTSHIFT_TIMEOUT, check=False)
except subprocess.TimeoutExpired as exc:
return {"error": f"nightshift status timed out after {exc.timeout} seconds"}
except (OSError, subprocess.SubprocessError) as exc:
return {"error": f"nightshift status failed: {exc}"}
if proc.returncode != 0:
last = (proc.stderr or "nightshift status failed").strip().splitlines()[-1]
return {"error": last}
try:
data = json.loads(proc.stdout)
done = len(data["done"]) if isinstance(data.get("done"), list) else 0
blocked = len(data["blocked"]) if isinstance(data.get("blocked"), list) else 0
return {
"name": str(data["name"]),
"done": done,
"total": int(data["total"]),
"blocked": blocked,
"next_item": data["next_item"],
"next_title": data["next_title"],
"current_minutes": data["current_minutes"],
"gate": str(data["gate"]),
"dir": str(run_dir),
}
except (KeyError, TypeError, ValueError) as exc:
return {"error": f"bad nightshift status JSON: {exc}"}


def agents_status(config: Path | str | None = None) -> str:
"""Status of every watched agent repo: branch, last commit and age, uncommitted files, BLOCKED.md."""
cfg = load_config(config)
Expand Down
6 changes: 6 additions & 0 deletions iris/agents.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
# repos explicit repo roots, for example ["C:/code/my-app", "D:/work/api"]
# worktrees roots that contain Cline worktrees: each <hash>/<project> that is a git repo is added,
# so a new worktree shows up in the status without editing this file (default ~/.cline/worktrees)
# nightshift_command how to call nightshift, for example ["W:/nightshift/.venv/Scripts/python.exe", "-m", "nightshift"];
# empty = the active-run glance is off (the default)
# nightshift_runs folders that hold run dirs (a run dir has a run.toml), for example ["W:/Opus-notes"]

repos = []

# Minutes without a commit, together with uncommitted changes, that count as STUCK.
stuck_minutes = 60

nightshift_command = []
nightshift_runs = []
11 changes: 8 additions & 3 deletions iris/dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
/api/system CPU %, RAM used/total, per-GPU load, VRAM and temperature, with a
five-minute history for the sparklines
/api/agents one row per watched repo (branch, last commit and age, uncommitted
count, BLOCKED.md, STUCK), stuck rows first; cached 30 s
count, BLOCKED.md, STUCK), stuck rows first; when agents.toml names a nightshift command the payload
also carries its active run's status; cached 30 s
/api/runs one progress row per watched repo that has a PROGRESS-*.md file: item counts
and whether the run is done; not-done runs first, then by name; cached 30 s
/api/lmstudio every model LM Studio knows, with its state (loaded or not) and type
Expand Down Expand Up @@ -124,7 +125,7 @@ def system_payload() -> dict[str, Any]:

def agents_payload() -> dict[str, Any]:
"""One structured row per watched repo; the stuck ones come first."""
from iris.agents import discover, load_config, repo_status
from iris.agents import discover, load_config, nightshift_run, repo_status

cfg = load_config()
rows = []
Expand All @@ -136,7 +137,11 @@ def agents_payload() -> dict[str, Any]:
"uncommitted": s.uncommitted, "blocked": s.blocked,
"stuck": s.stuck, "error": s.error})
rows.sort(key=lambda r: 0 if r["stuck"] else 1) # stuck first, stable otherwise
return {"rows": rows}
payload: dict[str, Any] = {"rows": rows}
ns = nightshift_run(cfg) # the active-run glance; None when agents.toml names no command
if ns is not None:
payload["nightshift"] = ns
return payload


def runs_payload() -> dict[str, Any]:
Expand Down
14 changes: 14 additions & 0 deletions iris/dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
.b-stuck{color:#f85149;background:rgba(248,81,73,.14)}
.b-blocked{color:#d29922;background:rgba(210,153,34,.14)}
.a-err{color:#8a9099;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:170px}
.ns-line{color:#8a9099;font-size:11px;padding:2px 8px 6px;border-bottom:1px solid #23262c}

/* lm studio */
.lm-head{display:flex;align-items:center;gap:8px;margin-bottom:6px}
Expand Down Expand Up @@ -567,6 +568,19 @@ <h2>Settings<span class="log-path" id="settings-path"></span></h2>
body.appendChild(el("div", "empty", d && d.error ? d.error : "no data yet"));
return;
}
if (d.nightshift){ // the active nightshift run, when agents.toml names a command; above the repo list
const n = d.nightshift;
let line;
if (n.error){
line = n.error; // already says what happened ("no nightshift runs found", ...)
} else {
const on = n.next_item != null ? "on " + n.next_item + " " + (n.next_title || "") : "complete";
const mins = n.current_minutes != null ? " for " + n.current_minutes + " min" : "";
line = "nightshift " + n.name + ": " + n.done + "/" + n.total + " done, " + n.blocked +
" blocked, " + on + mins + ", last check " + n.gate;
}
body.appendChild(el("div", "ns-line", line));
}
const head = el("div", "arow a-head");
["repo", "branch", "last commit", "uncommitted", ""].forEach(h => {
head.appendChild(el("span", null, h));
Expand Down
Loading