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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(skills): let voice-authored drafts be switched on
Harald12c9be33c478
diff --git a/jarvis/ui/web/frontend/src/views/SkillsView.test.tsx b/jarvis/ui/web/frontend/src/views/SkillsView.test.tsxindex 4727adf4f7..5d812d3c48 100644--- a/jarvis/ui/web/frontend/src/views/SkillsView.test.tsx+++ b/jarvis/ui/web/frontend/src/views/SkillsView.test.tsx@@ -1,8 +1,9 @@/*** Component tests for the reworked SkillsView: a flat list where every healthy- * skill has an On/Off switch (on by default), a draft skill is shown locked with- * no switch, deletion is confirmed before it fires, and built-in skills cannot- * be deleted. Drag-reorder is verified live (jsdom has no real pointer/layout).+ * skill has an On/Off switch (on by default), a broken draft is shown locked+ * with no switch, a healthy draft has an off switch (promote via enable),+ * deletion is confirmed before it fires, and built-in skills cannot be+ * deleted. Drag-reorder is verified live (jsdom has no real pointer/layout).** Driven through a mocked fetch (mirrors ContactsView.test.tsx) with the UI* language forced to English for deterministic labels.@@ -18,7 +19,7 @@ import {} from "@testing-library/react";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { SkillsView } from "@/views/SkillsView";+import { serializeFrontmatter, SkillsView } from "@/views/SkillsView";import { setUiLanguage } from "@/i18n";interface RouteResult {@@ -134,7 +135,7 @@ describe("SkillsView — On/Off switch", () => {});describe("SkillsView — draft is locked", () => {- it("a draft skill shows an error label and no switch", async () => {+ it("a broken draft shows an error label and no switch", async () => {installFetchMock({"GET /api/skills": () => ({body: {@@ -149,6 +150,51 @@ describe("SkillsView — draft is locked", () => {expect(screen.queryByRole("switch")).toBeNull();expect(screen.getByText("Error")).toBeTruthy();});++ it("a healthy draft shows an off switch, not an error", async () => {+ installFetchMock({+ "GET /api/skills": () => ({+ body: {+ skills: [skill({ name: "morning", state: "draft", error: null })],+ total: 1,+ },+ }),+ });+ renderView();++ await screen.findByText("morning");+ const sw = screen.getByRole("switch");+ expect(sw.getAttribute("aria-checked")).toBe("false");+ expect(screen.queryByText("Error")).toBeNull();+ });++ it("turning a healthy draft on calls enable", async () => {+ const calls = installFetchMock({+ "GET /api/skills": () => ({+ body: {+ skills: [skill({ name: "morning", state: "draft", error: null })],+ total: 1,+ },+ }),+ "POST /api/skills/morning/enable": () => ({+ body: skill({ name: "morning", state: "active" }),+ }),+ });+ renderView();++ await screen.findByText("morning");+ fireEvent.click(screen.getByRole("switch"));++ await waitFor(() => {+ expect(+ calls.some(+ (c) =>+ c.method === "POST" &&+ c.url.endsWith("/api/skills/morning/enable"),+ ),+ ).toBe(true);+ });+ });});describe("SkillsView — delete", () => {@@ -262,3 +308,30 @@ describe("SkillsView — multi-select bulk delete", () => {).toBeTruthy();});});++describe("serializeFrontmatter", () => {+ it("writes nested trigger.language as a YAML list, not a comma string", () => {+ const yaml = serializeFrontmatter({+ schema_version: "1",+ name: "Morning Routine 2",+ triggers: [+ {+ type: "voice",+ pattern: "(morning routine|morgenroutine)",+ combo: null,+ cron: null,+ language: ["de", "en"],+ },+ ],+ });+ expect(yaml).toContain("language:");+ expect(yaml).toContain("- de");+ expect(yaml).toContain("- en");+ expect(yaml).not.toMatch(/language:\s*de,en/);+ });++ it("quotes schema_version so YAML keeps it as a string", () => {+ const yaml = serializeFrontmatter({ schema_version: "1", name: "x" });+ expect(yaml).toContain('schema_version: "1"');+ });+});diff --git a/jarvis/ui/web/frontend/src/views/SkillsView.tsx b/jarvis/ui/web/frontend/src/views/SkillsView.tsxindex 130d59b3a9..c0bfa0262a 100644--- a/jarvis/ui/web/frontend/src/views/SkillsView.tsx+++ b/jarvis/ui/web/frontend/src/views/SkillsView.tsx@@ -89,7 +89,7 @@ const STATE_VARIANT: Record<> = {active: "default",validated: "secondary",- draft: "destructive",+ draft: "secondary",disabled: "outline",};@@ -102,12 +102,20 @@ const TRIGGER_ICON: Record<SkillTrigger["type"], typeof Mic> = {/*** A skill is "on" (it triggers + is offered to the brain) when it is ACTIVE or* VALIDATED — the trigger-matcher and the AVAILABLE SKILLS prompt treat both the- * same. Only DISABLED is "off"; DRAFT is broken and cannot be switched on.+ * same. DISABLED is "off". A DRAFT is either waiting for the user to switch+ * it on (healthy, error is empty) or broken (parse/validation error).*/function isSkillOn(state: SkillState): boolean {return state === "active" || state === "validated";}+function isBrokenDraft(skill: {+ state: SkillState;+ error: string | null;+}): boolean {+ return skill.state === "draft" && Boolean(skill.error);+}+// In-memory admin pass — holds the pass for the session so the user doesn't// have to re-enter it on every edit. Deliberately not localStorage: whoever// closes the app has to re-enter the pass on the next start.@@ -162,9 +170,12 @@ export function SkillsView() {it.name === name ? { ...it, state: on ? "active" : "disabled" } : it,),);- setEnabled.mutate({ name, enabled: on });+ setEnabled.mutate(+ { name, enabled: on },+ { onError: () => void refetch() },+ );},- [setEnabled],+ [setEnabled, refetch],);// Names that may actually be deleted — built-ins are protected, so they are@@ -442,11 +453,13 @@ export function SkillsView() {</div>{searchActive && search.data && (<div className="flex items-center justify-between text-[10px] text-muted-foreground">- <span>{search.data.total} Treffer</span>+ <span>+ {search.data.total} {t("skills_view.matches")}+ </span>{search.data.brain_used && (<span className="flex items-center gap-1"><Sparkle className="h-2.5 w-2.5" />- KI-geranked+ {t("skills_view.ai_ranked")}</span>)}</div>@@ -510,7 +523,7 @@ export function SkillsView() {</ScrollArea></div>- {/* Rechte Spalte: Detail-Panel */}+ {/* Right column: detail panel */}<div className="flex min-w-0 flex-1 flex-col">{selected ? (<SkillDetailPanel name={selected} />@@ -526,7 +539,7 @@ export function SkillsView() {}// -----------------------------------------------------------------------// Linke Spalte — Draggable List Row (On/Off switch + delete)+// Left column — draggable list row (On/Off switch + delete)// ----------------------------------------------------------------------function SkillRowDraggable({@@ -552,7 +565,7 @@ function SkillRowDraggable({}) {const t = useT();const controls = useDragControls();- const isDraft = skill.state === "draft";+ const broken = isBrokenDraft(skill);const on = isSkillOn(skill.state);// In selection mode the whole row body toggles the checkbox (built-ins are// protected and stay inert); otherwise it opens the detail panel.@@ -656,10 +669,11 @@ function SkillRowDraggable({</button>{/* Right rail: On/Off switch (or error lock) + delete. Hidden in- selection mode — the bulk toolbar owns deletion there. */}+ selection mode — the bulk toolbar owns deletion there. A healthy+ draft still gets a switch (off) so the user can promote it. */}{!selectionMode && (<div className="flex flex-shrink-0 items-center gap-1.5">- {isDraft ? (+ {broken ? (<spanclassName="flex items-center gap-1 text-[10px] font-medium text-destructive"title={skill.error ?? undefined}@@ -891,7 +905,7 @@ function DeleteConfirmDialog({}// -----------------------------------------------------------------------// Rechte Spalte — Detail-Panel+// Right column — detail panel// ----------------------------------------------------------------------function SkillDetailPanel({ name }: { name: string }) {@@ -945,7 +959,7 @@ function SkillDetailPanel({ name }: { name: string }) {} catch (e) {const msg = (e as Error).message;setSaveError(msg);- // 403 -> Admin-Pass noetig+ // 403 -> admin password requiredif (data.is_builtin &&(msg.includes("Admin-Password") || msg.includes("403"))@@ -970,7 +984,7 @@ function SkillDetailPanel({ name }: { name: string }) {if (isLoading || !data) {return (<div className="flex h-full items-center justify-center text-sm text-muted-foreground">- Lade Skill…+ {t("skills_view.loading_skill")}</div>);}@@ -982,7 +996,7 @@ function SkillDetailPanel({ name }: { name: string }) {);}- const isDraft = data.state === "draft";+ const broken = isBrokenDraft(data);const on = isSkillOn(data.state);return (@@ -1029,7 +1043,7 @@ function SkillDetailPanel({ name }: { name: string }) {)}</div><div className="flex items-center gap-3">- {!isDraft && (+ {!broken && (<div className="flex items-center gap-2"><span className="text-xs text-muted-foreground">{on ? t("skills_view.on") : t("skills_view.off")}@@ -1092,7 +1106,7 @@ function SkillDetailPanel({ name }: { name: string }) {</div><div className="flex min-h-0 flex-1">- {/* Linke Sub-Spalte: Editor */}+ {/* Left sub-column: editor */}<div className="flex min-w-0 flex-1 flex-col"><div className="flex items-center justify-between border-b border-border px-6 py-2"><span className="text-[10px] uppercase tracking-wider text-muted-foreground">@@ -1118,7 +1132,7 @@ function SkillDetailPanel({ name }: { name: string }) {/></div>- {/* Rechte Sub-Spalte: Bundle-Tree + optional Resource-Viewer */}+ {/* Right sub-column: bundle tree + optional resource viewer */}{data.resource_count > 0 && (<div className="flex w-[320px] flex-col border-l border-border">{openResource ? (@@ -1159,7 +1173,7 @@ function SkillDetailPanel({ name }: { name: string }) {}// -----------------------------------------------------------------------// Admin-Pass-Dialog+// Admin password dialog// ----------------------------------------------------------------------function AdminPassDialog({@@ -1237,9 +1251,12 @@ function buildSkillMdText(return `---\n${fmYaml}---\n\n${data.body}`;}-function serializeFrontmatter(fm: Record<string, unknown>): string {+export function serializeFrontmatter(fm: Record<string, unknown>): string {// Minimal YAML dumper — no complex cases (refs, anchors). We know that// SkillFrontmatter only contains primitives + lists + flat dicts.+ // Nested lists (e.g. trigger.language: ["de","en"]) MUST go through dump(),+ // never String(array) — JS Array.toString joins with commas and Save+ // would write `language: de,en`, which the loader rejects.const lines: string[] = [];const dump = (key: string, val: unknown, indent = 0): void => {const pad = " ".repeat(indent);@@ -1254,12 +1271,23 @@ function serializeFrontmatter(fm: Record<string, unknown>): string {}lines.push(`${pad}${key}:`);for (const item of val) {- if (typeof item === "object" && item !== null) {+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {const entries = Object.entries(item as Record<string, unknown>);+ if (entries.length === 0) {+ lines.push(`${pad} - {}`);+ continue;+ }const [firstKey, firstVal] = entries[0];- lines.push(`${pad} - ${firstKey}: ${formatScalar(firstVal)}`);- for (const [k, v] of entries.slice(1)) {- lines.push(`${pad} ${k}: ${formatScalar(v)}`);+ if (firstVal === null || typeof firstVal !== "object") {+ lines.push(`${pad} - ${firstKey}: ${formatScalar(firstVal)}`);+ for (const [k, v] of entries.slice(1)) {+ dump(k, v, indent + 4);+ }+ } else {+ lines.push(`${pad} -`);+ for (const [k, v] of entries) {+ dump(k, v, indent + 4);+ }}} else {lines.push(`${pad} - ${formatScalar(item)}`);@@ -1287,8 +1315,14 @@ function formatScalar(val: unknown): string {if (val === null || val === undefined) return "null";if (typeof val === "boolean" || typeof val === "number") return String(val);const str = String(val);- if (/[:#\n]/.test(str) || str.trim() !== str || str === "") {- // Quote when there are colons, hashes, or leading/trailing whitespace+ // Quote numeric-looking strings so YAML does not turn schema_version "1"+ // into integer 1 (Literal["1"] then rejects the file on Save).+ if (+ /[:#\n]/.test(str) ||+ str.trim() !== str ||+ str === "" ||+ /^-?\d+(\.\d+)?$/.test(str)+ ) {return JSON.stringify(str);}return str;diff --git a/jarvis/ui/web/skills_routes.py b/jarvis/ui/web/skills_routes.pyindex bcdd26be34..54a9c2935e 100644--- a/jarvis/ui/web/skills_routes.py+++ b/jarvis/ui/web/skills_routes.py@@ -5,7 +5,8 @@ Endpoints:- ``GET /api/skills/{name}`` → full skill incl. Markdown body.- ``PUT /api/skills/{name}`` → update body (and optionally frontmatter).For built-in skills: ``admin_password`` is required in the request body.-- ``POST /api/skills/{name}/enable`` → state -> ACTIVE.+- ``POST /api/skills/{name}/enable`` → state -> ACTIVE+ (healthy AP-15 drafts are promoted; broken drafts stay 409).- ``POST /api/skills/{name}/disable`` → state -> DISABLED.- ``POST /api/skills/reload`` → force ``Registry.reload()``.@@ -1595,16 +1596,46 @@ def _flip_state(reg = _require_registry(request)try:skill = reg.get(name)- except KeyError:- raise HTTPException(status_code=404, detail=f"Skill '{name}' not found")+ except KeyError as exc:+ raise HTTPException(+ status_code=404, detail=f"Skill '{name}' not found"+ ) from exc- # DRAFT stays DRAFT — a broken skill can't be activated.+ # A DRAFT is either broken (parse/validation error) or an AP-15 review+ # draft (voice/AI-authored, frontmatter valid, waiting for a human to+ # switch it on). ``skill-enable`` and the Skills-view switch are that+ # human act — they call this route. Broken drafts stay locked.if skill.state == SkillLifecycleState.DRAFT:- raise HTTPException(- status_code=409,- detail=f"Skill '{name}' is in DRAFT state (error: {skill.error}) — "- "fix it first.",- )+ if new_state != SkillLifecycleState.ACTIVE:+ raise HTTPException(+ status_code=409,+ detail=(+ f"Skill '{name}' is in DRAFT state (error: {skill.error}) — "+ "fix or enable it first."+ ),+ )+ if skill.error or skill.frontmatter is None:+ raise HTTPException(+ status_code=409,+ detail=(+ f"Skill '{name}' is in DRAFT state (error: {skill.error}) — "+ "fix it first."+ ),+ )+ from jarvis.skills.authoring.draft_writer import UnsafeSkillError++ try:+ skill = reg.promote(name)+ except KeyError as exc:+ raise HTTPException(status_code=404, detail=str(exc)) from exc+ except UnsafeSkillError as exc:+ raise HTTPException(status_code=409, detail=str(exc)) from exc+ except RuntimeError as exc:+ raise HTTPException(status_code=409, detail=str(exc)) from exc+ from jarvis.skills import prefs++ prefs.set_state(name, True)+ return _skill_to_summary(skill)updated = replace(skill, state=new_state)reg._skills[name] = updated # type: ignore[attr-defined]diff --git a/tests/unit/ui/web/test_skills_routes.py b/tests/unit/ui/web/test_skills_routes.pyindex 45ba025679..71b4fbb9df 100644--- a/tests/unit/ui/web/test_skills_routes.py+++ b/tests/unit/ui/web/test_skills_routes.py@@ -97,6 +97,67 @@ def test_enable_after_disable_records_active(skills_root: Path) -> None:assert reg.get("alpha").state == SkillLifecycleState.ACTIVE+def test_enable_promotes_healthy_draft(skills_root: Path) -> None:+ """Voice/AI-authored skills land as ``state: draft`` (AP-15). Enable is+ the human promotion the Skills view and ``skill-enable`` already advertise.+ """+ _make_skill(skills_root, "alpha", state="draft")+ client, reg = _client(skills_root)++ assert reg.get("alpha").state == SkillLifecycleState.DRAFT+ assert reg.get("alpha").error is None++ res = client.post("/api/skills/alpha/enable")+ assert res.status_code == 200, res.text+ assert res.json()["state"] == "active"+ assert reg.get("alpha").state == SkillLifecycleState.ACTIVE+ text = (skills_root / "alpha" / "SKILL.md").read_text(encoding="utf-8")+ assert "state: active" in text+ assert prefs.load_state_overrides()["alpha"] == "active"+++def test_enable_refuses_broken_draft(skills_root: Path) -> None:+ folder = skills_root / "broken"+ folder.mkdir()+ (folder / "SKILL.md").write_text(+ '---\nschema_version: "1"\nname: broken\ntriggers:\n - type: voice\n---\n\n## Body\n',+ encoding="utf-8",+ )+ client, reg = _client(skills_root)++ assert reg.get("broken").state == SkillLifecycleState.DRAFT+ assert reg.get("broken").error++ res = client.post("/api/skills/broken/enable")+ assert res.status_code == 409, res.text+ assert reg.get("broken").state == SkillLifecycleState.DRAFT+++def test_enable_refuses_unsafe_draft(skills_root: Path) -> None:+ folder = skills_root / "unsafe"+ folder.mkdir()+ (folder / "SKILL.md").write_text(+ '---\nschema_version: "1"\nname: unsafe\nstate: draft\n---\n\n'+ "```python\neval('boom')\n```\n",+ encoding="utf-8",+ )+ client, _reg = _client(skills_root)++ res = client.post("/api/skills/unsafe/enable")+ assert res.status_code == 409, res.text+ detail = res.json()["detail"].lower()+ assert "eval" in detail or "unsafe" in detail+++def test_disable_refuses_draft(skills_root: Path) -> None:+ _make_skill(skills_root, "alpha", state="draft")+ client, reg = _client(skills_root)++ res = client.post("/api/skills/alpha/disable")+ assert res.status_code == 409, res.text+ assert reg.get("alpha").state == SkillLifecycleState.DRAFT++# ----------------------------------------------------------------------# delete# ----------------------------------------------------------------------