mirror of
https://github.com/0xWheatyz/handler.git
synced 2026-08-30 05:26:23 +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:
@@ -22,6 +22,7 @@ const empty: NewProjectBody = {
|
||||
root_dir: "",
|
||||
git_remote: "",
|
||||
credential_ref: "",
|
||||
init_mise: false,
|
||||
};
|
||||
|
||||
export function RepositoriesSection() {
|
||||
@@ -163,6 +164,28 @@ export function RepositoriesSection() {
|
||||
</>
|
||||
)}
|
||||
|
||||
{!editing && (
|
||||
<label className="hstack" style={{ gap: 8, cursor: "pointer", marginTop: 14 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.init_mise}
|
||||
onChange={(e) => setForm({ ...form, init_mise: e.target.checked })}
|
||||
/>
|
||||
<span style={{ fontSize: "var(--text-sm)" }}>
|
||||
Initialize mise — after the clone, run an agent that writes a{" "}
|
||||
<span className="mono">.mise.toml</span> with a{" "}
|
||||
<span className="mono">[tasks.test]</span> task for this repo’s stack, then
|
||||
commits and pushes it. Needed for repos that don’t define one yet.
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
{!editing && form.init_mise && form.mode === "manual" && !form.git_remote.trim() && (
|
||||
<p className="faint" style={{ fontSize: "var(--text-xs)", margin: "6px 0 0" }}>
|
||||
A git remote is required to push the new <span className="mono">.mise.toml</span> —
|
||||
add one above, or mise won’t be initialized.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="hstack mt14">
|
||||
<Button variant="primary" disabled={s.cmd.busy || !canSave} onClick={save}>
|
||||
{editing ? "Save changes" : form.mode === "server" ? "Add & pull" : "Register"}
|
||||
|
||||
@@ -146,6 +146,9 @@ export interface NewProjectBody {
|
||||
root_dir: string;
|
||||
git_remote: string;
|
||||
credential_ref: string;
|
||||
/* Bootstrap tooling: after the clone, run an agent that writes + commits + pushes a
|
||||
* .mise.toml with a [tasks.test] task for the repo's stack. Needs a git remote. */
|
||||
init_mise: boolean;
|
||||
}
|
||||
export interface ScheduleBody {
|
||||
name_prefix: string;
|
||||
@@ -535,12 +538,14 @@ export function DashboardProvider({
|
||||
repo: b.repo.trim(),
|
||||
id: b.id.trim() || null,
|
||||
credential_ref: b.credential_ref.trim() || null,
|
||||
init_mise: b.init_mise,
|
||||
}
|
||||
: {
|
||||
id: b.id.trim(),
|
||||
root_dir: b.root_dir.trim(),
|
||||
git_remote: b.git_remote.trim() || null,
|
||||
credential_ref: b.credential_ref.trim() || null,
|
||||
init_mise: b.init_mise,
|
||||
};
|
||||
const created = await clientRef.current.api<Project>("/projects", {
|
||||
method: "POST",
|
||||
@@ -573,6 +578,35 @@ export function DashboardProvider({
|
||||
} else {
|
||||
setCmd({ text: `repository '${created.id}' registered`, error: false, busy: false });
|
||||
}
|
||||
// "Initialize mise": follow the bootstrap agent's launch so the operator knows a
|
||||
// .mise.toml is being written, committed, and pushed for them.
|
||||
if (created.mise_init_command_id != null) {
|
||||
setCmd({
|
||||
text: `repository '${created.id}': launching a mise-init agent to create .mise.toml…`,
|
||||
error: false,
|
||||
busy: true,
|
||||
});
|
||||
const mise = await clientRef.current.trackCommand(created.mise_init_command_id);
|
||||
if (!mise) {
|
||||
setCmd({
|
||||
text: `repository '${created.id}' registered; mise-init still starting (see Activity). Is the worker up?`,
|
||||
error: false,
|
||||
busy: false,
|
||||
});
|
||||
} else if (mise.status === "done") {
|
||||
setCmd({
|
||||
text: `repository '${created.id}' registered; a mise-init agent is now writing, committing, and pushing .mise.toml (watch it in Runs).`,
|
||||
error: false,
|
||||
busy: false,
|
||||
});
|
||||
} else {
|
||||
setCmd({
|
||||
text: `repository '${created.id}' registered but the mise-init agent failed to launch — ${mise.error ?? ""}`,
|
||||
error: true,
|
||||
busy: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (e instanceof AuthError) return false;
|
||||
|
||||
@@ -18,6 +18,9 @@ export interface Project {
|
||||
created_at: string;
|
||||
/* Present on the registration response in git-server mode: the enqueued clone. */
|
||||
sync_command_id?: number | null;
|
||||
/* Present on the registration response when "Initialize mise" was ticked: the
|
||||
* enqueued bootstrap agent that writes + commits + pushes a .mise.toml. */
|
||||
mise_init_command_id?: number | null;
|
||||
}
|
||||
|
||||
export interface Agent {
|
||||
|
||||
Reference in New Issue
Block a user