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(self-build): choose which repositories merge loop pull requests on green CI (#780)

Ruben Lütkecbed830ff24a
diff --git a/docs/self-build.md b/docs/self-build.md
index d4767d0b81..94b3ba40c0 100644
--- a/docs/self-build.md
+++ b/docs/self-build.md
@@ -209,7 +209,9 @@ detail.
- **Pause building** is the loop's kill switch. **Stop all agents** engages
the society kill switch after a confirmation (which pauses building too);
while it is engaged the page says so and offers Release.
-- **Settings → General → Self-building** edits `[self_build]`.
+- **Settings → General → Self-building** edits `[self_build]`, including the
+ repositories whose loop pull requests merge on green CI (`code_land_repos`),
+ shown with a warning that a listed repository changes without a review.
- A **"Built by {assistant}"** badge marks skills (Skills list and detail),
routines (an agent's routines) and agents (the agent card) that a build
created, and opens that build.
diff --git a/dodaios/core/config_writer.py b/dodaios/core/config_writer.py
index 5d16d78d2f..fea2733ec2 100644
--- a/dodaios/core/config_writer.py
+++ b/dodaios/core/config_writer.py
@@ -1294,13 +1294,13 @@ SELF_BUILD_SETTING_KEYS: frozenset[str] = frozenset(
{
"enabled", "silent_days", "memory", "skill", "routine", "agent", "code",
"trial_days", "trial_uses", "max_builds_per_day", "max_agents_per_week",
- "max_open_trials", "max_code_runs_per_day", "max_rejections",
+ "max_open_trials", "max_code_runs_per_day", "max_rejections", "code_land_repos",
}
)
def set_self_build_settings(
- values: dict[str, str | bool | int], *, path: Path = DEFAULT_CONFIG_FILE
+ values: dict[str, str | bool | int | list[str]], *, path: Path = DEFAULT_CONFIG_FILE
) -> None:
"""Persist a validated ``[self_build]`` patch in one atomic write.
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/de.json b/dodaios/ui/web/frontend/src/i18n/locales/de.json
index 21ed921929..97c65f9e29 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/de.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/de.json
@@ -3552,7 +3552,12 @@
"silent_days": "Ruhige erste Tage"
},
"save_error": "Speichern fehlgeschlagen: {detail}",
- "unavailable": "Diese Einstellungen konnten nicht geladen werden."
+ "unavailable": "Diese Einstellungen konnten nicht geladen werden.",
+ "land_title": "Code-Änderungen selbst mergen",
+ "land_description": "Repositories in dieser Liste bekommen Pull Requests, die nach grüner CI gemergt werden. Alle anderen bekommen Entwurfs-Pull-Requests, die du mergst.",
+ "land_warning": "Der Code eines gelisteten Repositorys ändert sich, ohne dass du den Pull Request vorher ansiehst. Füge nur Repositorys hinzu, deren Tests du vertraust.",
+ "land_add": "Repository hinzufügen",
+ "land_remove": "{repo} entfernen"
}
},
"telephony_view": {
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/en.json b/dodaios/ui/web/frontend/src/i18n/locales/en.json
index fd8f1ea3c2..b77e792de4 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/en.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/en.json
@@ -3552,7 +3552,12 @@
"silent_days": "Quiet first days"
},
"save_error": "Could not save: {detail}",
- "unavailable": "These settings could not be loaded."
+ "unavailable": "These settings could not be loaded.",
+ "land_title": "Merge code changes on their own",
+ "land_description": "Repositories listed here get pull requests that merge once CI is green. Every other repository gets draft pull requests that you merge.",
+ "land_warning": "A listed repository's code changes without you looking at the pull request first. Only add repositories you trust the tests of.",
+ "land_add": "Add repository",
+ "land_remove": "Remove {repo}"
}
},
"telephony_view": {
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/es.json b/dodaios/ui/web/frontend/src/i18n/locales/es.json
index 3cac0898f5..30ca6b8d2e 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/es.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/es.json
@@ -3552,7 +3552,12 @@
"silent_days": "Primeros días en silencio"
},
"save_error": "No se pudo guardar: {detail}",
- "unavailable": "No se pudieron cargar estos ajustes."
+ "unavailable": "No se pudieron cargar estos ajustes.",
+ "land_title": "Fusionar cambios de código por su cuenta",
+ "land_description": "Los repositorios de esta lista reciben pull requests que se fusionan cuando la CI está en verde. Los demás reciben pull requests en borrador que fusionas tú.",
+ "land_warning": "El código de un repositorio de la lista cambia sin que mires antes el pull request. Añade solo repositorios en cuyas pruebas confíes.",
+ "land_add": "Añadir repositorio",
+ "land_remove": "Quitar {repo}"
}
},
"telephony_view": {
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/pt.json b/dodaios/ui/web/frontend/src/i18n/locales/pt.json
index 5608b849e8..c312fcfe49 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/pt.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/pt.json
@@ -3552,7 +3552,12 @@
"silent_days": "Primeiros dias em silêncio"
},
"save_error": "Não foi possível guardar: {detail}",
- "unavailable": "Não foi possível carregar estas definições."
+ "unavailable": "Não foi possível carregar estas definições.",
+ "land_title": "Integrar alterações de código sozinho",
+ "land_description": "Os repositórios desta lista recebem pull requests que são integrados quando a CI fica verde. Os restantes recebem pull requests em rascunho que é o utilizador a integrar.",
+ "land_warning": "O código de um repositório da lista muda sem que veja primeiro o pull request. Adicione apenas repositórios em cujos testes confia.",
+ "land_add": "Adicionar repositório",
+ "land_remove": "Remover {repo}"
}
},
"telephony_view": {
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/de.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/de.json
index 5fb33aa991..4dd1ad818a 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/de.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/de.json
@@ -106,7 +106,10 @@
"tokens": "{count} Tokens",
"history": "Verlauf",
"note": "Notiz",
- "opened": "eröffnet"
+ "opened": "eröffnet",
+ "code_branch": "Branch",
+ "code_pr": "Pull Request",
+ "code_draft": "Entwurfs-Pull-Request"
},
"outcome": {
"used": "genutzt",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/en.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/en.json
index bcb908353c..9ee989e824 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/en.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/en.json
@@ -106,7 +106,10 @@
"tokens": "{count} tokens",
"history": "History",
"note": "Note",
- "opened": "opened"
+ "opened": "opened",
+ "code_branch": "branch",
+ "code_pr": "pull request",
+ "code_draft": "draft pull request"
},
"outcome": {
"used": "used",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/es.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/es.json
index 4ae2bb7bcf..1e9e914d6e 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/es.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/es.json
@@ -106,7 +106,10 @@
"tokens": "{count} tokens",
"history": "Historial",
"note": "Nota",
- "opened": "abierto"
+ "opened": "abierto",
+ "code_branch": "rama",
+ "code_pr": "pull request",
+ "code_draft": "pull request en borrador"
},
"outcome": {
"used": "usado",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/pt.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/pt.json
index cce2e3f750..6a0adfb026 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/pt.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/pt.json
@@ -106,7 +106,10 @@
"tokens": "{count} tokens",
"history": "Histórico",
"note": "Nota",
- "opened": "aberto"
+ "opened": "aberto",
+ "code_branch": "ramo",
+ "code_pr": "pull request",
+ "code_draft": "pull request em rascunho"
},
"outcome": {
"used": "utilizado",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/self_build/zh.json b/dodaios/ui/web/frontend/src/i18n/locales/self_build/zh.json
index ce21d8d2da..9c3ad41660 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/self_build/zh.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/self_build/zh.json
@@ -106,7 +106,10 @@
"tokens": "{count} 个 token",
"history": "历史",
"note": "备注",
- "opened": "创建于"
+ "opened": "创建于",
+ "code_branch": "分支",
+ "code_pr": "拉取请求",
+ "code_draft": "草稿拉取请求"
},
"outcome": {
"used": "已使用",
diff --git a/dodaios/ui/web/frontend/src/i18n/locales/zh.json b/dodaios/ui/web/frontend/src/i18n/locales/zh.json
index 010d071c6c..5752c54bee 100644
--- a/dodaios/ui/web/frontend/src/i18n/locales/zh.json
+++ b/dodaios/ui/web/frontend/src/i18n/locales/zh.json
@@ -3552,7 +3552,12 @@
"silent_days": "最初的安静天数"
},
"save_error": "无法保存:{detail}",
- "unavailable": "无法加载这些设置。"
+ "unavailable": "无法加载这些设置。",
+ "land_title": "自动合并代码更改",
+ "land_description": "列表中的仓库会收到在 CI 通过后自动合并的拉取请求。其他仓库只会收到由你合并的草稿拉取请求。",
+ "land_warning": "列表中仓库的代码会在你未查看拉取请求的情况下被更改。只添加你信任其测试的仓库。",
+ "land_add": "添加仓库",
+ "land_remove": "移除 {repo}"
}
},
"telephony_view": {
diff --git a/dodaios/ui/web/frontend/src/lib/selfBuildApi.ts b/dodaios/ui/web/frontend/src/lib/selfBuildApi.ts
index 3d263c04b5..d225f10135 100644
--- a/dodaios/ui/web/frontend/src/lib/selfBuildApi.ts
+++ b/dodaios/ui/web/frontend/src/lib/selfBuildApi.ts
@@ -35,6 +35,11 @@ export interface BuildArtefact {
id?: string;
label?: string;
url?: string;
+ /** Code builds: the repository, branch and pull request. */
+ repo?: string;
+ branch?: string;
+ number?: number;
+ draft?: boolean;
[key: string]: unknown;
}
@@ -109,6 +114,8 @@ export interface SelfBuildSettings {
max_open_trials: number;
max_code_runs_per_day: number;
max_rejections: number;
+ /** Repositories (`owner/name`) whose loop pull requests merge after green CI. */
+ code_land_repos: string[];
}
export interface SelfBuildSettingsPayload {
diff --git a/dodaios/ui/web/frontend/src/views/SelfBuildView.test.tsx b/dodaios/ui/web/frontend/src/views/SelfBuildView.test.tsx
index 0c31356a3b..f3badada07 100644
--- a/dodaios/ui/web/frontend/src/views/SelfBuildView.test.tsx
+++ b/dodaios/ui/web/frontend/src/views/SelfBuildView.test.tsx
@@ -56,7 +56,13 @@ const BUILDS: Build[] = [
case: "You summarised the PR list every morning.",
}),
build({ id: "k1", state: "kept", title: "Mail humanizer", artefact: { type: "skill", id: "humanizer" } }),
- build({ id: "u1", kind: "code", state: "undone", title: "Fix the flaky test" }),
+ build({
+ id: "u1",
+ kind: "code",
+ state: "undone",
+ title: "Fix the flaky test",
+ artefact: { type: "code", id: "https://github.com/octo/app/pull/7", repo: "octo/app", number: 7, draft: true, url: "https://github.com/octo/app/pull/7" },
+ }),
];
const STATUS: SelfBuildStatus = {
@@ -235,3 +241,21 @@ describe("BuiltByBadge", () => {
expect(useSelfBuildFocus.getState().buildId).toBe("k1");
});
});
+
+describe("BuildDetail for code", () => {
+ beforeEach(async () => {
+ setUiLanguage("en");
+ await loadLocaleChunk("self_build");
+ });
+ afterEach(() => cleanup());
+
+ it("names the pull request, not its URL, and links to it", async () => {
+ installFetch();
+ useSelfBuildFocus.getState().request("u1");
+ renderWith(<SelfBuildView />);
+ const detail = await screen.findByTestId("build-detail");
+ expect(within(detail).getByText("octo/app#7")).toBeTruthy();
+ expect(within(detail).getByText("draft pull request")).toBeTruthy();
+ expect(within(detail).getByRole("link", { name: /open/i }).getAttribute("href")).toBe("https://github.com/octo/app/pull/7");
+ });
+});
diff --git a/dodaios/ui/web/frontend/src/views/selfBuild/BuildDetail.tsx b/dodaios/ui/web/frontend/src/views/selfBuild/BuildDetail.tsx
index 8a59225394..8ddea0609a 100644
--- a/dodaios/ui/web/frontend/src/views/selfBuild/BuildDetail.tsx
+++ b/dodaios/ui/web/frontend/src/views/selfBuild/BuildDetail.tsx
@@ -145,10 +145,10 @@ export function BuildDetail({
</Section>
<Section label={t("self_build.detail.made")}>
- {artefact.type && artefact.id ? (
- <p className="flex min-w-0 items-center gap-2 text-base text-foreground">
- <span className="truncate">{artefact.label || artefact.id}</span>
- <span className="shrink-0 text-sm text-muted-foreground">{artefact.type}</span>
+ {artefact.type && (artefact.id || artefact.branch) ? (
+ <p className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-base text-foreground">
+ <span className="truncate">{artefactLabel(artefact, t)}</span>
+ <span className="shrink-0 text-sm text-muted-foreground">{artefactKind(artefact, t)}</span>
{typeof artefact.url === "string" && /^https?:\/\//.test(artefact.url) && (
<a
href={artefact.url}
@@ -245,6 +245,23 @@ export function BuildDetail({
);
}
+/** What the person reads for what a build made: its name, never a raw id when a better one exists. */
+function artefactLabel(artefact: Build["artefact"], t: (key: string) => string): string {
+ const str = (key: string) => (typeof artefact[key] === "string" ? (artefact[key] as string) : "");
+ if (artefact.type === "code") {
+ const repo = str("repo");
+ if (typeof artefact.number === "number") return `${repo}#${artefact.number}`;
+ return `${repo}${repo && str("branch") ? " · " : ""}${str("branch")}` || t("self_build.detail.made_none");
+ }
+ return str("label") || str("name") || str("id");
+}
+
+function artefactKind(artefact: Build["artefact"], t: (key: string) => string): string {
+ if (artefact.type !== "code") return String(artefact.type);
+ if (typeof artefact.number !== "number") return t("self_build.detail.code_branch");
+ return artefact.draft === false ? t("self_build.detail.code_pr") : t("self_build.detail.code_draft");
+}
+
function stateLabel(t: (key: string) => string, state: string): string {
const key = `self_build.state.${state}`;
const label = t(key);
diff --git a/dodaios/ui/web/frontend/src/views/settings/SelfBuildGroup.test.tsx b/dodaios/ui/web/frontend/src/views/settings/SelfBuildGroup.test.tsx
index 27873b1bfa..fa14406d13 100644
--- a/dodaios/ui/web/frontend/src/views/settings/SelfBuildGroup.test.tsx
+++ b/dodaios/ui/web/frontend/src/views/settings/SelfBuildGroup.test.tsx
@@ -25,6 +25,7 @@ const SETTINGS = {
max_open_trials: 5,
max_code_runs_per_day: 1,
max_rejections: 2,
+ code_land_repos: ["octo/app"],
};
function installFetch() {
@@ -84,4 +85,16 @@ describe("SelfBuildGroup", () => {
fireEvent.blur(field);
await waitFor(() => expect(puts).toEqual([{ max_builds_per_day: 50 }]));
});
+
+ it("adds and removes a repository that merges on its own, with a warning in sight", async () => {
+ const puts = installFetch();
+ renderGroup();
+ const row = await screen.findByTestId("self-build-land-repos");
+ expect(row.textContent).toMatch(/without you looking at the pull request/);
+ fireEvent.change(within(row).getByRole("textbox"), { target: { value: "me/tool" } });
+ fireEvent.click(within(row).getByRole("button", { name: "Add repository" }));
+ await waitFor(() => expect(puts.at(-1)).toEqual({ code_land_repos: ["octo/app", "me/tool"] }));
+ fireEvent.click(within(row).getByRole("button", { name: "Remove octo/app" }));
+ await waitFor(() => expect(puts.at(-1)).toEqual({ code_land_repos: ["me/tool"] }));
+ });
});
diff --git a/dodaios/ui/web/frontend/src/views/settings/SelfBuildGroup.tsx b/dodaios/ui/web/frontend/src/views/settings/SelfBuildGroup.tsx
index 0881af9eb4..06879d331c 100644
--- a/dodaios/ui/web/frontend/src/views/settings/SelfBuildGroup.tsx
+++ b/dodaios/ui/web/frontend/src/views/settings/SelfBuildGroup.tsx
@@ -7,6 +7,7 @@
* running loop reads the new values on its next decision, no restart.
*/
import { useEffect, useState } from "react";
+import { X } from "lucide-react";
import { Switch } from "@/components/ui/switch";
import { fill, useT } from "@/i18n";
import { cn } from "@/lib/utils";
@@ -135,6 +136,11 @@ export function SelfBuildGroup() {
))}
</div>
</SettingsRow>
+ <LandReposRow
+ repos={payload.settings.code_land_repos ?? []}
+ disabled={save.isPending}
+ onChange={(code_land_repos) => apply({ code_land_repos })}
+ />
</SettingsCard>
)}
{error && <SettingsNote tone="error" className="mt-2">{error}</SettingsNote>}
@@ -192,3 +198,81 @@ function NumberField({
</label>
);
}
+
+/**
+ * Repositories where a loop pull request merges itself once CI is green. Off
+ * for every repository until it is listed here; everything else stays a draft
+ * the person merges. Merging changes the person's code, so the row says so.
+ */
+function LandReposRow({
+ repos,
+ disabled,
+ onChange,
+}: {
+ repos: string[];
+ disabled: boolean;
+ onChange: (repos: string[]) => void;
+}) {
+ const t = useT();
+ const [draft, setDraft] = useState("");
+ const add = () => {
+ const repo = draft.trim();
+ if (!repo) return;
+ if (!repos.some((r) => r.toLowerCase() === repo.toLowerCase())) onChange([...repos, repo]);
+ setDraft("");
+ };
+ return (
+ <SettingsRow
+ id="settings-self-build-land"
+ testId="self-build-land-repos"
+ title={t("settings_view.self_build.land_title")}
+ description={t("settings_view.self_build.land_description")}
+ >
+ <SettingsNote tone="warning">{t("settings_view.self_build.land_warning")}</SettingsNote>
+ {repos.length > 0 && (
+ <ul className="flex flex-wrap gap-2">
+ {repos.map((repo) => (
+ <li
+ key={repo}
+ className="inline-flex items-center gap-1.5 rounded-full border border-border px-2.5 py-1 font-mono text-xs text-foreground"
+ >
+ {repo}
+ <button
+ type="button"
+ disabled={disabled}
+ aria-label={fill(t("settings_view.self_build.land_remove"), { repo })}
+ onClick={() => onChange(repos.filter((r) => r !== repo))}
+ className="rounded p-0.5 text-muted-foreground hover:bg-secondary hover:text-foreground disabled:opacity-50"
+ >
+ <X className="h-3 w-3" aria-hidden />
+ </button>
+ </li>
+ ))}
+ </ul>
+ )}
+ <form
+ className="flex items-center gap-2"
+ onSubmit={(event) => {
+ event.preventDefault();
+ add();
+ }}
+ >
+ <input
+ value={draft}
+ disabled={disabled}
+ onChange={(event) => setDraft(event.target.value)}
+ placeholder="owner/name"
+ aria-label={t("settings_view.self_build.land_add")}
+ className="h-8 w-56 rounded-md border border-border-strong bg-input px-2 font-mono text-sm text-foreground placeholder:text-foreground-faint focus-visible:border-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ />
+ <button
+ type="submit"
+ disabled={disabled || !draft.trim()}
+ className="h-8 rounded-md border border-border-strong px-3 text-sm text-foreground hover:bg-secondary disabled:opacity-50"
+ >
+ {t("settings_view.self_build.land_add")}
+ </button>
+ </form>
+ </SettingsRow>
+ );
+}
diff --git a/dodaios/ui/web/self_build_routes.py b/dodaios/ui/web/self_build_routes.py
index 49fd043119..28ebace4ee 100644
--- a/dodaios/ui/web/self_build_routes.py
+++ b/dodaios/ui/web/self_build_routes.py
@@ -20,6 +20,7 @@ from __future__ import annotations
import asyncio
import logging
+import re
from typing import Annotated, Any, Literal
from fastapi import APIRouter, HTTPException, Query, Request
@@ -126,6 +127,30 @@ class SettingsBody(BaseModel):
max_open_trials: int | None = None
max_code_runs_per_day: int | None = None
max_rejections: int | None = None
+ #: Repositories (``owner/name``) whose loop pull requests merge after green CI.
+ code_land_repos: list[str] | None = None
+
+
+#: ``owner/name`` as GitHub spells it.
+_REPO = re.compile(r"^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}$")
+
+
+def _clean_repos(values: list[str]) -> list[str]:
+ """Trim, drop empties and duplicates (case-insensitive), refuse anything not ``owner/name``."""
+ out: list[str] = []
+ seen: set[str] = set()
+ for raw in values:
+ repo = str(raw).strip().removeprefix("https://github.com/").removesuffix(".git").strip("/")
+ if not repo:
+ continue
+ if not _REPO.match(repo):
+ raise HTTPException(status_code=400, detail=f"Not a repository (owner/name): {raw!r}")
+ if repo.lower() not in seen:
+ seen.add(repo.lower())
+ out.append(repo)
+ if len(out) > 50:
+ raise HTTPException(status_code=400, detail="At most 50 repositories.")
+ return out
def _config(request: Request) -> Any:
@@ -175,6 +200,8 @@ async def put_settings(request: Request, body: SettingsBody) -> dict[str, Any]:
from dodaios.core.config import SelfBuildConfig
changes = body.model_dump(exclude_none=True)
+ if "code_land_repos" in changes:
+ changes["code_land_repos"] = _clean_repos(changes["code_land_repos"])
if not changes:
raise HTTPException(status_code=400, detail="No settings were provided.")
cfg = _config(request)
diff --git a/tests/unit/self_build/test_self_build_control.py b/tests/unit/self_build/test_self_build_control.py
index 0c98795183..30ae04c75b 100644
--- a/tests/unit/self_build/test_self_build_control.py
+++ b/tests/unit/self_build/test_self_build_control.py
@@ -155,3 +155,28 @@ def test_society_kill_switch_pauses_the_loop(
monkeypatch.setattr(service_module, "_current", None)
assert runtime._pause_self_build() is False
+
+
+def test_land_repos_are_cleaned_and_saved(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ toml = tmp_path / "jarvis.toml"
+ toml.write_text("", encoding="utf-8")
+ real = config_writer.set_self_build_settings
+ monkeypatch.setattr(
+ config_writer, "set_self_build_settings", lambda values: real(values, path=toml)
+ )
+ cfg = SimpleNamespace(self_build=SelfBuildConfig())
+ client, svc = _client(tmp_path, cfg)
+ put = client.put(
+ "/api/self-build/settings",
+ json={"code_land_repos": [" octo/app ", "https://github.com/Octo/App.git", "", "me/tool"]},
+ )
+ assert put.status_code == 200, put.text
+ assert put.json()["settings"]["code_land_repos"] == ["octo/app", "me/tool"]
+ assert cfg.self_build.code_land_repos == ["octo/app", "me/tool"]
+ assert 'code_land_repos = ["octo/app", "me/tool"]' in toml.read_text(encoding="utf-8")
+ bad = client.put("/api/self-build/settings", json={"code_land_repos": ["not a repo"]})
+ assert bad.status_code == 400
+ assert cfg.self_build.code_land_repos == ["octo/app", "me/tool"]
+ svc.ledger.close()