mirror of
https://github.com/0xWheatyz/handler.git
synced 2026-08-31 19:46:24 +00:00
24b8c44451
The mise-init agent wedged on launch and the UI reported it green. Three distinct problems, fixed together: 1. Onboarding wedge (the proximate bug). A freshly-installed claude opens interactive setup — theme picker, then a folder-trust prompt — before the REPL. A detached tmux agent has no one to answer it, so it sat on the theme picker forever while agents.status said 'working'. New control.claude_config.ensure_onboarded() marks onboarding complete and trusts the working dir in ~/.claude.json (merge-only, so the login flow's oauthAccount survives); spawn() calls it before launching. 2. Config-name gate. control/mise.py only recognized `.mise.toml`, so a repo shipping `mise.toml` (no dot) — or config under `.config/mise/` — failed the [tasks.test] gate even when healthy. It now accepts the filenames mise itself reads and scans them all for the test task. 3. "Done" != done (the design gap). A spawned agent's real state lives in its tmux pane, but the socket is control-container-only, so the API couldn't see it. The worker now snapshots each working agent's pane tail (last ~40 lines) into two new agents columns (last_output, output_at, migration 0007) on its existing poll loop; the API serializes them and AgentsSection renders a live-output <pre> under each running agent. A wedged agent now shows the theme picker instead of a misleading green badge. Tests: home-dir writes are isolated to tmp in conftest; added coverage for claude_config seeding/merge, the mise filename set, the worker capture (including dead-session skip), and the API serialization. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BxKY28XKCM6o4ag3nmaVsZ
59 lines
2.0 KiB
Python
59 lines
2.0 KiB
Python
"""The mise-config gate — one source of truth for "does this project define the canonical
|
|
``[tasks.test]`` task".
|
|
|
|
Shared by the spawn gate (``control.spawn.require_test_task``, which refuses to launch an
|
|
agent against a project with no test task) and the mise-init Stop hook (which refuses to
|
|
let the bootstrap agent finish until the task exists and is committed + pushed).
|
|
|
|
mise reads several config filenames, not just ``.mise.toml`` — a repo may ship ``mise.toml``
|
|
(no leading dot) or keep config under ``.config/mise/`` — so the gate accepts any of them
|
|
and treats a ``[tasks.test]`` in *any* present config as satisfying the requirement.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import tomllib
|
|
|
|
# The config filenames mise itself looks for, in the rough precedence order it uses. A
|
|
# project only needs one; we scan all present ones for the test task.
|
|
CONFIG_NAMES = (
|
|
"mise.toml",
|
|
".mise.toml",
|
|
"mise.local.toml",
|
|
".mise.local.toml",
|
|
os.path.join(".config", "mise.toml"),
|
|
os.path.join(".config", "mise", "config.toml"),
|
|
)
|
|
|
|
|
|
def config_paths(working_dir: str) -> list[str]:
|
|
return [os.path.join(working_dir, name) for name in CONFIG_NAMES]
|
|
|
|
|
|
def existing_config(working_dir: str) -> str | None:
|
|
"""Path to the first present mise config file under ``working_dir``, else ``None``."""
|
|
for path in config_paths(working_dir):
|
|
if os.path.exists(path):
|
|
return path
|
|
return None
|
|
|
|
|
|
def has_config(working_dir: str) -> bool:
|
|
return existing_config(working_dir) is not None
|
|
|
|
|
|
def has_test_task(working_dir: str) -> bool:
|
|
"""True when any present mise config defines a ``[tasks.test]`` task."""
|
|
for path in config_paths(working_dir):
|
|
if not os.path.exists(path):
|
|
continue
|
|
try:
|
|
with open(path, "rb") as fh:
|
|
data = tomllib.load(fh)
|
|
except (OSError, tomllib.TOMLDecodeError):
|
|
continue
|
|
if "test" in (data.get("tasks") or {}):
|
|
return True
|
|
return False
|