Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(agentic-ide): every connected coding CLI resumes its own conversation

rubenluetke10-beepe0a932df682a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 202d824e42..2e739ad021 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,8 +9,34 @@ versioning per [SemVer](https://semver.org/).
## [Unreleased]
+### Added
+
+- **Grok Build in the Open-beside menu.** The official `grok` CLI is now a
+ workspace terminal like Claude Code and Codex: pick it when splitting a
+ pane, resume the same conversation, and sign in through SuperGrok or
+ X Premium+. The xAI API-key card stays a separate thing.
+
### Fixed
+- **A web-searched answer in a live call is spoken to the end.** Gemini Live
+ closes every tool call with an "interrupted" edge before its turn boundary;
+ that edge wiped the evidence the boundary guard needed, so every search
+ looked like a mute provider, the retry it triggered cut the answer already
+ streaming ("… dass sie ihre Plattformen" — end of reply), and the model's
+ second answer was thrown away as a phantom. Both halves of the tool boundary
+ are now recognized and withheld.
+- **A Gemini brain that cannot create a context cache stops paying for the
+ attempt on every call.** A free-tier key (no cache storage) or a Vertex route
+ without default credentials failed the cache create ~0.7 s per call, four
+ times inside one delegated voice turn; a failure now holds for ten minutes.
+- **Every connected coding CLI resumes its conversation, not only Claude Code
+ and Codex.** Kimi Code's current generation files its sessions under
+ `wd_<folder>` buckets with the folder recorded inside each session; the
+ Agentic IDE only knew the previous generation's MD5 folders, so a Kimi pane
+ always came back empty. Both layouts are read now. Grok Build and Kimi Code
+ also write a session file the moment a pane opens, so a pane that was never
+ prompted is no longer "resumed" into an empty conversation — a real user
+ turn is what counts.
- **Dictation delivers its text about as fast after a long recording as after
a short one.** The final read used to start only after the key was released
and work through the recording one window at a time, so a one-minute
@@ -23,6 +49,13 @@ versioning per [SemVer](https://semver.org/).
upload is now cut to half a second before it is sent, a transcript that ends
well before your speech does gets only its missing tail read back in, and
a hardware overflow on the microphone is counted as the real loss it is.
+- **The local recognizer says when it cannot reach your GPU — and fixes it
+ from inside the app.** On a desktop without the CUDA runtime libraries the
+ on-device recognizer quietly ran on the CPU (about eight times slower; the
+ cloud fallback took 48 s for a 70 s recording). The provider card now shows
+ what the config asked for, what really runs, and why, with a one-click
+ install of the missing libraries. They are also available as the `cuda`
+ install extra.
- **The wake word no longer fires on a stray single word.** Since the 20 Aug
crash fix, the check that decides between "Hey George" and whatever was
actually said had quietly lost its strongest comparison, so a lone word like
diff --git a/jarvis/agent_config_parity.py b/jarvis/agent_config_parity.py
index b060ea7492..2d3b8a7850 100644
--- a/jarvis/agent_config_parity.py
+++ b/jarvis/agent_config_parity.py
@@ -213,6 +213,16 @@ USER_SETUP: dict[Platform, tuple[Shared, ...]] = {
# Same reasoning as Claude Code's plugins above, and the same treatment.
Shared("plugins", "dir", copy_fallback=False, whole=True),
),
+ "grok-build": (
+ # Grok's login lives in auth.json, so the settings file can be shared
+ # whole — the same split Codex has.
+ Shared("config.toml", "file", fmt="toml"),
+ Shared("settings.json", "file", fmt="json"),
+ Shared("skills", "dir"),
+ Shared("commands", "dir"),
+ Shared("hooks", "dir"),
+ Shared("rules", "dir"),
+ ),
}
#: Keys merged out of a document that also holds identity. See :class:`MergedKey`.
@@ -233,6 +243,7 @@ MERGED_KEYS: dict[Platform, tuple[MergedKey, ...]] = {
),
# Codex's mcp_servers live in config.toml, which is shared whole above.
"codex": (),
+ "grok-build": (),
}
diff --git a/jarvis/agentic_ide/agent_sessions.py b/jarvis/agentic_ide/agent_sessions.py
index 82442f601a..758280b08b 100644
--- a/jarvis/agentic_ide/agent_sessions.py
+++ b/jarvis/agentic_ide/agent_sessions.py
@@ -1,16 +1,18 @@
"""How each coding CLI names, keeps and reopens one of its conversations.
A pane of the Agentic IDE is not the conversation it shows. The conversation
-lives inside the agent's own CLI — Claude Code and Codex each keep their own
-history on disk — and all this module does is hold the one string needed to
-point back at it: a *resume handle*.
+lives inside the agent's own CLI — every coding CLI here (Claude Code, Codex,
+OpenCode, Kimi Code, Grok Build, and the launch profiles over them) keeps its
+own history on disk — and all this module does is hold the one string needed
+to point back at it: a *resume handle*.
That indirection is what makes a workspace survivable. Closing the browser kills
every agent process (deliberately: an unwatched agent burns tokens invisibly),
and a restarted app forgets the workspace entirely. With a handle per pane, both
can be undone — the pane comes back and so does what it already knows.
-The two CLIs do NOT work the same way, and the difference decides the design:
+The CLIs do NOT work the same way, and the difference decides the design. Two
+shapes cover all of them — ASSIGNED at launch, or DISCOVERED afterwards:
* **Claude Code** accepts ``--session-id <uuid>``, so the id can be *assigned*
at launch. We mint one per pane and hand it over; resuming is then simply
@@ -20,6 +22,10 @@ The two CLIs do NOT work the same way, and the difference decides the design:
shortcut and is a trap: it means "the newest session in this folder", so three
Codex panes in one repository would all resume the SAME conversation and two
users' work would silently vanish. Every pane must carry its own id.
+* **Grok Build** is the Claude Code shape (``--session-id`` at launch,
+ ``--resume`` later); **OpenCode** and **Kimi Code** are the Codex shape
+ (the id is theirs to choose — a database row, a session directory — and
+ ours to find by folder and time). Each adapter below says which.
Callers never branch on an agent name (AP-21). They ask this module whether a
handle can be minted, spent, or found, and an agent that answers "no" degrades
@@ -118,9 +124,7 @@ class _Adapter:
# Finds the id afterwards, for CLIs that cannot be told one. The third
# argument is the set of ids other panes already hold — see `discover`; the
# fourth is the config dir whose history to search (None = the default).
- discover: (
- Callable[[str, float, Collection[str], Path | None], ResumeHandle | None] | None
- )
+ discover: Callable[[str, float, Collection[str], Path | None], ResumeHandle | None] | None
# Is there actually a conversation behind an id? See `has_conversation`.
exists: Callable[[ResumeHandle, Path | None], bool]
@@ -134,6 +138,17 @@ def _claude_launch() -> tuple[tuple[str, ...], ResumeHandle | None]:
)
+def _grok_launch() -> tuple[tuple[str, ...], ResumeHandle | None]:
+ # Same shape as Claude Code: Grok accepts a client-supplied UUID at
+ # launch (``--session-id``) and refuses anything that is not one. Minting
+ # here means we never have to guess which session a pane created.
+ session_id = str(uuid4())
+ return (
+ ("--session-id", session_id),
+ ResumeHandle(kind="grok_session", id=session_id, captured_at=time.time()),
+ )
+
+
def _codex_launch() -> tuple[tuple[str, ...], ResumeHandle | None]:
# Nothing can be passed: the id is Codex's to choose and ours to find later.
return ((), None)
@@ -160,9 +175,7 @@ _ADAPTERS: dict[str, _Adapter] = {
resume=lambda session_id: ("resume", session_id),
# Late-bound on purpose: the discovery function is defined further down,
# next to the file-format knowledge it needs.
- discover=lambda cwd, started, taken, home: _discover_codex(
- cwd, started, taken, home
- ),
+ discover=lambda cwd, started, taken, home: _discover_codex(cwd, started, taken, home),
exists=lambda handle, home: _codex_conversation_exists(handle, home),
),
"opencode": _Adapter(
@@ -172,9 +185,7 @@ _ADAPTERS: dict[str, _Adapter] = {
# reused for something else between releases; `--session` has to keep
# meaning this or the CLI would break its own users.
resume=lambda session_id: ("--session", session_id),
- discover=lambda cwd, started, taken, home: _discover_opencode(
- cwd, started, taken, home
- ),
+ discover=lambda cwd, started, taken, home: _discover_opencode(cwd, started, taken, home),
exists=lambda handle, home: _opencode_conversation_exists(handle, home),
),
"kimi": _Adapter(
@@ -184,11 +195,16 @@ _ADAPTERS: dict[str, _Adapter] = {
# generations disagree on the SHORT flag (-C versus -c), so a short one
# would mean something different depending on which is installed.
resume=lambda session_id: ("--session", session_id),
- discover=lambda cwd, started, taken, home: _discover_kimi(
- cwd, started, taken, home
- ),
+ discover=lambda cwd, started, taken, home: _discover_kimi(cwd, started, taken, home),
exists=lambda handle, home: _kimi_conversation_exists(handle, home),
),
+ "grok-build": _Adapter(
+ kind="grok_session",
+ launch=_grok_launch,
+ resume=lambda session_id: ("--resume", session_id),
+ discover=None,
+ exists=lambda handle, home: _grok_conversation_exists(handle, home),
+ ),
}
@@ -238,9 +254,7 @@ def resume_argv(agent: str, handle: ResumeHandle | None) -> tuple[str, ...] | No
return adapter.resume(handle.id)
-def has_conversation(
- agent: str, handle: ResumeHandle | None, home: Path | None = None
-) -> bool:
+def has_conversation(agent: str, handle: ResumeHandle | None, home: Path | None = None) -> bool:
"""Is there actually something behind this handle, or only a reserved id?
**The distinction this whole module got wrong at first.** Being handed an id
@@ -312,9 +326,7 @@ def _claude_home(override: Path | None = None) -> Path:
return Path(raw).expanduser() if raw else Path.home() / ".claude"
-def _claude_conversation_exists(
- handle: ResumeHandle, home: Path | None = None
-) -> bool:
+def _claude_conversation_exists(handle: ResumeHandle, home: Path | None = None) -> bool:
"""True when Claude Code has a transcript filed under this session id.
Searched by id across all project folders rather than by rebuilding the
@@ -441,9 +453,7 @@ def _candidate_files(root: Path, started_at: float) -> list[Path]:
return keep[:_MAX_CANDIDATES]
-def _codex_conversation_exists(
- handle: ResumeHandle, home: Path | None = None
-) -> bool:
+def _codex_conversation_exists(handle: ResumeHandle, home: Path | None = None) -> bool:
"""True when Codex still has the rollout file this handle came from.
The id is in the filename, and ``captured_at`` says roughly when it was
@@ -556,9 +566,7 @@ def _opencode_db(home: Path | None = None) -> Path | None:
return max(candidates, key=lambda p: p.stat().st_mtime)
-def _opencode_rows(
- home: Path | None, query: str, params: tuple[Any, ...]
-) -> list[tuple[Any, ...]]:
+def _opencode_rows(home: Path | None, query: str, params: tuple[Any, ...]) -> list[tuple[Any, ...]]:
"""Run a read-only query against the session database.
Read-only and never ``immutable``: the CLI may well be running and holding a
@@ -600,12 +608,8 @@ def _epoch_seconds(value: Any) -> float | None:
return number / 1000.0 if number > 1e11 else number
-def _opencode_conversation_exists(
- handle: ResumeHandle, home: Path | None = None
-) -> bool:
- rows = _opencode_rows(
- home, "SELECT 1 FROM session WHERE id = ? LIMIT 1", (handle.id,)
- )
+def _opencode_conversation_exists(handle: ResumeHandle, home: Path | None = None) -> bool:
+ rows = _opencode_rows(home, "SELECT 1 FROM session WHERE id = ? LIMIT 1", (handle.id,))
return bool(rows)
@@ -660,9 +664,7 @@ def _discover_opencode(
stamp = _epoch_seconds(created)
if stamp is None or stamp < started_at - _SKEW_S:
continue
- return ResumeHandle(
- kind="opencode_session", id=session_id, captured_at=stamp
- )
+ return ResumeHandle(kind="opencode_session", id=session_id, captured_at=stamp)
return None
@@ -688,17 +690,19 @@ def _kimi_root(home: Path | None = None) -> Path | None:
def _kimi_folder_key(cwd: str) -> str | None:
- """The per-working-directory folder name this CLI derives from a path.
+ """The per-working-directory folder name the LEGACY generation derives.
MEASURED against a live install rather than taken from documentation: the
folder is the MD5 of the working directory exactly as the OS spells it
(``C:\\Users\\...`` on Windows), which is why the native string is hashed and
not a normalised or POSIX one.
- This is the ONLY link between a session and the folder it belongs to — the
- files inside record no working directory — so when the derived folder is
- absent there is simply nothing to match against, and the caller starts a
- fresh conversation instead of guessing.
+ In that generation this is the ONLY link between a session and the folder
+ it belongs to — the files inside record no working directory — so when the
+ derived folder is absent there is simply nothing to match against. The
+ current generation records the working directory inside each session (see
+ :func:`_kimi_session_folder`) and names its buckets differently, so it is
+ never matched through this key.
"""
import hashlib
@@ -711,23 +715,177 @@ def _kimi_folder_key(cwd: str) -> str | None:
return hashlib.md5(native.encode("utf-8"), usedforsecurity=False).hexdigest()
-def _kimi_sessions_dir(cwd: str, home: Path | None) -> Path | None:
- root = _kimi_root(home)
+# The current generation names its per-folder buckets like this. Anything else
+# under ``sessions/`` is the legacy generation's MD5 bucket (or a stranger).
+_KIMI_WORKSPACE_BUCKET_PREFIX = "wd_"
+
+# What the current generation writes into a session's wire log the moment the
+# session OPENS, before anybody has typed anything — MEASURED across eight
+# opened-and-abandoned sessions on a live install, each exactly these records
+# and nothing else. A log that holds any record beyond them has a conversation
+# in it. Keyed on "anything beyond the setup prefix" rather than on the name of
+# the first-turn record on purpose: a future release can rename its turn
+# records and this still reads a real conversation as real.
+_KIMI_SETUP_RECORDS = frozenset({"metadata", "config.update", "tools.set_active_tools"})
+
+
+def _kimi_buckets_for(cwd: str, root: Path) -> list[Path]:
+ """Every bucket under ``root/sessions`` that may hold ``cwd``'s sessions.
+
+ Both generations at once, because a machine can carry both histories and
+ the launch path does not know which one a given pane wrote into:
+
+ * **Legacy** — one bucket named ``md5(cwd)``; it IS the folder scoping.
+ * **Current** — buckets named ``wd_<slug>_<hash>``, mapped back to their
+ folder by the CLI's own ``workspaces.json`` (``workspaces[key].root``).
+ When that index is missing or unreadable every ``wd_`` bucket is offered
+ and the per-session ``state.json`` does the filtering instead, so a
+ damaged index costs a few more ``stat`` calls and never a conversation.
+ """
+ sessions = root / "sessions"
+ if not sessions.is_dir():
+ return []
+ out: list[Path] = []
key = _kimi_folder_key(cwd)
- if root is None or key is None:
+ if key is not None and (sessions / key).is_dir():
+ out.append(sessions / key)
+
+ mapped: list[Path] | None = None
+ index = root / "workspaces.json"
+ try:
+ payload = json.loads(index.read_text(encoding="utf-8")) if index.is_file() else None
+ except (OSError, ValueError):
+ payload = None
+ if isinstance(payload, dict) and isinstance(payload.get("workspaces"), dict):
+ mapped = []
+ for bucket_name, entry in payload["workspaces"].items():
+ if not isinstance(bucket_name, str) or not isinstance(entry, dict):
+ continue
+ bucket_root = entry.get("root")
+ if isinstance(bucket_root, str) and _same_folder(bucket_root, cwd):
+ bucket = sessions / bucket_name
+ if bucket.is_dir():
+ mapped.append(bucket)
+ if mapped is None:
+ try:
+ mapped = [
+ child
+ for child in sessions.iterdir()
+ if child.is_dir() and child.name.startswith(_KIMI_WORKSPACE_BUCKET_PREFIX)
+ ]
+ except OSError:
+ mapped = []
+ out.extend(bucket for bucket in mapped if bucket not in out)
+ return out
+
+
+def _kimi_session_state(folder: Path) -> dict[str, Any] | None:
+ """The current generation's ``state.json`` for a session, or None (legacy)."""
+ state = folder / "state.json"
+ try:
+ if not state.is_file():
+ return None
+ payload = json.loads(state.read_text(encoding="utf-8"))
+ except (OSError, ValueError):
return None
- folder = root / "sessions" / key
- return folder if folder.is_dir() else None
+ return payload if isinstance(payload, dict) else None
+
+
+def _kimi_session_folder(folder: Path) -> str | None:
+ """The working directory a session belongs to, when the session says so.
+
+ Only the current generation records it (``state.json`` → ``workDir``). None
+ means "the session does not say" — the legacy layout, where the bucket name
+ already is the scoping — and NOT "no folder".
+ """
+ state = _kimi_session_state(folder)
+ if state is None:
+ return None
+ work_dir = state.get("workDir")
+ return work_dir if isinstance(work_dir, str) and work_dir else None
+
+def _kimi_session_created(folder: Path) -> float | None:
+ """When a session opened: its own ``createdAt`` when recorded, else mtime.
-def _kimi_conversation_exists(
- handle: ResumeHandle, home: Path | None = None
-) -> bool:
+ The legacy generation records nothing, and there the directory's mtime is
+ the moment it was created (the CLI never touches the directory afterwards —
+ it writes INTO it). The current generation stamps ``createdAt`` in
+ ``state.json``; that is read first because the directory's mtime there moves
+ whenever a file inside is added.
+ """
+ state = _kimi_session_state(folder)
+ if state is not None:
+ stamp = _parse_utc(state.get("createdAt"))
+ if stamp is not None:
+ return stamp
+ try:
+ return folder.stat().st_mtime
+ except OSError:
+ return None
+
+
+def _kimi_wire_has_turn(log: Path) -> bool:
+ """Does this wire log hold anything beyond the records written at open?
+
+ Reads line by line and stops at the first record outside
+ :data:`_KIMI_SETUP_RECORDS`, so a long conversation costs the few setup
+ lines and one more, never the whole file. A line that is not JSON is taken
+ as content: the CLI writes only JSON here, so anything else was written by
+ a turn that was cut off mid-line — which is still a conversation.
+ """
+ try:
+ with log.open("r", encoding="utf-8", errors="replace") as handle:
+ for raw in handle:
+ line = raw.strip()
+ if not line:
+ continue
+ try:
+ record = json.loads(line)
+ except ValueError:
+ return True
+ kind = record.get("type") if isinstance(record, dict) else None
+ if kind not in _KIMI_SETUP_RECORDS:
+ return True
+ except OSError:
+ return False
+ return False
+
+
+def _kimi_session_has_content(folder: Path) -> bool:
+ """Is there a conversation in this session directory, or only its shell?
+
+ Both generations create the directory the moment a session opens, so "the
+ directory exists" is no evidence of anything. What counts as content
+ differs per layout and is MEASURED, not assumed:
+
+ * **Current** — ``agents/<name>/wire.jsonl`` exists from the start and is
+ already tens of kilobytes (the system prompt is logged into it), so its
+ SIZE says nothing; what says something is a record beyond the setup
+ prefix (:func:`_kimi_wire_has_turn`).
+ * **Legacy** — ``context.jsonl``/``wire.jsonl`` are created at open and
+ stay EMPTY until the first turn, so any non-empty regular file is a
+ conversation.
+ """
+ try:
+ wires = sorted(folder.glob("agents/*/wire.jsonl"))
+ except OSError:
+ return False
+ if wires:
+ return any(_kimi_wire_has_turn(wire) for wire in wires)
+ try:
+ return any(child.is_file() and child.stat().st_size > 0 for child in folder.iterdir())
+ except OSError:
+ return False
+
+
+def _kimi_conversation_exists(handle: ResumeHandle, home: Path | None = None) -> bool:
"""True when this CLI still holds a conversation behind the handle.
- Searched by id across every working-directory folder, for the same reason
- the Claude check is: the id is unique everywhere, while the folder name is
- the CLI's own convention and could change without notice.
+ Searched by id across every bucket, for the same reason the Claude check
+ is: the id is unique everywhere (a UUID, prefixed ``session_`` in the
+ current generation), while the bucket name is the CLI's own convention and
+ differs between its two generations already.
"""
session_id = handle.id
if not session_id or "/" in session_id or "\\" in session_id:
@@ -740,7 +898,7 @@ def _kimi_conversation_exists(
return False
try:
return any(
- child.is_dir() and any(child.iterdir())
+ child.is_dir() and _kimi_session_has_content(child)
for child in sessions.glob(f"*/{session_id}")
)
except OSError:
@@ -755,22 +913,29 @@ def _discover_kimi(
) -> ResumeHandle | None:
"""The session a pane in ``cwd`` started at ``started_at`` created.
- A session here is a DIRECTORY named after its id, so the moment it was
- created is its own timestamp — no file has to be opened at all, which keeps
- this the cheapest discovery of the three even for a heavy user.
-
- An empty directory is skipped: this CLI creates the folder when the session
- opens and writes into it once the conversation has content, so resuming an
- empty one reopens nothing and costs the pane its launch.
+ A session here is a DIRECTORY named after its id — in the current generation
+ ``session_<uuid>``, which is also exactly what ``--session`` expects, so the
+ directory name is the handle. The two generations scope a session to its
+ folder differently (see :func:`_kimi_buckets_for`), and this walks whichever
+ buckets can hold ``cwd``'s sessions, in either layout.
+
+ A session without content is skipped: both generations create the directory
+ the moment the session opens, so resuming an empty one reopens nothing and
+ costs the pane its launch. A current-generation session whose ``state.json``
+ names another folder is skipped too — that only happens when the bucket
+ index was unreadable and every bucket is being offered.
"""
- folder = _kimi_sessions_dir(cwd, home)
- if folder is None:
+ root = _kimi_root(home)
+ if root is None:
return None
claimed = {str(t) for t in taken}
- best: tuple[float, str] | None = None
- try:
- children = list(folder.iterdir())
- except OSError:
+ candidates: list[Path] = []
+ for bucket in _kimi_buckets_for(cwd, root):
+ try:
+ candidates.extend(child for child in bucket.iterdir() if child.is_dir())
+ except OSError:
+ continue
+ if not candidates:
return None
def _mtime(path: Path) -> float:
@@ -784,18 +949,19 @@ def _discover_kimi(
# pane's own folder for an arbitrary 400 others, and the pane would come
# back as a fresh conversation with nothing to explain why. A pane's own
# session is by construction among the newest.
- children.sort(key=_mtime, reverse=True)
- for child in children[:_MAX_CANDIDATES]:
+ candidates.sort(key=_mtime, reverse=True)
+ best: tuple[float, str] | None = None
+ for child in candidates[:_MAX_CANDIDATES]:
session_id = child.name
- if session_id in claimed or not child.is_dir():
+ if session_id in claimed:
continue
- try:
- if not any(child.iterdir()):
- continue
- stamp = child.stat().st_mtime
- except OSError:
+ recorded_folder = _kimi_session_folder(child)
+ if recorded_folder is not None and not _same_folder(recorded_folder, cwd):
continue
- if stamp < started_at - _SKEW_S:
+ stamp = _kimi_session_created(child)
+ if stamp is None or stamp < started_at - _SKEW_S:
+ continue
+ if not _kimi_session_has_content(child):
continue
if best is None or stamp < best[0]:
best = (stamp, session_id)
@@ -804,6 +970,64 @@ def _discover_kimi(
return ResumeHandle(kind="kimi_session", id=best[1], captured_at=best[0])
+# ---------------------------------------------------------------- Grok Build
+def _grok_home(override: Path | None = None) -> Path:
+ """The GROK_HOME whose history to read: the account's, else the default."""
+ if override is not None:
+ return Path(override).expanduser()
+ raw = os.environ.get("GROK_HOME")
+ return Path(raw).expanduser() if raw else Path.home() / ".grok"
+
+
+def _grok_conversation_exists(handle: ResumeHandle, home: Path | None = None) -> bool:
+ """True when Grok Build has a transcript filed under this session id.
+
+ Searched by id across every working-directory group rather than by
+ reconstructing the encoded folder name. That name is the CLI's own
+ convention (URL-encoded cwd, or a slug-plus-hash when the encoding is
+ over 255 bytes) and could change without notice, while the id is a UUID
+ and unique everywhere.
+
+ The directory and its ``updates.jsonl`` exist from the moment the session
+ OPENS — MEASURED on a live install: a pane opened and abandoned leaves a
+ log holding the ``session_start`` hook run and nothing else, so neither
+ the directory nor a non-empty log is evidence of a conversation. What is
+ evidence is a user turn in that log (``"sessionUpdate":
+ "user_message_chunk"``). Resuming a session without one reopens an empty
+ conversation, which is indistinguishable from a dead pane.
+ """
+ session_id = handle.id
+ if not session_id or "/" in session_id or "\\" in session_id:
+ return False
+ root = _grok_home(home) / "sessions"
+ if not root.is_dir():
+ return False
+ found = next(root.glob(f"*/{session_id}"), None)
+ if found is None or not found.is_dir():
+ return False
+ return _grok_log_has_user_turn(found / "updates.jsonl")
+
+
+# The session-update record Grok Build writes when the USER says something.
+# Every other record in `updates.jsonl` (hook runs, agent chunks, turn ends) can
+# appear without a conversation ever having happened.
+_GROK_USER_TURN_MARKER = b'"user_message_chunk"'
+
+
+def _grok_log_has_user_turn(log: Path) -> bool:
+ """Does this update log record at least one user turn?
+
+ Read as bytes, line by line, stopping at the first hit: a long conversation
+ has its first user turn within the first few lines, and an abandoned pane's
+ log is one line long.
+ """
+ try:
+ with log.open("rb") as handle:
+ return any(_GROK_USER_TURN_MARKER in line for line in handle)
+ except OSError:
+ return False
+
+
__all__ = [
"ResumeHandle",
"can_resume",
diff --git a/jarvis/agentic_ide/names.py b/jarvis/agentic_ide/names.py
index 6f3ae65687..b20a3645ab 100644
--- a/jarvis/agentic_ide/names.py
+++ b/jarvis/agentic_ide/names.py
@@ -37,6 +37,7 @@ fuzzy matching: "T1" and "T11" score 0.80 against each other, which is above
the acting floor, so a fuzzy hit between two positions would be a coin flip
over which agent gets the work. Positions match exactly or not at all.
"""
+
from __future__ import annotations
import re
@@ -56,7 +57,7 @@ _POSITION_NAME_RE = re.compile(rf"^{CALL_SIGN_PREFIX}(\d{{1,3}})$", re.IGNORECAS
#: merely has installed — so the list is deliberately WIDER than the registry.
#: Positional call-signs cannot collide with any of them.
_KNOWN_PRODUCTS: frozenset[str] = frozenset(
- {"jarvis", "claude", "codex", "gemini", "copilot", "cursor", "aider"}
+ {"jarvis", "claude", "codex", "gemini", "copilot", "cursor", "aider", "grok"}
)
@@ -105,6 +106,7 @@ _NEAR_MISS_FLOOR = 0.55
# Positional call-signs #
# --------------------------------------------------------------------------- #
+
def position_name(number: int) -> str:
"""The call-sign of the ``number``-th pane, counting from 1 ("T3")."""
return f"{CALL_SIGN_PREFIX}{int(number)}"
@@ -173,22 +175,72 @@ def free_positions(taken: Iterable[str], count: int) -> list[str]:
# reading its article as the digit would turn it into an order for pane one.
_NUMBER_WORDS: dict[str, int] = {
# German
- "eins": 1, "zwei": 2, "zwo": 2, "drei": 3, # i18n-allow: input vocabulary
- "vier": 4, "fuenf": 5, "fünf": 5, "sechs": 6, "sieben": 7, "acht": 8, # i18n-allow: input vocabulary
- "neun": 9, "zehn": 10, "elf": 11, "zwoelf": 12, "zwölf": 12, # i18n-allow: input vocabulary
- "dreizehn": 13, "vierzehn": 14, "fuenfzehn": 15, "fünfzehn": 15, # i18n-allow: input vocabulary
- "sechzehn": 16, "siebzehn": 17, "achtzehn": 18, "neunzehn": 19, # i18n-allow: input vocabulary
+ "eins": 1,
+ "zwei": 2,
+ "zwo": 2,
+ "drei": 3, # i18n-allow: input vocabulary
+ "vier": 4,
+ "fuenf": 5,
+ "fünf": 5, # i18n-allow: input vocabulary
+ "sechs": 6,
+ "sieben": 7,
+ "acht": 8, # i18n-allow: input vocabulary
+ "neun": 9,
+ "zehn": 10,
+ "elf": 11,
+ "zwoelf": 12,
+ "zwölf": 12, # i18n-allow: input vocabulary
+ "dreizehn": 13,
+ "vierzehn": 14,
+ "fuenfzehn": 15,
+ "fünfzehn": 15, # i18n-allow: input vocabulary
+ "sechzehn": 16,
+ "siebzehn": 17,
+ "achtzehn": 18,
+ "neunzehn": 19, # i18n-allow: input vocabulary
"zwanzig": 20, # i18n-allow: input vocabulary
# English
- "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6,
- "seven": 7, "eight": 8, "nine": 9, "ten": 10, "eleven": 11, "twelve": 12,
- "thirteen": 13, "fourteen": 14, "fifteen": 15, "sixteen": 16,
- "seventeen": 17, "eighteen": 18, "nineteen": 19, "twenty": 20,
+ "one": 1,
+ "two": 2,
+ "three": 3,
+ "four": 4,
+ "five": 5,
+ "six": 6,
+ "seven": 7,
+ "eight": 8,
+ "nine": 9,
+ "ten": 10,
+ "eleven": 11,
+ "twelve": 12,
+ "thirteen": 13,
+ "fourteen": 14,
+ "fifteen": 15,
+ "sixteen": 16,
+ "seventeen": 17,
+ "eighteen": 18,
+ "nineteen": 19,
+ "twenty": 20,
# Spanish
- "uno": 1, "dos": 2, "tres": 3, "cuatro": 4, "cinco": 5,
- "seis": 6, "siete": 7, "ocho": 8, "nueve": 9, "diez": 10, "once": 11,
- "doce": 12, "trece": 13, "catorce": 14, "quince": 15, "dieciseis": 16,
- "dieciséis": 16, "diecisiete": 17, "dieciocho": 18, "diecinueve": 19,
+ "uno": 1,
+ "dos": 2,
+ "tres": 3,
+ "cuatro": 4,
+ "cinco": 5,
+ "seis": 6,
+ "siete": 7,
+ "ocho": 8,
+ "nueve": 9,
+ "diez": 10,
+ "once": 11,
+ "doce": 12,
+ "trece": 13,
+ "catorce": 14,
+ "quince": 15,
+ "dieciseis": 16,
+ "dieciséis": 16,
+ "diecisiete": 17,
+ "dieciocho": 18,
+ "diecinueve": 19,
"veinte": 20,
}
@@ -199,26 +251,66 @@ _NUMBER_WORDS: dict[str, int] = {
# ending is what tells the two apart, so it is mandatory wherever the language
# has one.
_ORDINAL_STEMS_DE: dict[str, int] = {
- "erst": 1, "zweit": 2, "dritt": 3, "viert": 4, "fuenft": 5, "fünft": 5, # i18n-allow: input vocabulary
- "sechst": 6, "siebt": 7, "siebent": 7, "acht": 8, "neunt": 9, "zehnt": 10, # i18n-allow: input vocabulary
- "elft": 11, "zwoelft": 12, "zwölft": 12, # i18n-allow: input vocabulary
+ "erst": 1,
+ "zweit": 2,
+ "dritt": 3,
+ "viert": 4,
+ "fuenft": 5,
+ "fünft": 5, # i18n-allow: input vocabulary
+ "sechst": 6,
+ "siebt": 7,
+ "siebent": 7,
+ "acht": 8,
+ "neunt": 9,
+ "zehnt": 10, # i18n-allow: input vocabulary
+ "elft": 11,
+ "zwoelft": 12,
+ "zwölft": 12, # i18n-allow: input vocabulary
}
_ORDINAL_ENDINGS_DE: tuple[str, ...] = ("e", "en", "er", "es", "em")
_ORDINAL_PLAIN: dict[str, int] = {
# i18n-allow: speech-recognition input vocabulary, not prose
# English
- "first": 1, "second": 2, "third": 3, "fourth": 4, "fifth": 5, "sixth": 6,
- "seventh": 7, "eighth": 8, "ninth": 9, "tenth": 10, "eleventh": 11,
+ "first": 1,
+ "second": 2,
+ "third": 3,
+ "fourth": 4,
+ "fifth": 5,
+ "sixth": 6,
+ "seventh": 7,
+ "eighth": 8,
+ "ninth": 9,
+ "tenth": 10,
+ "eleventh": 11,
"twelfth": 12,
# Spanish, in every gendered and apocopated form people actually say
- "primer": 1, "primero": 1, "primera": 1,
- "segundo": 2, "segunda": 2,
- "tercer": 3, "tercero": 3, "tercera": 3,
- "cuarto": 4, "cuarta": 4, "quinto": 5, "quinta": 5,
- "sexto": 6, "sexta": 6, "septimo": 7, "séptimo": 7, "septima": 7,
- "séptima": 7, "octavo": 8, "octava": 8, "noveno": 9, "novena": 9,
- "decimo": 10, "décimo": 10, "decima": 10, "décima": 10,
+ "primer": 1,
+ "primero": 1,
+ "primera": 1,
+ "segundo": 2,
+ "segunda": 2,
+ "tercer": 3,
+ "tercero": 3,
+ "tercera": 3,
+ "cuarto": 4,
+ "cuarta": 4,
+ "quinto": 5,
+ "quinta": 5,
+ "sexto": 6,
+ "sexta": 6,
+ "septimo": 7,
+ "séptimo": 7,
+ "septima": 7,
+ "séptima": 7,
+ "octavo": 8,
+ "octava": 8,
+ "noveno": 9,
+ "novena": 9,
+ "decimo": 10,
+ "décimo": 10,
+ "decima": 10,
+ "décima": 10,
}
_ORDINAL_WORDS: dict[str, int] = {
@@ -233,8 +325,7 @@ _ORDINAL_WORDS: dict[str, int] = {
#: Words meaning "the one at the end", resolved against the live pane count.
_LAST_WORDS: frozenset[str] = frozenset(
# i18n-allow: speech-recognition input vocabulary, not prose
- {"letzte", "letzten", "letztes", "letzter", "last", "ultimo", "último",
- "ultima", "última"}
+ {"letzte", "letzten", "letztes", "letzter", "last", "ultimo", "último", "ultima", "última"}
)
#: How a person says the noun. Matches the German compound too ("Terminalfenster")
@@ -244,12 +335,8 @@ _PANE_NOUN = r"(?:terminals?|terminales|panes?|tabs?|fenster)"
#: An article in front of the noun or the ordinal, all three locales.
_ARTICLE = r"(?:der|die|das|den|dem|des|the|el|la|los|las)" # i18n-allow: input vocabulary
-_NUMBER_WORD_ALT = "|".join(
- sorted((re.escape(w) for w in _NUMBER_WORDS), key=len, reverse=True)
-)
-_ORDINAL_ALT = "|".join(
- sorted((re.escape(w) for w in _ORDINAL_WORDS), key=len, reverse=True)
-)
+_NUMBER_WORD_ALT = "|".join(sorted((re.escape(w) for w in _NUMBER_WORDS), key=len, reverse=True))
+_ORDINAL_ALT = "|".join(sorted((re.escape(w) for w in _ORDINAL_WORDS), key=len, reverse=True))
_LAST_ALT = "|".join(sorted((re.escape(w) for w in _LAST_WORDS), key=len, reverse=True))
#: Every shape that names a pane BY POSITION. Each one carries a terminal
@@ -458,9 +545,7 @@ def phonetic_key(name: str) -> str:
return "".join(squeezed)
-def resolve(
- spoken: str, candidates: list[str], *, fuzzy: bool = True
-) -> str | None:
+def resolve(spoken: str, candidates: list[str], *, fuzzy: bool = True) -> str | None:
"""Best-matching call-sign for ``spoken``, or ``None`` when nothing fits.
``spoken`` may be a whole utterance ("what is terminal three up to?") — the
@@ -575,8 +660,7 @@ def near_miss(
(
(name, score)
for name in candidates
- if position_of(name) is None
- and (score := similarity(spoken, name)) >= _NEAR_MISS_FLOOR
+ if position_of(name) is None and (score := similarity(spoken, name)) >= _NEAR_MISS_FLOOR
),
key=lambda item: (-item[1], item[0]),
)
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentAllocation.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentAllocation.test.tsx
index 80f38c442a..86273d263b 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgentAllocation.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentAllocation.test.tsx
@@ -54,6 +54,14 @@ const AGENTS: AgentStatus[] = [
version: null,
install_command: null,
},
+ {
+ name: "grok-build",
+ display_name: "Grok Build",
+ installed: false,
+ version: null,
+ install_command: null,
+ description: "xAI's terminal coding agent — SuperGrok or X Premium+.",
+ },
];
const ACCOUNTS: AgentAccount[] = [
@@ -177,6 +185,9 @@ describe("AgentAllocation", () => {
.querySelector("img")
?.getAttribute("src"),
).toBe("/agent-logos/zai.svg");
+ expect(
+ screen.getByTestId("agent-mark-grok-build").getAttribute("data-logo"),
+ ).toBe("/provider-logos/grok.svg");
fireEvent.click(screen.getAllByRole("button", { name: "All" })[0]);
expect(claudeMark.getAttribute("data-logo")).toBe(
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentMark.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentMark.test.tsx
index e8491f881f..e4a04c7602 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgentMark.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentMark.test.tsx
@@ -27,13 +27,21 @@ describe("AgentMark", () => {
it("redraws a single-colour silhouette in the theme's own ink", () => {
// Claude and OpenAI ship as one near-white fill. Nothing about that colour
// is brand, so the mark is a mask and follows light/dark by itself.
- render(<AgentMark agent="claude" label="Claude Code" />);
+ const { unmount } = render(<AgentMark agent="claude" label="Claude Code" />);
expect(mark("claude").getAttribute("data-ground")).toBe("ink");
expect(mark("claude").getAttribute("data-logo")).toBe(
"/provider-logos/claude.svg",
);
// The <img> is what made it invisible on paper; it must be gone.
expect(mark("claude").querySelector("img")).toBeNull();
+ unmount();
+
+ render(<AgentMark agent="grok-build" label="Grok Build" />);
+ expect(mark("grok-build").getAttribute("data-ground")).toBe("ink");
+ expect(mark("grok-build").getAttribute("data-logo")).toBe(
+ "/provider-logos/grok.svg",
+ );
+ expect(mark("grok-build").querySelector("img")).toBeNull();
});
it("gives a lockup with a white background the dark ground it was drawn on", () => {
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgentMark.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgentMark.tsx
index 9ad8dcadec..fd62f3a1e6 100644
--- a/jarvis/ui/web/frontend/src/components/agentic/AgentMark.tsx
+++ b/jarvis/ui/web/frontend/src/components/agentic/AgentMark.tsx
@@ -36,6 +36,7 @@ const AGENT_LOGOS: Record<string, LogoAsset> = {
claude: { url: "/provider-logos/claude.svg", ground: "ink" },
codex: { url: "/provider-logos/openai.svg", ground: "ink" },
glm: { url: "/agent-logos/zai.svg", ground: "any" },
+ "grok-build": { url: "/provider-logos/grok.svg", ground: "ink" },
kimi: { url: "/agent-logos/kimi.svg", ground: "dark" },
opencode: { url: "/agent-logos/opencode.svg", ground: "dark" },
};
diff --git a/jarvis/workspace/agents.py b/jarvis/workspace/agents.py
index 684c5499e3..a210703c45 100644
--- a/jarvis/workspace/agents.py
+++ b/jarvis/workspace/agents.py
@@ -26,10 +26,12 @@ Git Bash on Windows and ``$SHELL``/``/etc/shells`` elsewhere. On a host with no
shell at all (a stripped container) the entry reports itself as not installed
rather than handing the PTY an argv that cannot start.
"""
+
from __future__ import annotations
import asyncio
import logging
+import sys
import time
from collections.abc import Callable
from dataclasses import dataclass
@@ -337,9 +339,7 @@ def make_cli_agent(
binary_name=binary,
check_command=(binary, "--version"),
version_parse_regex=version_regex,
- install=install or InstallMethods(
- npm_package=npm_package or None, recommended="npm"
- ),
+ install=install or InstallMethods(npm_package=npm_package or None, recommended="npm"),
# We only care whether the binary is installed; the agent handles its
# own login interactively on first launch in the terminal.
auth=AuthConfig(type="none"),
@@ -392,6 +392,33 @@ CODEX_TRUST = TrustSpec(
subdir=".codex",
)
+#: Grok Build keeps folder trust in ``$GROK_HOME/trusted_folders.toml``.
+GROK_TRUST = TrustSpec(
+ filename="trusted_folders.toml",
+ fmt="toml",
+ section=("folders",),
+ key="trusted",
+ value=True,
+ home_env="GROK_HOME",
+ subdir=".grok",
+ backup=True,
+)
+
+
+def _grok_build_install() -> InstallMethods:
+ """Official Grok Build installer for the OS that will run it.
+
+ Grok ships two scripts, not one: ``install.ps1`` on Windows and
+ ``install.sh`` everywhere else. The shared script installer fetches
+ whichever URL we declare and wraps it in the matching runner, so picking
+ the URL at registration is what makes the command actually work.
+ """
+ url = (
+ "https://x.ai/cli/install.ps1" if sys.platform == "win32" else "https://x.ai/cli/install.sh"
+ )
+ return InstallMethods(script_url=url, recommended="script")
+
+
#: Kimi ships under two generations that both install a binary called ``kimi``.
KIMI_CURRENT = "kimi-code"
KIMI_LEGACY = "kimi-cli"
@@ -450,9 +477,7 @@ def kimi_generation() -> str | None:
parts = {part.lower() for part in resolved.parts}
if _KIMI_CURRENT_PACKAGE in parts:
return KIMI_CURRENT
- package = (
- resolved.parent / "node_modules" / "@moonshot-ai" / _KIMI_CURRENT_PACKAGE
- )
+ package = resolved.parent / "node_modules" / "@moonshot-ai" / _KIMI_CURRENT_PACKAGE
if package.is_dir():
return KIMI_CURRENT
@@ -521,9 +546,7 @@ _AGENTS: dict[str, WorkspaceAgent] = {
npm_package="@anthropic-ai/claude-code",
homepage="https://claude.com/claude-code",
trust=CLAUDE_TRUST,
- account=AccountSpec(
- env=(("CLAUDE_CONFIG_DIR", "{dir}"),), native_dir="~/.claude"
- ),
+ account=AccountSpec(env=(("CLAUDE_CONFIG_DIR", "{dir}"),), native_dir="~/.claude"),
# Verified live: an ``@path`` is resolved into the file's contents and
# the file-picker popup does not eat an injected reference.
file_reference="at",
@@ -622,7 +645,11 @@ _AGENTS: dict[str, WorkspaceAgent] = {
# process the agent rather than a cmd wrapper around it.
win_shim=WinShim(
relative_path=(
- "node_modules", "@moonshot-ai", "kimi-code", "dist", "main.mjs",
+ "node_modules",
+ "@moonshot-ai",
+ "kimi-code",
+ "dist",
+ "main.mjs",
),
kind="node",
),
@@ -672,6 +699,32 @@ _AGENTS: dict[str, WorkspaceAgent] = {
spawn_env_factory=glm_spawn_env,
spoken_aliases=("glm", "g l m", "gee ell em", "jlm"),
),
+ "grok-build": make_cli_agent(
+ "grok-build",
+ "Grok Build",
+ binary="grok",
+ homepage="https://x.ai/cli",
+ description="xAI's terminal coding agent — SuperGrok or X Premium+.",
+ install=_grok_build_install(),
+ trust=GROK_TRUST,
+ account=AccountSpec(
+ env=(("GROK_HOME", "{dir}"),),
+ native_dir="~/.grok",
+ login_markers=("auth.json",),
+ login_argv=("login",),
+ ),
+ extra_path_dirs=("~/.grok/bin",),
+ # Flag, not an env var: Grok's updater is on by default and would swap
+ # the binary under a pane that is mid-conversation (same class as
+ # OpenCode and Kimi).
+ launch_args=("--no-auto-update",),
+ file_reference="at",
+ instruction_filename="AGENTS.md",
+ # "grok build" has to be listed: "open grok build" otherwise matches
+ # the short spelling and leaves "build" as an unmatched word, which
+ # drops the whole spawn group.
+ spoken_aliases=("grok", "groc", "grock", "grok build"),
+ ),
PLAIN_TERMINAL: WorkspaceAgent(
name=PLAIN_TERMINAL,
display_name="Plain Terminal",
@@ -761,9 +814,7 @@ def _custom_agent(entry: Any) -> WorkspaceAgent:
# Empty for a shell launch: the whole line goes to the shell verbatim,
# so a second, half-parsed copy of it here would only be something a
# future caller could pick up and get wrong.
- launch_args=()
- if through_shell
- else custom_clis.split_command(entry.command)[1:],
+ launch_args=() if through_shell else custom_clis.split_command(entry.command)[1:],
file_reference=entry.file_reference,
custom=True,
logo_url=custom_clis.logo_url(entry),
@@ -891,9 +942,7 @@ def coding_agent_names() -> tuple[str, ...]:
The "Make It Yours" launcher plans a grid of agents that extend Jarvis, so
it asks this rather than :func:`agent_names`.
"""
- return tuple(
- name for name, agent in _registry().items() if agent.is_coding_agent
- )
+ return tuple(name for name, agent in _registry().items() if agent.is_coding_agent)
def needs_trust(name: str) -> bool:
@@ -1099,11 +1148,7 @@ async def detect_agents(
global _detection_cache, _detection_task
cached = _detection_cache
- if (
- not force
- and cached is not None
- and time.monotonic() - cached[0] < _DETECTION_TTL_S
- ):
+ if not force and cached is not None and time.monotonic() - cached[0] < _DETECTION_TTL_S:
return list(cached[1])
running = _detection_task
@@ -1169,9 +1214,7 @@ async def _sweep_agents(prober: CliStatusProber) -> list[AgentInfo]:
unspecced = [a for a in registry.values() if a.spec is None and a.is_coding_agent]
found: dict[str, bool] = {}
if unspecced:
- found = await asyncio.to_thread(
- lambda: {a.name: _on_path(a.executable) for a in unspecced}
- )
+ found = await asyncio.to_thread(lambda: {a.name: _on_path(a.executable) for a in unspecced})
out: list[AgentInfo] = []
for agent in registry.values():
@@ -1318,6 +1361,7 @@ __all__ = [
"AGENT_NAMES",
"CLAUDE_TRUST",
"CODEX_TRUST",
+ "GROK_TRUST",
"KIMI_CURRENT",
"KIMI_LEGACY",
"PLAIN_TERMINAL",
diff --git a/tests/unit/agentic_ide/test_agent_sessions.py b/tests/unit/agentic_ide/test_agent_sessions.py
index c3855b35b3..a220b1d9e6 100644
--- a/tests/unit/agentic_ide/test_agent_sessions.py
+++ b/tests/unit/agentic_ide/test_agent_sessions.py
@@ -5,6 +5,7 @@ collide. Codex's own ``--last`` shortcut would give all of them the same
conversation, so discovery has to tell them apart — and it has to do so on a
machine in any timezone, which is where the interesting failure lives.
"""
+
from __future__ import annotations
import json
@@ -44,6 +45,14 @@ def test_two_panes_never_share_a_minted_id() -> None:
assert first is not None and second is not None and first.id != second.id
+def test_grok_build_mints_a_session_id_at_launch() -> None:
+ argv, handle = sessions.launch_extra("grok-build")
+ assert argv[0] == "--session-id"
+ assert handle is not None and handle.id == argv[1]
+ assert len(handle.id) == 36 and handle.id.count("-") == 4
+ assert sessions.resume_argv("grok-build", handle) == ("--resume", handle.id)
+
+
def test_codex_cannot_be_told_an_id_but_can_resume_one() -> None:
argv, handle = sessions.launch_extra("codex")
assert argv == () and handle is None
@@ -95,9 +104,7 @@ def _write_rollout(
record = {"timestamp": utc, "type": "session_meta", "payload": payload}
# A real rollout has thousands of lines after the header; only the first
# one may ever be read.
- target.write_text(
- json.dumps(record) + "\n" + '{"type":"turn"}\n' * 50, encoding="utf-8"
- )
+ target.write_text(json.dumps(record) + "\n" + '{"type":"turn"}\n' * 50, encoding="utf-8")
return target
@@ -152,9 +159,7 @@ def test_panes_opened_in_one_batch_do_not_claim_the_same_session(
# Both panes launched within the same second, before either file existed.
first = sessions.discover("codex", cwd, _epoch("2026-07-25T12:00:00Z"))
assert first is not None and first.id == "pane-one-session"
- second = sessions.discover(
- "codex", cwd, _epoch("2026-07-25T12:00:00Z"), taken={first.id}
- )
+ second = sessions.discover("codex", cwd, _epoch("2026-07-25T12:00:00Z"), taken={first.id})
assert second is not None and second.id == "pane-two-session"
@@ -173,10 +178,7 @@ def test_codex_discovery_ignores_a_session_from_another_folder(
session_id="stranger",
)
assert (
- sessions.discover(
- "codex", str(tmp_path / "repo"), _epoch("2026-07-25T12:00:05Z")
- )
- is None
+ sessions.discover("codex", str(tmp_path / "repo"), _epoch("2026-07-25T12:00:05Z")) is None
)
@@ -261,10 +263,7 @@ def test_a_corrupt_rollout_file_is_skipped_not_raised(
(folder / "rollout-broken.jsonl").write_text("{not json", encoding="utf-8")
(tmp_path / "repo").mkdir()
assert (
- sessions.discover(
- "codex", str(tmp_path / "repo"), _epoch("2026-07-25T12:00:05Z")
- )
- is None
+ sessions.discover("codex", str(tmp_path / "repo"), _epoch("2026-07-25T12:00:05Z")) is None
)
diff --git a/tests/unit/agentic_ide/test_new_cli_providers.py b/tests/unit/agentic_ide/test_new_cli_providers.py
index 2bde693f41..c7676ee7a2 100644
--- a/tests/unit/agentic_ide/test_new_cli_providers.py
+++ b/tests/unit/agentic_ide/test_new_cli_providers.py
@@ -1,4 +1,4 @@
-"""The three CLI providers added alongside Claude Code and Codex.
+"""The CLI providers added alongside Claude Code and Codex.
Each of them exercises a different half of the registry contract, which is why
they are worth testing together rather than one file per product:
@@ -11,6 +11,9 @@ they are worth testing together rather than one file per product:
* **GLM** is not a CLI at all — it is the Claude Code binary pointed at another
vendor — so it proves a launch profile inherits behaviour without duplicating
it, and that the environment it depends on is never half-applied.
+* **Grok Build** is a standalone native CLI that accepts a client UUID at
+ launch, so it proves the mint-at-start resume path works for something that
+ is not Claude Code.
"""
from __future__ import annotations
@@ -31,7 +34,7 @@ from jarvis.workspace import agents as workspace_agents
def test_every_new_provider_is_launchable_and_installable() -> None:
"""A registered entry must answer the three questions a pane asks of it."""
- for name in ("opencode", "kimi", "glm"):
+ for name in ("opencode", "kimi", "glm", "grok-build"):
entry = workspace_agents.get_agent(name)
assert entry is not None, f"{name} is not registered"
assert entry.is_coding_agent
@@ -40,7 +43,7 @@ def test_every_new_provider_is_launchable_and_installable() -> None:
def test_a_two_part_version_string_is_not_read_as_no_version() -> None:
- """"kimi, version 1.3" must parse — a blank version reads as a broken install."""
+ """ "kimi, version 1.3" must parse — a blank version reads as a broken install."""
import re
entry = workspace_agents.get_agent("kimi")
@@ -55,7 +58,7 @@ def test_a_two_part_version_string_is_not_read_as_no_version() -> None:
def test_a_product_name_can_never_become_a_pane_call_sign() -> None:
"""Saying "Kimi" must address the CLI, not a pane that happens to be called that."""
reserved = workspace_agents.reserved_call_signs()
- for spoken in ("kimi", "opencode", "glm", "claude", "codex"):
+ for spoken in ("kimi", "opencode", "glm", "claude", "codex", "grok"):
assert spoken in reserved
from jarvis.agentic_ide import names
@@ -142,9 +145,7 @@ def test_two_opencode_panes_in_one_folder_get_different_conversations(
_add_session(db, "ses_b", str(tmp_path), started + 2)
first = agent_sessions.discover("opencode", str(tmp_path), started)
assert first is not None
- second = agent_sessions.discover(
- "opencode", str(tmp_path), started, taken=[first.id]
- )
+ second = agent_sessions.discover("opencode", str(tmp_path), started, taken=[first.id])
assert second is not None
assert second.id != first.id
@@ -235,6 +236,195 @@ def test_kimi_skips_a_session_folder_with_nothing_in_it(
assert agent_sessions.discover("kimi", str(tmp_path), time.time() - 5) is None
+# The records the current generation writes into a session's wire log the
+# moment it opens — before anybody typed anything. Mirrors what a live install
+# leaves behind (see `agent_sessions._KIMI_SETUP_RECORDS`).
+_KIMI_CODE_SETUP_LINES = (
+ '{"type":"metadata","protocol_version":"1.4","created_at":1785351452567}\n'
+ '{"type":"config.update","profileName":"agent","systemPrompt":"You are Kimi Code CLI"}\n'
+ '{"type":"config.update","time":1785351452600}\n'
+ '{"type":"tools.set_active_tools","names":["Read","Write","Edit","Grep"]}\n'
+)
+_KIMI_CODE_TURN_LINE = (
+ '{"type":"turn.started","turnId":"t1","input":[{"type":"text","text":"hello"}]}\n'
+)
+
+
+def _kimi_code_session(
+ root: Path,
+ bucket: str,
+ session_id: str,
+ work_dir: Path,
+ created_at: float,
+ *,
+ prompted: bool,
+) -> Path:
+ """Lay down one session exactly as the current generation does.
+
+ A ``wd_<slug>_<hash>`` bucket, ``state.json`` carrying the folder and the
+ open time, and ``agents/main/wire.jsonl`` that is tens of kilobytes from
+ the start — content is a record beyond the setup prefix, never the size.
+ """
+ import json
+ from datetime import UTC, datetime
+
+ folder = root / "sessions" / bucket / session_id
+ (folder / "agents" / "main").mkdir(parents=True)
+ stamp = datetime.fromtimestamp(created_at, tz=UTC).isoformat().replace("+00:00", "Z")
+ state = {
+ "createdAt": stamp,
+ "updatedAt": stamp,
+ "title": "New Session",
+ "agents": {"main": {"type": "main", "parentAgentId": None}},
+ "workDir": work_dir.as_posix(),
+ }
+ (folder / "state.json").write_text(json.dumps(state), encoding="utf-8")
+ lines = _KIMI_CODE_SETUP_LINES + (_KIMI_CODE_TURN_LINE if prompted else "")
+ (folder / "agents" / "main" / "wire.jsonl").write_text(lines, encoding="utf-8")
+ return folder
+
+
+def _kimi_code_index(root: Path, buckets: dict[str, Path]) -> None:
+ """The CLI's own ``workspaces.json``: bucket name → folder it belongs to."""
+ import json
+
+ payload = {
+ "version": 1,
+ "workspaces": {
+ name: {"root": folder.as_posix(), "name": folder.name}
+ for name, folder in buckets.items()
+ },
+ "deleted_workspace_ids": [],
+ }
+ root.mkdir(parents=True, exist_ok=True)
+ (root / "workspaces.json").write_text(json.dumps(payload), encoding="utf-8")
+
+
+def test_kimi_code_finds_the_session_its_pane_created_through_the_workspace_index(
+ _agent_history_in_tmp: Path, tmp_path: Path
+) -> None:
+ """The current generation: `wd_` buckets, `state.json`, a `session_` id.
+
+ This is the layout a 2026 install actually has — the MD5 bucket of the
+ legacy generation is simply absent there, and a lookup that only knows
+ the MD5 name reports "nothing to resume" on a machine full of sessions.
+ """
+ root = _agent_history_in_tmp / "kimi"
+ _kimi_code_index(root, {"wd_proj_1fce0659c7a0": tmp_path})
+ started = time.time()
+ _kimi_code_session(
+ root,
+ "wd_proj_1fce0659c7a0",
+ "session_aaaaaaaa-0000-0000-0000-000000000001",
+ tmp_path,
+ started + 1,
+ prompted=True,
+ )
+ handle = agent_sessions.discover("kimi", str(tmp_path), started)
+ assert handle is not None
+ assert handle.kind == "kimi_session"
+ # The directory name IS the id the CLI expects back, prefix included.
+ assert handle.id == "session_aaaaaaaa-0000-0000-0000-000000000001"
+ assert agent_sessions.resume_argv("kimi", handle) == ("--session", handle.id)
+ assert agent_sessions.has_conversation("kimi", handle) is True
+
+
+def test_kimi_code_skips_a_session_that_was_opened_but_never_prompted(
+ _agent_history_in_tmp: Path, tmp_path: Path
+) -> None:
+ """Its wire log is never empty — the system prompt is logged at open — so
+ size is no evidence; only a record beyond the setup prefix is."""
+ root = _agent_history_in_tmp / "kimi"
+ _kimi_code_index(root, {"wd_proj_1fce0659c7a0": tmp_path})
+ started = time.time()
+ _kimi_code_session(
+ root,
+ "wd_proj_1fce0659c7a0",
+ "session_aaaaaaaa-0000-0000-0000-000000000002",
+ tmp_path,
+ started + 1,
+ prompted=False,
+ )
+ assert agent_sessions.discover("kimi", str(tmp_path), started) is None
+ handle = agent_sessions.ResumeHandle(
+ "kimi_session", "session_aaaaaaaa-0000-0000-0000-000000000002", started
+ )
+ assert agent_sessions.has_conversation("kimi", handle) is False
+
+
+def test_kimi_code_reads_the_sessions_own_folder_when_the_index_is_missing(
+ _agent_history_in_tmp: Path, tmp_path: Path
+) -> None:
+ """No `workspaces.json`: every `wd_` bucket is offered and each session's
+ `state.json` decides — a damaged index costs stats, never a conversation."""
+ root = _agent_history_in_tmp / "kimi"
+ started = time.time()
+ _kimi_code_session(
+ root,
+ "wd_other_0000000000ab",
+ "session_aaaaaaaa-0000-0000-0000-00000000000e",
+ tmp_path / "elsewhere",
+ started + 1,
+ prompted=True,
+ )
+ _kimi_code_session(
+ root,
+ "wd_proj_1fce0659c7a0",
+ "session_aaaaaaaa-0000-0000-0000-000000000003",
+ tmp_path,
+ started + 2,
+ prompted=True,
+ )
+ handle = agent_sessions.discover("kimi", str(tmp_path), started)
+ assert handle is not None
+ assert handle.id == "session_aaaaaaaa-0000-0000-0000-000000000003"
+
+
+def test_kimi_code_hands_panes_opened_together_their_own_sessions(
+ _agent_history_in_tmp: Path, tmp_path: Path
+) -> None:
+ """Two panes, seconds apart: the earliest unclaimed session goes to the
+ first pane, and the id it holds is not offered to the second."""
+ root = _agent_history_in_tmp / "kimi"
+ _kimi_code_index(root, {"wd_proj_1fce0659c7a0": tmp_path})
+ started = time.time()
+ first = "session_aaaaaaaa-0000-0000-0000-000000000004"
+ second = "session_aaaaaaaa-0000-0000-0000-000000000005"
+ _kimi_code_session(root, "wd_proj_1fce0659c7a0", first, tmp_path, started + 1, prompted=True)
+ _kimi_code_session(root, "wd_proj_1fce0659c7a0", second, tmp_path, started + 3, prompted=True)
+ one = agent_sessions.discover("kimi", str(tmp_path), started)
+ assert one is not None and one.id == first
+ two = agent_sessions.discover("kimi", str(tmp_path), started, taken={first})
+ assert two is not None and two.id == second
+
+
+def test_kimi_legacy_and_current_histories_are_searched_side_by_side(
+ _agent_history_in_tmp: Path, tmp_path: Path
+) -> None:
+ """A machine that carried both generations keeps both layouts under one
+ root; a handle from either must still be found by id."""
+ root = _agent_history_in_tmp / "kimi"
+ key = agent_sessions._kimi_folder_key(str(tmp_path))
+ assert key is not None
+ legacy = root / "sessions" / key / "11111111-1111-1111-1111-111111111111"
+ legacy.mkdir(parents=True)
+ (legacy / "context.jsonl").write_text('{"role":"user","content":"hi"}\n', encoding="utf-8")
+ _kimi_code_session(
+ root,
+ "wd_proj_1fce0659c7a0",
+ "session_aaaaaaaa-0000-0000-0000-000000000006",
+ tmp_path,
+ time.time(),
+ prompted=True,
+ )
+ for session_id in (
+ "11111111-1111-1111-1111-111111111111",
+ "session_aaaaaaaa-0000-0000-0000-000000000006",
+ ):
+ handle = agent_sessions.ResumeHandle("kimi_session", session_id, time.time())
+ assert agent_sessions.has_conversation("kimi", handle) is True, session_id
+
+
def test_kimi_folder_key_is_derived_from_the_native_path(tmp_path: Path) -> None:
"""The only link between a session and its folder — so it must be stable."""
import hashlib
@@ -464,9 +654,7 @@ async def test_a_refused_glm_pane_says_so_instead_of_claiming_to_be_starting(
def test_the_glm_environment_factory_reports_not_configured_without_a_key(
monkeypatch: pytest.MonkeyPatch,
) -> None:
- monkeypatch.setattr(
- "jarvis.core.config.get_secret", lambda *_a, **_k: None
- )
+ monkeypatch.setattr("jarvis.core.config.get_secret", lambda *_a, **_k: None)
assert workspace_agents.glm_spawn_env() is None
@@ -481,6 +669,84 @@ def test_the_glm_environment_pins_no_model_the_user_did_not_choose(
assert "ANTHROPIC_DEFAULT_SONNET_MODEL" not in env
+# ----------------------------------------------------------------- Grok Build
+
+
+def test_grok_build_mints_a_session_id_the_way_claude_code_does() -> None:
+ """Grok accepts a client UUID at launch, so we never have to guess later."""
+ entry = workspace_agents.get_agent("grok-build")
+ assert entry is not None
+ assert entry.executable == "grok"
+ assert entry.adapter_key == "grok-build"
+ argv, handle = agent_sessions.launch_extra("grok-build")
+ assert handle is not None and handle.kind == "grok_session"
+ assert argv == ("--session-id", handle.id)
+ assert len(handle.id) == 36 and handle.id.count("-") == 4
+ assert agent_sessions.resume_argv("grok-build", handle) == (
+ "--resume",
+ handle.id,
+ )
+ foreign = agent_sessions.ResumeHandle("claude_session", handle.id, time.time())
+ assert agent_sessions.resume_argv("grok-build", foreign) is None
+
+
+def test_grok_build_treats_a_session_folder_without_a_log_as_fresh(
+ _agent_history_in_tmp: Path,
+) -> None:
+ """An opened-but-never-prompted pane must not be resumed into a dead TUI."""
+ _, handle = agent_sessions.launch_extra("grok-build")
+ assert handle is not None
+ assert agent_sessions.has_conversation("grok-build", handle) is False
+ folder = _agent_history_in_tmp / "grok-build" / "sessions" / "encoded-cwd" / handle.id
+ folder.mkdir(parents=True)
+ assert agent_sessions.has_conversation("grok-build", handle) is False
+ (folder / "updates.jsonl").write_text("", encoding="utf-8")
+ assert agent_sessions.has_conversation("grok-build", handle) is False
+ # MEASURED: opening a pane already writes the session_start hook run into
+ # the log, so a non-empty log is not a conversation either.
+ hook_only = (
+ '{"method":"_x.ai/session/update","params":{"update":'
+ '{"sessionUpdate":"hook_execution","event_name":"session_start"}}}\n'
+ )
+ (folder / "updates.jsonl").write_text(hook_only, encoding="utf-8")
+ assert agent_sessions.has_conversation("grok-build", handle) is False
+ user_turn = (
+ '{"method":"_x.ai/session/update","params":{"update":'
+ '{"sessionUpdate":"user_message_chunk","content":{"type":"text","text":"hi"}}}}\n'
+ )
+ (folder / "updates.jsonl").write_text(hook_only + user_turn, encoding="utf-8")
+ assert agent_sessions.has_conversation("grok-build", handle) is True
+
+
+def test_grok_build_never_follows_a_session_id_out_of_its_home(
+ _agent_history_in_tmp: Path,
+) -> None:
+ """A crafted id with a path separator is not a lookup, it is a traversal."""
+ handle = agent_sessions.ResumeHandle(
+ kind="grok_session", id="../outside", captured_at=time.time()
+ )
+ assert agent_sessions.has_conversation("grok-build", handle) is False
+
+
+def test_grok_build_still_finds_its_session_behind_a_long_history(
+ _agent_history_in_tmp: Path,
+) -> None:
+ """The id is unique; cwd-encoded neighbour folders must not hide it."""
+ _, handle = agent_sessions.launch_extra("grok-build")
+ assert handle is not None
+ root = _agent_history_in_tmp / "grok-build" / "sessions"
+ for index in range(50):
+ other = root / f"other-{index}" / f"sess-{index}"
+ other.mkdir(parents=True)
+ (other / "updates.jsonl").write_text("{}\n", encoding="utf-8")
+ mine = root / "the-cwd" / handle.id
+ mine.mkdir(parents=True)
+ (mine / "updates.jsonl").write_text(
+ '{"params":{"update":{"sessionUpdate":"user_message_chunk"}}}\n', encoding="utf-8"
+ )
+ assert agent_sessions.has_conversation("grok-build", handle) is True
+
+
# ------------------------------------------------- per-CLI pane behaviour
@@ -489,6 +755,7 @@ def test_a_dropped_file_is_written_the_way_each_cli_reads_it() -> None:
assert at_style == '"/w/a b.py"' # a space would end the @reference early
assert drops.reference("/w/a.py", agent="claude") == "@/w/a.py"
assert drops.reference("/w/a.py", agent="opencode") == "@/w/a.py"
+ assert drops.reference("/w/a.py", agent="grok-build") == "@/w/a.py"
assert drops.reference("/w/a.py", agent="codex") == '"/w/a.py"'
# An entry nobody has registered gets the form that works everywhere.
assert drops.reference("/w/a.py", agent="nope") == '"/w/a.py"'
@@ -548,9 +815,7 @@ def test_a_booting_pane_of_a_new_cli_is_not_prompted_yet() -> None:
assert _ready_for_prompt(_Pane("opencode", ("Loading...",))) is False
assert _ready_for_prompt(_Pane("opencode", ("> ",))) is True
assert _ready_for_prompt(_Pane("kimi", ("starting",))) is False
- assert _ready_for_prompt(
- _Pane("codex", ("› Input disabled.",), cursor_visible=False)
- ) is False
+ assert _ready_for_prompt(_Pane("codex", ("› Input disabled.",), cursor_visible=False)) is False
assert _ready_for_prompt(_Pane("codex", ("› Ask Codex anything",))) is True
assert _ready_for_prompt(_Pane("codex", ("» Ask Codex anything",))) is True
# The one measured exception keeps its fast path.
diff --git a/tests/unit/agentic_ide/test_spawn_intent.py b/tests/unit/agentic_ide/test_spawn_intent.py
index 95917d2589..f0bbadcd5b 100644
--- a/tests/unit/agentic_ide/test_spawn_intent.py
+++ b/tests/unit/agentic_ide/test_spawn_intent.py
@@ -17,6 +17,7 @@ The discriminator is the terminal noun, and it is mandatory. Everything else
(verb, count, agent) is optional or defaulted, so the detector can only ever
claim a turn the user spelled out.
"""
+
from __future__ import annotations
import pytest
@@ -52,6 +53,9 @@ NAMES = ["Alex", "Blake", "Casey", "Dana"]
("Gib mir ein Codex Terminal", 1, "codex"), # i18n-allow: spoken input under test
# "Claude" alone is enough — nobody says the product name in full.
("Starte zwei Claude Terminals", 2, "claude"), # i18n-allow: spoken input under test
+ # Grok Build: short name and the two-word product name both count.
+ ("Open two Grok terminals", 2, "grok-build"),
+ ("Open a Grok Build terminal", 1, "grok-build"),
# Pane / window / tab are the same request.
("Öffne zwei neue Panes", 2, None), # i18n-allow: spoken input under test
("Open three more tabs", 3, None),
@@ -81,7 +85,7 @@ def test_a_number_above_the_cap_is_clamped_not_refused() -> None:
def test_an_ordinary_large_count_is_taken_at_face_value() -> None:
- """"as many as you want" is the point — 20 panes must not be trimmed to 12.
+ """ "as many as you want" is the point — 20 panes must not be trimmed to 12.
Guards the 2026-07-26 directive: the old cap of 12 silently rewrote what the
user asked for, which is worse than refusing it.
@@ -203,9 +207,7 @@ def test_recombined_completed_turn_does_not_hide_a_later_spawn_clause() -> None:
def test_question_inside_the_spawn_clause_still_never_opens_panes() -> None:
- utterance = (
- "Was passiert, wenn ich 5 Claude-Code-Terminals spawne?"
- ) # i18n-allow: spoken input under test
+ utterance = "Was passiert, wenn ich 5 Claude-Code-Terminals spawne?" # i18n-allow: spoken input under test
assert intent.detect_spawn(utterance, names=NAMES) is None
assert intent.owns_turn(utterance, names=NAMES) is False
@@ -267,16 +269,15 @@ def test_a_mixed_fleet_works_in_english_and_spanish() -> None:
assert english is not None
assert [(g.count, g.agent) for g in english.groups] == [(2, "codex"), (4, "claude")]
- spanish = intent.detect_spawn(
- "Abre tres terminales de Codex y dos de Claude", names=NAMES
- )
+ spanish = intent.detect_spawn("Abre tres terminales de Codex y dos de Claude", names=NAMES)
assert spanish is not None
assert [(g.count, g.agent) for g in spanish.groups] == [(3, "codex"), (2, "claude")]
def test_a_single_agent_request_is_still_one_group() -> None:
found = intent.detect_spawn(
- "Spawne fünf neue Claude Code Terminals", names=NAMES # i18n-allow: spoken input under test
+ "Spawne fünf neue Claude Code Terminals",
+ names=NAMES, # i18n-allow: spoken input under test
)
assert found is not None
assert [(g.count, g.agent) for g in found.groups] == [(5, "claude")]
@@ -285,7 +286,7 @@ def test_a_single_agent_request_is_still_one_group() -> None:
def test_an_unnamed_agent_stays_unnamed_so_the_panes_inherit() -> None:
- """"Three more terminals" must not be turned into a Claude request."""
+ """ "Three more terminals" must not be turned into a Claude request."""
found = intent.detect_spawn("Open three more terminals", names=NAMES)
assert found is not None
assert [(g.count, g.agent) for g in found.groups] == [(3, None)]
@@ -293,7 +294,7 @@ def test_an_unnamed_agent_stays_unnamed_so_the_panes_inherit() -> None:
def test_the_same_agent_named_twice_is_merged() -> None:
- """"Two Codex and two more Codex" is four Codex panes, not two groups."""
+ """ "Two Codex and two more Codex" is four Codex panes, not two groups."""
found = intent.detect_spawn(
"Open two Codex terminals and two more Codex terminals", names=NAMES
)
@@ -406,7 +407,7 @@ POSITIONS = ["T1", "T2", "T3", "T4"]
def test_a_mangled_call_sign_brief_still_reaches_its_pane() -> None:
- """"Terminal T2" garbled to "terminal tft zwei" must not size a fleet.
+ """ "Terminal T2" garbled to "terminal tft zwei" must not size a fleet.
The live failure: speech recognition mangled the call-sign, the addressing
detector found no pane, and the pane's NAME was re-read as a count — two
@@ -435,9 +436,7 @@ def test_a_briefed_position_never_becomes_a_fleet_size() -> None:
"there is no terminal two" — rather than opening panes the user never
asked for.
"""
- utterance = (
- "prompt wird du terminal tft zwei, dass es ein deep dive machen soll"
- ) # i18n-allow: production transcript under test
+ utterance = "prompt wird du terminal tft zwei, dass es ein deep dive machen soll" # i18n-allow: production transcript under test
assert intent.detect_spawn(utterance, names=["T1"]) is None
assert (
@@ -461,16 +460,14 @@ def test_a_brief_beside_a_real_fleet_size_still_spawns() -> None:
def test_an_elided_pane_noun_still_carries_its_fleet_size() -> None:
- """"… und öffne noch drei" keeps its three panes without repeating the noun.
+ """ "… und öffne noch drei" keeps its three panes without repeating the noun.
Ordinary spoken continuation elides a noun the sentence already
established; the opener and the additive in front of the count are what
mark it as a fleet size rather than task vocabulary, and the veto for the
briefed position must not swallow it.
"""
- utterance = (
- "prompte Terminal zwei und öffne noch drei" # i18n-allow: spoken input under test
- )
+ utterance = "prompte Terminal zwei und öffne noch drei" # i18n-allow: spoken input under test
found = intent.detect_spawn(utterance, names=["T1"])
assert found is not None
@@ -485,7 +482,7 @@ def test_an_elided_pane_noun_still_carries_its_fleet_size() -> None:
def test_an_opened_position_is_one_pane_not_a_count() -> None:
- """"öffne Terminal 2" opens ONE pane — the number is the pane's name.
+ """ "öffne Terminal 2" opens ONE pane — the number is the pane's name.
The open-verb sibling of the briefed shape: with no pane answering to the
position, the count fallback used to read the position's number as a
@@ -753,7 +750,7 @@ def test_corrections_replace_in_every_supported_locale(
def test_a_retraction_without_a_replacement_changes_nothing() -> None:
- """"nee" followed by no complete pane request keeps the original reading."""
+ """ "nee" followed by no complete pane request keeps the original reading."""
utterance = "Öffne zwei neue Codex Terminals, nee warte" # i18n-allow: spoken input under test
found = intent.detect_spawn(utterance, names=NAMES)
@@ -797,10 +794,8 @@ def test_a_task_after_the_second_fleet_sentence_still_reaches_the_panes() -> Non
def test_counts_inside_a_briefed_task_never_become_more_panes() -> None:
- """"…prompt them: create three config tabs" stays the task, not a fleet."""
- utterance = (
- "Open two terminals. Prompt them: create three config tabs for the app"
- )
+ """ "…prompt them: create three config tabs" stays the task, not a fleet."""
+ utterance = "Open two terminals. Prompt them: create three config tabs for the app"
found = intent.detect_spawn(utterance, names=NAMES)
@@ -833,7 +828,7 @@ def test_each_kind_gets_its_own_task() -> None:
def test_german_modal_briefs_route_by_kind() -> None:
- """"Die Claudes sollen …" hands the group its work without a verb in front."""
+ """ "Die Claudes sollen …" hands the group its work without a verb in front."""
utterance = (
"Öffne zwei Claude Terminals und einen Codex. Die Claudes sollen die "
"Tests fixen und der Codex soll die Docs aktualisieren."
@@ -846,19 +841,14 @@ def test_german_modal_briefs_route_by_kind() -> None:
def test_a_kind_the_brief_does_not_name_stays_blank() -> None:
- """"prompt the claudes …" deliberately leaves the codex without a task."""
- utterance = (
- "Open two claudes and one codex. Prompt the claudes to fix the "
- "failing tests."
- )
+ """ "prompt the claudes …" deliberately leaves the codex without a task."""
+ utterance = "Open two claudes and one codex. Prompt the claudes to fix the failing tests."
- assert intent.spawn_group_tasks(utterance) == {
- "claude": "fix the failing tests"
- }
+ assert intent.spawn_group_tasks(utterance) == {"claude": "fix the failing tests"}
def test_a_shared_brief_has_no_group_tasks() -> None:
- """"prompt each one to …" addresses everyone; the map must stand down."""
+ """ "prompt each one to …" addresses everyone; the map must stand down."""
utterance = (
"Spawn two Codex terminals and prompt each one to perform a read-only "
"platform compatibility review"
@@ -884,15 +874,10 @@ def test_work_in_front_of_the_first_kind_brief_disables_the_map() -> None:
def test_a_cli_named_inside_another_groups_task_is_not_an_addressee() -> None:
- """"prompt the claudes to fix codex bugs" briefs the claudes, not Codex."""
- utterance = (
- "Open two claude terminals. Prompt the claudes to fix the codex "
- "integration bugs."
- )
+ """ "prompt the claudes to fix codex bugs" briefs the claudes, not Codex."""
+ utterance = "Open two claude terminals. Prompt the claudes to fix the codex integration bugs."
- assert intent.spawn_group_tasks(utterance) == {
- "claude": "fix the codex integration bugs"
- }
+ assert intent.spawn_group_tasks(utterance) == {"claude": "fix the codex integration bugs"}
# --------------------------------------------------------------------------- #
@@ -934,7 +919,7 @@ def test_ordinary_tasks_are_not_divisions(task: str) -> None:
def test_prompt_them_does_not_leak_the_pronoun_into_the_task() -> None:
- """"prompt them, one fixes …" starts the task at the work, not at "them"."""
+ """ "prompt them, one fixes …" starts the task at the work, not at "them"."""
utterance = (
"spawn two new terminals and prompt them, one fixes a bug on macOS "
"and one fixes a bug on Linux"
@@ -988,7 +973,7 @@ def test_counts_in_the_task_half_never_add_panes(utterance: str) -> None:
def test_an_additive_extension_is_never_mistaken_for_task_talk() -> None:
- """"one MORE terminal for the tests" extends the fleet, full stop."""
+ """ "one MORE terminal for the tests" extends the fleet, full stop."""
found = intent.detect_spawn(
"Open two terminals and one more terminal for the tests", names=NAMES
)
@@ -1007,7 +992,7 @@ def test_a_named_groups_trailing_particle_is_not_a_predicate() -> None:
def test_a_garble_before_the_next_group_still_earns_the_question() -> None:
- """"two closed, one codex" garbles "Claudes" — Jarvis must ask, not guess.
+ """ "two closed, one codex" garbles "Claudes" — Jarvis must ask, not guess.
The old guard saw the codex six characters behind "closed" and treated it
as this group's real name — but it stands past a comma, in a group of its
@@ -1033,7 +1018,7 @@ def test_a_garble_before_the_next_group_still_earns_the_question() -> None:
def test_spoken_filler_in_front_of_the_enumeration_is_not_the_task() -> None:
- """"prompt them LIKE one fixes …" — the filler must not hide the division.
+ """ "prompt them LIKE one fixes …" — the filler must not hide the division.
The maintainer's own phrasing (2026-08-12). "like" in front of the first
enumerator kept it from opening its clause, so the distributive detector
diff --git a/tests/unit/workspace/test_agents.py b/tests/unit/workspace/test_agents.py
index 9987432724..d8ffca0f79 100644
--- a/tests/unit/workspace/test_agents.py
+++ b/tests/unit/workspace/test_agents.py
@@ -2,9 +2,11 @@
Detection runs against a fake prober — no real CLI is ever invoked.
"""
+
from __future__ import annotations
import asyncio
+import sys
import pytest
@@ -33,7 +35,7 @@ from jarvis.workspace.agents import (
# later addition into a test edit, which is the opposite of what an open
# registry is for. What must not break is that a shipped provider silently
# disappears.
-REQUIRED_CODING_AGENTS = frozenset({"claude", "codex", "opencode", "kimi", "glm"})
+REQUIRED_CODING_AGENTS = frozenset({"claude", "codex", "opencode", "kimi", "glm", "grok-build"})
def test_every_promised_coding_agent_is_registered() -> None:
@@ -90,6 +92,12 @@ def test_install_commands_are_runnable_or_honestly_absent() -> None:
assert install_command("kimi") == "npm install -g @moonshot-ai/kimi-code"
# A launch profile installs the binary it borrows.
assert install_command("glm") == "npm install -g @anthropic-ai/claude-code"
+ grok_install = install_command("grok-build")
+ assert grok_install is not None
+ if sys.platform == "win32":
+ assert "install.ps1" in grok_install
+ else:
+ assert "install.sh" in grok_install
assert install_command("nope") is None
@@ -103,6 +111,13 @@ def test_launch_command_is_bare_binary() -> None:
assert get_agent("opencode").launch_command == "opencode"
# The profile runs the borrowed binary, not a command named after itself.
assert get_agent("glm").launch_command == "claude"
+ grok = get_agent("grok-build")
+ assert grok is not None
+ assert grok.launch_command == "grok"
+ assert grok.launch_args == ("--no-auto-update",)
+ assert grok.file_reference == "at"
+ assert grok.account is not None
+ assert grok.account.env[0][0] == "GROK_HOME"
def test_build_agent_argv_wraps_command_in_a_shell() -> None:
@@ -153,10 +168,7 @@ class FakeProber:
self._statuses = statuses
async def probe_all(self, specs) -> dict[str, CliStatus]: # noqa: ANN001
- return {
- s.name: self._statuses.get(s.name, CliStatus(installed=False))
- for s in specs
- }
+ return {s.name: self._statuses.get(s.name, CliStatus(installed=False)) for s in specs}
@pytest.mark.asyncio
diff --git a/tests/unit/workspace/test_provider_parity.py b/tests/unit/workspace/test_provider_parity.py
index 408f30177a..c35c8cdb49 100644
--- a/tests/unit/workspace/test_provider_parity.py
+++ b/tests/unit/workspace/test_provider_parity.py
@@ -96,7 +96,17 @@ def test_no_pane_call_sign_can_shadow_a_cli_name() -> None:
reserved = names._reserved()
assert not {n.lower() for n in names.default_names(20)} & reserved
for name in workspace_agents.coding_agent_names():
- assert name.lower() in reserved
+ entry = workspace_agents.get_agent(name)
+ assert entry is not None
+ token = name.lower()
+ if token.isalpha() and len(token) > 1:
+ assert token in reserved
+ continue
+ # Hyphenated registry keys are not call-sign shaped, so the spoken
+ # product word has to be reserved instead — otherwise "Grok" could
+ # still be handed out as a pane name.
+ first = entry.display_name.split()[0].lower()
+ assert first in reserved, f"{name} has no reserved spoken token"
def test_every_coding_cli_either_resumes_or_says_it_cannot() -> None:
diff --git a/tests/unit/workspace/test_trust.py b/tests/unit/workspace/test_trust.py
index f8f3bdd58a..0f232df68b 100644
--- a/tests/unit/workspace/test_trust.py
+++ b/tests/unit/workspace/test_trust.py
@@ -1,4 +1,5 @@
-"""Trust pre-seed for Claude Code (~/.claude.json) and Codex (config.toml)."""
+"""Trust pre-seed for Claude Code, Codex and Grok Build."""
+
from __future__ import annotations
import json
@@ -66,6 +67,41 @@ def test_claude_is_idempotent_noop_second_run(tmp_path: Path) -> None:
assert res2.method == "noop"
+def test_grok_build_writes_trusted_folders_toml(tmp_path: Path) -> None:
+ home = tmp_path / "home"
+ home.mkdir()
+ repo = _repo(tmp_path)
+
+ [res] = ensure_trusted(repo, ["grok-build"], home=home)
+ assert res.ok and res.agent == "grok-build"
+
+ parsed = tomllib.loads((home / ".grok" / "trusted_folders.toml").read_text(encoding="utf-8"))
+ assert parsed["folders"][str(repo)]["trusted"] is True
+
+
+def test_grok_build_preserves_other_folders(tmp_path: Path) -> None:
+ home = tmp_path / "home"
+ (home / ".grok").mkdir(parents=True)
+ repo = _repo(tmp_path)
+ (home / ".grok" / "trusted_folders.toml").write_text(
+ "[folders.'C:/elsewhere']\ntrusted = true\n",
+ encoding="utf-8",
+ )
+ ensure_trusted(repo, ["grok-build"], home=home)
+ parsed = tomllib.loads((home / ".grok" / "trusted_folders.toml").read_text(encoding="utf-8"))
+ assert parsed["folders"]["C:/elsewhere"]["trusted"] is True
+ assert parsed["folders"][str(repo)]["trusted"] is True
+
+
+def test_test_mode_ignores_real_grok_home_env(tmp_path: Path, monkeypatch) -> None:
+ monkeypatch.setenv("GROK_HOME", str(tmp_path / "REAL_DO_NOT_TOUCH"))
+ home = tmp_path / "home"
+ home.mkdir()
+ ensure_trusted(_repo(tmp_path), ["grok-build"], home=home)
+ assert (home / ".grok" / "trusted_folders.toml").exists()
+ assert not (tmp_path / "REAL_DO_NOT_TOUCH").exists()
+
+
def test_codex_writes_trust_level_parseable_toml(tmp_path: Path) -> None:
home = tmp_path / "home"
home.mkdir()
@@ -171,9 +207,7 @@ def test_an_added_accounts_config_dir_is_trusted_as_well(tmp_path: Path) -> None
repo = _repo(tmp_path)
account = tmp_path / "accounts" / "second-seat"
- results = ensure_trusted(
- repo, ["claude"], home=home, config_dirs={"claude": [account]}
- )
+ results = ensure_trusted(repo, ["claude"], home=home, config_dirs={"claude": [account]})
assert [r.ok for r in results] == [True, True]
for cfg in (home / ".claude.json", account / ".claude.json"):
@@ -202,9 +236,7 @@ def test_an_account_directory_for_another_agent_is_ignored(tmp_path: Path) -> No
home = tmp_path / "home"
home.mkdir()
account = tmp_path / "accounts" / "claude-seat"
- ensure_trusted(
- _repo(tmp_path), ["codex"], home=home, config_dirs={"claude": [account]}
- )
+ ensure_trusted(_repo(tmp_path), ["codex"], home=home, config_dirs={"claude": [account]})
assert not account.exists()