mirror of
https://github.com/0xWheatyz/handler.git
synced 2026-08-30 04:26:24 +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:
@@ -50,6 +50,46 @@ def test_create_project_from_server_with_ssh_key(client, auth, env, secret_key):
|
||||
assert cmd["project_id"] == "coolproj"
|
||||
|
||||
|
||||
def test_create_project_with_init_mise_enqueues_bootstrap(client, auth, env, secret_key):
|
||||
_add_server(client, auth, generate_ssh_key=True)
|
||||
r = client.post(
|
||||
"/projects",
|
||||
json={"git_server": "github.com", "repo": "me/coolproj", "init_mise": True},
|
||||
headers=auth,
|
||||
)
|
||||
assert r.status_code == 201, r.text
|
||||
body = r.json()
|
||||
assert body["sync_command_id"] is not None
|
||||
assert body["mise_init_command_id"] is not None
|
||||
# The clone is queued before the bootstrap so it runs first (FIFO by id).
|
||||
assert body["mise_init_command_id"] > body["sync_command_id"]
|
||||
cmd = client.get(f"/commands/{body['mise_init_command_id']}", headers=auth).json()
|
||||
assert cmd["type"] == "mise_init"
|
||||
assert cmd["project_id"] == "coolproj"
|
||||
|
||||
|
||||
def test_create_project_without_init_mise_skips_bootstrap(client, auth, env, secret_key):
|
||||
_add_server(client, auth, generate_ssh_key=True)
|
||||
r = client.post(
|
||||
"/projects", json={"git_server": "github.com", "repo": "me/plain"}, headers=auth
|
||||
)
|
||||
assert r.status_code == 201, r.text
|
||||
assert r.json()["mise_init_command_id"] is None
|
||||
|
||||
|
||||
def test_init_mise_without_remote_does_not_enqueue(client, auth, env, tmp_path):
|
||||
# Manual mode with no git_remote: nothing to push to, so no bootstrap is queued.
|
||||
root = tmp_path / "local"
|
||||
root.mkdir()
|
||||
r = client.post(
|
||||
"/projects",
|
||||
json={"id": "local", "root_dir": str(root), "init_mise": True},
|
||||
headers=auth,
|
||||
)
|
||||
assert r.status_code == 201, r.text
|
||||
assert r.json()["mise_init_command_id"] is None
|
||||
|
||||
|
||||
def test_create_project_from_server_https_without_key(client, auth, env):
|
||||
_add_server(client, auth, hostname="git.corp", forge_type="gitea",
|
||||
base_url="https://git.corp:8443")
|
||||
|
||||
Reference in New Issue
Block a user