mirror of
https://github.com/0xWheatyz/handler.git
synced 2026-08-30 23:36:25 +00:00
feat(repos): add an "Initialize mise" option to the add-repo step
Some repos an operator wants to manage don't yet define the `.mise.toml` `[tasks.test]` task the spawn gate hard-requires — a chicken-and-egg, since you can't run an agent to author that file without it. This adds a one-click bootstrap. Ticking "Initialize mise" on the add step enqueues a `mise_init` command after the clone. The worker launches a dedicated agent that detects the repo's stack, writes a `.mise.toml` with a canonical `[tasks.test]` task, and commits + pushes it. That agent runs with the test-task gate off (creating the task is the point) and a `HANDLER_MISE_INIT` marker on, so its hooks enforce a bootstrap contract instead of the normal test gate: - Stop hook blocks the turn until `.mise.toml` defines `[tasks.test]` and the change is committed (clean tree) and pushed (no commits ahead of an upstream) — so claude cannot end before the work has actually landed. - git-push hook lets the bootstrap push through, skipping the test/build gate (there may be no working suite yet) so the file reaches the remote. Backend: `mise_init` command type (+ migration 0006), a shared `control.mise` helper for the test-task check, `spawn(require_tests=, mise_init=)`, gitops `is_clean`/`ahead_count`, and `init_mise` on the project-create API (only acts when a git remote exists to push to). Frontend: the checkbox, plumbed through the store, following the launch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BxKY28XKCM6o4ag3nmaVsZ
This commit is contained in:
@@ -68,6 +68,32 @@ def test_spawn_creates_agent_settings_and_session(env, fake_tmux):
|
||||
assert call["env"]["DATABASE_URL"] == env["url"]
|
||||
|
||||
|
||||
def test_spawn_mise_init_skips_test_gate_and_marks_env(env, fake_tmux):
|
||||
# A repo with no .mise.toml at all: the normal gate would refuse, but the mise-init
|
||||
# bootstrap agent must launch anyway (creating that file is its whole job).
|
||||
root = env["tmp"] / "proj"
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
_register_project(root)
|
||||
|
||||
agent = spawn.spawn("proj", "mise-init", require_tests=False, mise_init=True)
|
||||
|
||||
with get_engine().begin() as conn:
|
||||
assert repo.get_agent_by_name(conn, "proj", "mise-init")["id"] == agent["id"]
|
||||
# The launched session carries HANDLER_MISE_INIT so its hooks enforce commit + push.
|
||||
call = fake_tmux["calls"]["new_session"][0]
|
||||
assert call["env"]["HANDLER_MISE_INIT"] == "1"
|
||||
|
||||
|
||||
def test_spawn_still_gates_without_mise_init_flag(env, fake_tmux):
|
||||
root = env["tmp"] / "proj"
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
_register_project(root)
|
||||
# require_tests defaults on, so a normal spawn against a mise-less repo still refuses.
|
||||
with pytest.raises(spawn.SpawnError, match="no .mise.toml"):
|
||||
spawn.spawn("proj", "api")
|
||||
assert fake_tmux["calls"]["new_session"] == []
|
||||
|
||||
|
||||
def test_kill_sets_done_and_kills_session(env, fake_tmux):
|
||||
root = env["tmp"] / "proj"
|
||||
_write_mise(root, with_test=True)
|
||||
|
||||
Reference in New Issue
Block a user