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(ui): a screen for bringing your own skill in

Harald7d03597677e9
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index b73c6cd271..07ef176f49 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -4274,5 +4274,35 @@
"badge": "Marketplace",
"tooltip": "Aus dem Marketplace installiert",
"view_source": "Eintrag ansehen"
+ },
+ "skill_upload": {
+ "button": "Hochladen",
+ "title": "Skill hinzufügen",
+ "subtitle": "Lade einen eigenen Skill hoch oder hole ihn über einen Link.",
+ "source_files_title": "Dateien hochladen",
+ "source_files_desc": "Einen Skill-Ordner mit SKILL.md oder ein .zip-Archiv von diesem Rechner.",
+ "source_files_action": "Ordner wählen",
+ "source_link_title": "Über einen Link holen",
+ "source_link_desc": "Eine einzelne SKILL.md von einer Adresse laden, etwa aus einem GitHub-Repository.",
+ "source_link_action": "Link einfügen",
+ "back": "Zurück zur Auswahl",
+ "drop_title": "Skill-Ordner hier ablegen",
+ "drop_hint": "Ein Ordner mit SKILL.md, oder ein .zip- bzw. .tar.gz-Archiv.",
+ "choose_folder": "Ordner wählen",
+ "choose_archive": "Archiv wählen",
+ "link_label": "Adresse der SKILL.md",
+ "link_hint": "Es wird nur die erste Adresse im Text gelesen — ein eingefügter Befehl funktioniert also auch.",
+ "install": "Installieren",
+ "inspecting": "Upload wird gelesen",
+ "files": "Dateien",
+ "replace": "Ersetzen",
+ "clear": "Verwerfen",
+ "no_skill_detected": "In diesem Upload steckt keine lesbare SKILL.md.",
+ "lint_title": "Sicherheitsprüfung hat etwas gefunden.",
+ "lint_body": "Der Skill wird als Entwurf abgelegt und läuft erst, wenn du ihn freigibst.",
+ "ignored": "Ausgelassen",
+ "blocker_no_files": "Noch nichts ausgewählt.",
+ "will_land_as_draft": "Wird als Entwurf abgelegt.",
+ "ready": "Bereit zum Installieren."
}
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 0602a7069d..c60772b0d1 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -4274,5 +4274,35 @@
"badge": "Marketplace",
"tooltip": "Installed from the marketplace",
"view_source": "view listing"
+ },
+ "skill_upload": {
+ "button": "Upload",
+ "title": "Add a skill",
+ "subtitle": "Upload a skill of your own, or fetch one from a link.",
+ "source_files_title": "Upload files",
+ "source_files_desc": "A skill folder holding SKILL.md, or a .zip archive from this machine.",
+ "source_files_action": "Choose folder",
+ "source_link_title": "Fetch from a link",
+ "source_link_desc": "Load a single SKILL.md from an address, for example from a GitHub repository.",
+ "source_link_action": "Paste a link",
+ "back": "Back to the choices",
+ "drop_title": "Drop a skill folder here",
+ "drop_hint": "A folder holding SKILL.md, or a .zip / .tar.gz archive.",
+ "choose_folder": "Choose folder",
+ "choose_archive": "Choose archive",
+ "link_label": "Address of the SKILL.md",
+ "link_hint": "Only the first address in the text is read — so a pasted command works too.",
+ "install": "Install",
+ "inspecting": "Reading the upload",
+ "files": "files",
+ "replace": "Replace",
+ "clear": "Discard",
+ "no_skill_detected": "This upload holds no readable SKILL.md.",
+ "lint_title": "The safety check found something.",
+ "lint_body": "The skill lands as a draft and only runs once you enable it.",
+ "ignored": "Left out",
+ "blocker_no_files": "Nothing chosen yet.",
+ "will_land_as_draft": "Will land as a draft.",
+ "ready": "Ready to install."
}
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 5034ac4265..f5e93ab858 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -4274,5 +4274,35 @@
"badge": "Marketplace",
"tooltip": "Instalado desde el marketplace",
"view_source": "ver publicación"
+ },
+ "skill_upload": {
+ "button": "Subir",
+ "title": "Añadir una skill",
+ "subtitle": "Sube una skill propia u obtenla desde un enlace.",
+ "source_files_title": "Subir archivos",
+ "source_files_desc": "Una carpeta de skill con SKILL.md, o un archivo .zip de este equipo.",
+ "source_files_action": "Elegir carpeta",
+ "source_link_title": "Obtener desde un enlace",
+ "source_link_desc": "Cargar un único SKILL.md desde una dirección, por ejemplo de un repositorio de GitHub.",
+ "source_link_action": "Pegar un enlace",
+ "back": "Volver a las opciones",
+ "drop_title": "Suelta aquí una carpeta de skill",
+ "drop_hint": "Una carpeta con SKILL.md, o un archivo .zip o .tar.gz.",
+ "choose_folder": "Elegir carpeta",
+ "choose_archive": "Elegir archivo",
+ "link_label": "Dirección del SKILL.md",
+ "link_hint": "Solo se lee la primera dirección del texto, así que un comando pegado también sirve.",
+ "install": "Instalar",
+ "inspecting": "Leyendo la subida",
+ "files": "archivos",
+ "replace": "Reemplazar",
+ "clear": "Descartar",
+ "no_skill_detected": "Esta subida no contiene ningún SKILL.md legible.",
+ "lint_title": "La comprobación de seguridad encontró algo.",
+ "lint_body": "La skill se guarda como borrador y solo se ejecuta cuando la habilitas.",
+ "ignored": "Omitido",
+ "blocker_no_files": "Aún no has elegido nada.",
+ "will_land_as_draft": "Se guardará como borrador.",
+ "ready": "Lista para instalar."
}
}
diff --git a/jarvis/ui/web/frontend/src/lib/filePicking.test.ts b/jarvis/ui/web/frontend/src/lib/filePicking.test.ts
new file mode 100644
index 0000000000..1f9f981967
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/filePicking.test.ts
@@ -0,0 +1,171 @@
+import { describe, expect, it } from "vitest";
+
+import { collectDroppedFiles, filesFromInput, formatBytes } from "@/lib/filePicking";
+
+/**
+ * Getting a *folder* out of a browser is the awkward part of this feature, and
+ * the two roads in behave nothing alike: a file input hands over a flat list
+ * with paths tucked into a non-standard property, while a drop hands over an
+ * entry tree behind a callback API — one that returns at most 100 children per
+ * call and signals the end with an empty batch.
+ *
+ * Both have to arrive as the same `PickedFile[]`, or the server sees a folder
+ * as a pile of loose files.
+ */
+
+function fakeFile(name: string, relativePath?: string): File {
+ const file = new File(["x"], name);
+ if (relativePath !== undefined) {
+ Object.defineProperty(file, "webkitRelativePath", { value: relativePath });
+ }
+ return file;
+}
+
+function fileList(files: File[]): FileList {
+ return files as unknown as FileList;
+}
+
+// ----------------------------------------------------------------------
+// A file input
+// ----------------------------------------------------------------------
+
+describe("filesFromInput", () => {
+ it("uses the relative path a directory pick provides", () => {
+ const picked = filesFromInput(
+ fileList([
+ fakeFile("SKILL.md", "my-skill/SKILL.md"),
+ fakeFile("guide.md", "my-skill/references/guide.md"),
+ ]),
+ );
+
+ expect(picked.map((entry) => entry.path)).toEqual([
+ "my-skill/SKILL.md",
+ "my-skill/references/guide.md",
+ ]);
+ });
+
+ it("falls back to the bare name for a single file", () => {
+ const picked = filesFromInput(fileList([fakeFile("bundle.zip")]));
+ expect(picked).toHaveLength(1);
+ expect(picked[0].path).toBe("bundle.zip");
+ });
+
+ it("returns nothing when the pick was cancelled", () => {
+ expect(filesFromInput(null)).toEqual([]);
+ });
+});
+
+// ----------------------------------------------------------------------
+// A drop
+// ----------------------------------------------------------------------
+
+type EntryStub = {
+ isFile: boolean;
+ isDirectory: boolean;
+ name: string;
+ fullPath?: string;
+ file?: (onOk: (file: File) => void) => void;
+ createReader?: () => {
+ readEntries: (onOk: (entries: EntryStub[]) => void) => void;
+ };
+};
+
+function fileEntry(name: string, fullPath: string): EntryStub {
+ return {
+ isFile: true,
+ isDirectory: false,
+ name,
+ fullPath,
+ file: (onOk) => onOk(fakeFile(name)),
+ };
+}
+
+/** A directory that hands out its children in batches, like the real API. */
+function dirEntry(name: string, fullPath: string, batches: EntryStub[][]): EntryStub {
+ let call = 0;
+ return {
+ isFile: false,
+ isDirectory: true,
+ name,
+ fullPath,
+ createReader: () => ({
+ readEntries: (onOk) => {
+ const batch = batches[call] ?? [];
+ call += 1;
+ onOk(batch);
+ },
+ }),
+ };
+}
+
+function dataTransfer(entries: EntryStub[], files: File[] = []): DataTransfer {
+ return {
+ items: entries.map((entry) => ({
+ webkitGetAsEntry: () => entry,
+ getAsFile: () => null,
+ })),
+ files,
+ } as unknown as DataTransfer;
+}
+
+describe("collectDroppedFiles", () => {
+ it("walks a dropped folder down to the leaves", async () => {
+ const tree = dirEntry("my-skill", "/my-skill", [
+ [
+ fileEntry("SKILL.md", "/my-skill/SKILL.md"),
+ dirEntry("references", "/my-skill/references", [
+ [fileEntry("guide.md", "/my-skill/references/guide.md")],
+ [],
+ ]),
+ ],
+ [],
+ ]);
+
+ const picked = await collectDroppedFiles(dataTransfer([tree]));
+
+ expect(picked.map((entry) => entry.path)).toEqual([
+ "my-skill/SKILL.md",
+ "my-skill/references/guide.md",
+ ]);
+ });
+
+ it("keeps reading until a batch comes back empty", async () => {
+ // The real readEntries caps a batch at 100 children. A single call would
+ // silently truncate a large folder — the kind of loss nobody notices
+ // until a skill installs without half its files.
+ const tree = dirEntry("big", "/big", [
+ [fileEntry("a.md", "/big/a.md")],
+ [fileEntry("b.md", "/big/b.md")],
+ [],
+ ]);
+
+ const picked = await collectDroppedFiles(dataTransfer([tree]));
+
+ expect(picked.map((entry) => entry.path)).toEqual(["big/a.md", "big/b.md"]);
+ });
+
+ it("takes plain files when the browser exposes no entries", async () => {
+ const transfer = {
+ items: [{ webkitGetAsEntry: () => null, getAsFile: () => fakeFile("bundle.zip") }],
+ files: [],
+ } as unknown as DataTransfer;
+
+ const picked = await collectDroppedFiles(transfer);
+
+ expect(picked).toHaveLength(1);
+ expect(picked[0].path).toBe("bundle.zip");
+ });
+
+ it("returns nothing for an empty drop", async () => {
+ expect(await collectDroppedFiles(null)).toEqual([]);
+ });
+});
+
+describe("formatBytes", () => {
+ it("speaks in the units a person reads", () => {
+ expect(formatBytes(0)).toBe("0 B");
+ expect(formatBytes(512)).toBe("512 B");
+ expect(formatBytes(2048)).toBe("2.0 KB");
+ expect(formatBytes(5 * 1024 * 1024)).toBe("5.0 MB");
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/lib/filePicking.ts b/jarvis/ui/web/frontend/src/lib/filePicking.ts
new file mode 100644
index 0000000000..b7d5a180d2
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/filePicking.ts
@@ -0,0 +1,147 @@
+/**
+ * Turning "the owner dropped something on the window" into files with paths.
+ *
+ * A skill or plugin is a *folder*, and the browser makes getting one
+ * surprisingly awkward: a file input needs the non-standard `webkitdirectory`
+ * attribute and reports paths under `webkitRelativePath`, while a drag-and-drop
+ * carries no paths at all until you walk the `DataTransferItem` entries
+ * yourself — recursively, through a callback API older than Promises.
+ *
+ * Both roads end here, in the same `PickedFile[]`, so everything downstream
+ * (preview, upload, the server's staging rules) only ever sees one shape.
+ *
+ * The one trap worth naming: `DataTransfer` entries are only valid during the
+ * drop event itself. Awaiting anything before reading them empties the list —
+ * so `collectDroppedFiles` grabs every entry synchronously up front and only
+ * then starts walking them.
+ */
+
+export type PickedFile = {
+ file: File;
+ /** POSIX-style path relative to the drop, e.g. `my-skill/references/a.md`. */
+ path: string;
+};
+
+type FileSystemEntryLike = {
+ isFile: boolean;
+ isDirectory: boolean;
+ name: string;
+ fullPath?: string;
+ file?: (onOk: (file: File) => void, onErr?: (error: unknown) => void) => void;
+ createReader?: () => {
+ readEntries: (
+ onOk: (entries: FileSystemEntryLike[]) => void,
+ onErr?: (error: unknown) => void,
+ ) => void;
+ };
+};
+
+/** Strips the leading slash a `fullPath` carries and normalises separators. */
+function normalisePath(raw: string): string {
+ return raw.replace(/\\/g, "/").replace(/^\/+/, "").replace(/^\.\//, "");
+}
+
+/**
+ * The files an `<input type="file">` produced.
+ *
+ * With `webkitdirectory` set, each file carries its path relative to the
+ * chosen folder; without it (a single ZIP, say) the bare name is the path.
+ */
+export function filesFromInput(fileList: FileList | null): PickedFile[] {
+ if (!fileList) return [];
+ return Array.from(fileList).map((file) => ({
+ file,
+ path: normalisePath(
+ (file as File & { webkitRelativePath?: string }).webkitRelativePath || file.name,
+ ),
+ }));
+}
+
+/**
+ * The files a drop produced — folders walked to the leaves.
+ *
+ * Falls back to `dataTransfer.files` on browsers that do not expose the entry
+ * API, which loses folder structure but still lets a dropped archive through.
+ */
+export async function collectDroppedFiles(
+ dataTransfer: DataTransfer | null,
+): Promise<PickedFile[]> {
+ if (!dataTransfer) return [];
+
+ // Synchronous first pass — see the note at the top of this file.
+ const entries: FileSystemEntryLike[] = [];
+ const looseFiles: File[] = [];
+ for (const item of Array.from(dataTransfer.items ?? [])) {
+ const getEntry = (
+ item as DataTransferItem & { webkitGetAsEntry?: () => FileSystemEntryLike | null }
+ ).webkitGetAsEntry;
+ const entry = getEntry ? getEntry.call(item) : null;
+ if (entry) {
+ entries.push(entry);
+ continue;
+ }
+ const file = item.getAsFile?.();
+ if (file) looseFiles.push(file);
+ }
+
+ if (entries.length === 0) {
+ const fallback = looseFiles.length > 0 ? looseFiles : Array.from(dataTransfer.files ?? []);
+ return fallback.map((file) => ({ file, path: normalisePath(file.name) }));
+ }
+
+ const picked: PickedFile[] = [];
+ for (const entry of entries) {
+ await walkEntry(entry, "", picked);
+ }
+ return picked;
+}
+
+async function walkEntry(
+ entry: FileSystemEntryLike,
+ parentPath: string,
+ out: PickedFile[],
+): Promise<void> {
+ if (entry.isFile && entry.file) {
+ const file = await new Promise<File | null>((resolve) => {
+ entry.file?.(resolve, () => resolve(null));
+ });
+ if (!file) return; // unreadable entry — skip it rather than fail the drop
+ const path = entry.fullPath
+ ? normalisePath(entry.fullPath)
+ : normalisePath(parentPath ? `${parentPath}/${file.name}` : file.name);
+ out.push({ file, path });
+ return;
+ }
+
+ if (!entry.isDirectory || !entry.createReader) return;
+
+ const basePath = entry.fullPath
+ ? normalisePath(entry.fullPath)
+ : normalisePath(parentPath ? `${parentPath}/${entry.name}` : entry.name);
+ const reader = entry.createReader();
+
+ // readEntries hands back at most 100 entries per call and signals the end
+ // with an empty batch — a single call silently truncates a large folder.
+ while (true) {
+ const batch = await new Promise<FileSystemEntryLike[]>((resolve) => {
+ reader.readEntries(resolve, () => resolve([]));
+ });
+ if (batch.length === 0) break;
+ for (const child of batch) {
+ await walkEntry(child, basePath, out);
+ }
+ }
+}
+
+/** `12.3 MB` — the size, in the words a person reads. */
+export function formatBytes(bytes: number): string {
+ if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";
+ const units = ["B", "KB", "MB", "GB"];
+ let size = bytes;
+ let unit = 0;
+ while (size >= 1024 && unit < units.length - 1) {
+ size /= 1024;
+ unit += 1;
+ }
+ return `${size.toFixed(size < 10 && unit > 0 ? 1 : 0)} ${units[unit]}`;
+}
diff --git a/jarvis/ui/web/frontend/src/lib/skillUpload.ts b/jarvis/ui/web/frontend/src/lib/skillUpload.ts
new file mode 100644
index 0000000000..04e4f227cf
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/lib/skillUpload.ts
@@ -0,0 +1,73 @@
+/**
+ * Talking to `/api/skills/upload` — inspect first, install second.
+ *
+ * The two-call shape is deliberate. Inspecting is what lets the dialog show
+ * the real skill name, the files that will actually be installed and every
+ * blocker at once, *before* anything is written. Installing then repeats the
+ * upload rather than referencing a staged copy, which costs a second transfer
+ * over a loopback connection and buys a server that keeps no half-finished
+ * state around.
+ */
+
+import type { PickedFile } from "@/lib/filePicking";
+
+export type SkillUploadLimits = {
+ max_file_bytes: number;
+ max_total_bytes: number;
+ max_file_count: number;
+};
+
+export type DetectedSkill = {
+ name: string;
+ description: string;
+ category: string;
+ version: string;
+ tags: string[];
+ /** The state the install would produce — `draft` when the lint bites. */
+ state: string;
+ resource_count: number;
+};
+
+export type SkillUploadReport = {
+ /** True when nothing blocks the install. Lint findings do not block. */
+ ready: boolean;
+ problems: string[];
+ lint_findings: string[];
+ /** Paths as they will be installed, relative to the skill folder. */
+ files: string[];
+ /** OS clutter that was dropped — shown so the file count adds up. */
+ ignored: string[];
+ stripped_root: string | null;
+ total_bytes: number;
+ skill: DetectedSkill | null;
+ limits: SkillUploadLimits;
+};
+
+function buildUploadBody(picked: PickedFile[]): FormData {
+ const body = new FormData();
+ for (const { file } of picked) body.append("files", file);
+ // The relative paths travel beside the files, in the same order: a
+ // multipart body has no field for them, and without them a folder drop
+ // would arrive as a pile of loose files.
+ body.append("paths", JSON.stringify(picked.map((entry) => entry.path)));
+ return body;
+}
+
+async function postUpload<T>(url: string, picked: PickedFile[]): Promise<T> {
+ const res = await fetch(url, { method: "POST", body: buildUploadBody(picked) });
+ if (!res.ok) {
+ const body = await res.json().catch(() => ({}));
+ throw new Error(body.detail ?? `HTTP ${res.status}`);
+ }
+ return res.json();
+}
+
+/** Reports what the upload holds. Writes nothing. */
+export function inspectSkillUpload(picked: PickedFile[]): Promise<SkillUploadReport> {
+ return postUpload<SkillUploadReport>("/api/skills/upload/inspect", picked);
+}
+
+/** Installs the upload and returns the skill detail. */
+export function uploadSkill<T>(picked: PickedFile[]): Promise<T> {
+ return postUpload<T>("/api/skills/upload", picked);
+}
diff --git a/jarvis/ui/web/frontend/src/views/SkillUploadDialog.test.tsx b/jarvis/ui/web/frontend/src/views/SkillUploadDialog.test.tsx
new file mode 100644
index 0000000000..9bb9a72b4d
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/SkillUploadDialog.test.tsx
@@ -0,0 +1,195 @@
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import type { ReactElement } from "react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import { setUiLanguage } from "@/i18n";
+import { SkillUploadDialog } from "@/views/SkillUploadDialog";
+
+/**
+ * What the preview promises, the install has to deliver.
+ *
+ * The dialog's whole job is to answer "what happens if I say yes" before the
+ * yes. Two ways it could lie, and both are pinned here: offering an install
+ * the server has already said is blocked, and staying quiet about a skill that
+ * will land as a draft rather than going live.
+ */
+
+const READY_REPORT = {
+ ready: true,
+ problems: [],
+ lint_findings: [],
+ files: ["SKILL.md", "references/guide.md"],
+ ignored: [".DS_Store"],
+ stripped_root: "my-skill",
+ total_bytes: 2048,
+ skill: {
+ name: "my-skill",
+ description: "A skill of my own.",
+ category: "productivity",
+ version: "1.0.0",
+ tags: [],
+ state: "validated",
+ resource_count: 1,
+ },
+ limits: { max_file_bytes: 10485760, max_total_bytes: 52428800, max_file_count: 2000 },
+};
+
+function jsonResponse(body: unknown, ok = true, status = 200): Response {
+ return { ok, status, json: async () => body } as Response;
+}
+
+let fetchMock: ReturnType<typeof vi.fn>;
+
+function stubFetch(responses: Record<string, unknown>) {
+ fetchMock = vi.fn(async (url: string) => {
+ const key = Object.keys(responses).find((candidate) => url.includes(candidate));
+ if (!key) return jsonResponse({ detail: "unexpected call" }, false, 404);
+ return jsonResponse(responses[key]);
+ });
+ (globalThis as unknown as { fetch: typeof fetch }).fetch =
+ fetchMock as unknown as typeof fetch;
+}
+
+function withClient(node: ReactElement) {
+ const client = new QueryClient({
+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
+ });
+ return <QueryClientProvider client={client}>{node}</QueryClientProvider>;
+}
+
+/** Picks a folder through the hidden input, the way the browser would. */
+function pickFolder(files: File[]) {
+ const input = screen.getByTestId("skill-folder-input") as HTMLInputElement;
+ Object.defineProperty(input, "files", { value: files, configurable: true });
+ fireEvent.change(input);
+}
+
+function skillFile(relativePath: string): File {
+ const file = new File(["---\nname: my-skill\n---\n"], relativePath.split("/").pop()!);
+ Object.defineProperty(file, "webkitRelativePath", { value: relativePath });
+ return file;
+}
+
+beforeEach(() => {
+ // Pinned rather than inherited: a changed default language must not
+ // silently turn every assertion below into a lookup miss.
+ setUiLanguage("en");
+ stubFetch({ "/upload/inspect": READY_REPORT });
+});
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
+
+describe("SkillUploadDialog", () => {
+ it("offers both ways in before asking for anything", () => {
+ render(withClient(<SkillUploadDialog open onClose={() => {}} />));
+
+ expect(screen.getByText("Upload files")).toBeTruthy();
+ expect(screen.getByText("Fetch from a link")).toBeTruthy();
+ // Nothing to confirm yet — the footer only appears once a road is chosen.
+ expect(screen.queryByText("Install")).toBeNull();
+ });
+
+ it("shows what the upload holds, not what was dropped", async () => {
+ render(withClient(<SkillUploadDialog open onClose={() => {}} />));
+ fireEvent.click(screen.getByText("Upload files"));
+
+ pickFolder([skillFile("my-skill/SKILL.md"), skillFile("my-skill/references/guide.md")]);
+
+ await waitFor(() => expect(screen.getByText("my-skill")).toBeTruthy());
+ // The wrapper folder is gone from the listing — these are the paths that
+ // will actually be installed.
+ expect(screen.getByText("SKILL.md")).toBeTruthy();
+ expect(screen.getByText("references/guide.md")).toBeTruthy();
+ // The file count shrank by one; the reason is on screen.
+ expect(screen.getByText(/Left out/)).toBeTruthy();
+ });
+
+ it("sends the relative paths beside the files", async () => {
+ render(withClient(<SkillUploadDialog open onClose={() => {}} />));
+ fireEvent.click(screen.getByText("Upload files"));
+
+ pickFolder([skillFile("my-skill/SKILL.md")]);
+
+ await waitFor(() => expect(fetchMock).toHaveBeenCalled());
+ const body = fetchMock.mock.calls[0][1].body as FormData;
+ expect(JSON.parse(body.get("paths") as string)).toEqual(["my-skill/SKILL.md"]);
+ });
+
+ it("refuses to offer an install the server has blocked", async () => {
+ stubFetch({
+ "/upload/inspect": {
+ ...READY_REPORT,
+ ready: false,
+ problems: ["Skill 'my-skill' already exists."],
+ },
+ });
+ render(withClient(<SkillUploadDialog open onClose={() => {}} />));
+ fireEvent.click(screen.getByText("Upload files"));
+
+ pickFolder([skillFile("my-skill/SKILL.md")]);
+
+ await waitFor(() =>
+ expect(screen.getAllByText("Skill 'my-skill' already exists.").length).toBeGreaterThan(0),
+ );
+ expect(screen.getByText("Install").closest("button")?.disabled).toBe(true);
+ });
+
+ it("says up front that an unsafe skill will land as a draft", async () => {
+ stubFetch({
+ "/upload/inspect": {
+ ...READY_REPORT,
+ lint_findings: ["os.system call in a code block"],
+ skill: { ...READY_REPORT.skill, state: "draft" },
+ },
+ });
+ render(withClient(<SkillUploadDialog open onClose={() => {}} />));
+ fireEvent.click(screen.getByText("Upload files"));
+
+ pickFolder([skillFile("my-skill/SKILL.md")]);
+
+ await waitFor(() =>
+ expect(screen.getByText(/The safety check found something/)).toBeTruthy(),
+ );
+ expect(screen.getByText(/Will land as a draft/)).toBeTruthy();
+ // A finding is not a blocker: it changes where the skill lands, and the
+ // owner may still say yes to that.
+ expect(screen.getByText("Install").closest("button")?.disabled).toBe(false);
+ });
+
+ it("installs and reports the name back", async () => {
+ stubFetch({
+ "/upload/inspect": READY_REPORT,
+ "/api/skills/upload": { name: "my-skill" },
+ });
+ const onInstalled = vi.fn();
+ const onClose = vi.fn();
+ render(withClient(<SkillUploadDialog open onClose={onClose} onInstalled={onInstalled} />));
+ fireEvent.click(screen.getByText("Upload files"));
+
+ pickFolder([skillFile("my-skill/SKILL.md")]);
+ await waitFor(() => expect(screen.getByText("my-skill")).toBeTruthy());
+
+ fireEvent.click(screen.getByText("Install"));
+
+ await waitFor(() => expect(onInstalled).toHaveBeenCalledWith("my-skill"));
+ expect(onClose).toHaveBeenCalled();
+ });
+
+ it("puts the long-dead link import back within reach", async () => {
+ stubFetch({ "/api/skills/import": { name: "linked-skill" } });
+ const onInstalled = vi.fn();
+ render(withClient(<SkillUploadDialog open onClose={() => {}} onInstalled={onInstalled} />));
+
+ fireEvent.click(screen.getByText("Fetch from a link"));
+ fireEvent.change(screen.getByLabelText("Address of the SKILL.md"), {
+ target: { value: "https://example.test/SKILL.md" },
+ });
+ fireEvent.click(screen.getByText("Install"));
+
+ await waitFor(() => expect(onInstalled).toHaveBeenCalledWith("linked-skill"));
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/SkillUploadDialog.tsx b/jarvis/ui/web/frontend/src/views/SkillUploadDialog.tsx
new file mode 100644
index 0000000000..210b62d387
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/SkillUploadDialog.tsx
@@ -0,0 +1,540 @@
+import { useCallback, useEffect, useRef, useState } from "react";
+import { useQueryClient } from "@tanstack/react-query";
+import {
+ AlertTriangle,
+ ArrowLeft,
+ ArrowRight,
+ Check,
+ FileArchive,
+ FolderOpen,
+ Link2,
+ Loader2,
+ ShieldAlert,
+ Upload,
+ X,
+} from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { ScrollArea } from "@/components/ui/scroll-area";
+import { cn } from "@/lib/utils";
+import { useT } from "@/i18n";
+import { useImportSkill } from "@/hooks/useSkills";
+import {
+ collectDroppedFiles,
+ filesFromInput,
+ formatBytes,
+ type PickedFile,
+} from "@/lib/filePicking";
+import {
+ inspectSkillUpload,
+ uploadSkill,
+ type SkillUploadReport,
+} from "@/lib/skillUpload";
+
+/**
+ * Bringing your own skill in — the drop-a-folder flow.
+ *
+ * The shape follows what the public skill hubs settled on, for a good reason:
+ * the files come first and the details come second. You drop a folder, the
+ * dialog tells you what it found in it, and only then is there anything to
+ * confirm. Nothing is typed that can be read.
+ *
+ * Two ways in, because we have two:
+ * - upload a folder or a .zip / .tar.gz from this machine,
+ * - fetch a single SKILL.md from a link.
+ * The link route has existed in the backend for a long time and was never
+ * wired into a screen; it is reachable from here now.
+ *
+ * What the preview must never do is understate the result. If the safety lint
+ * bites, the skill lands as a draft rather than going live — so the preview
+ * says "draft" up front instead of letting the owner discover it afterwards.
+ */
+
+type Mode = "choose" | "files" | "link";
+
+export function SkillUploadDialog({
+ open,
+ onClose,
+ onInstalled,
+}: {
+ open: boolean;
+ onClose: () => void;
+ onInstalled?: (name: string) => void;
+}) {
+ const t = useT();
+ const qc = useQueryClient();
+ const [mode, setMode] = useState<Mode>("choose");
+ const [picked, setPicked] = useState<PickedFile[]>([]);
+ const [report, setReport] = useState<SkillUploadReport | null>(null);
+ const [inspecting, setInspecting] = useState(false);
+ const [installing, setInstalling] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const [dragging, setDragging] = useState(false);
+ const [link, setLink] = useState("");
+ const folderInput = useRef<HTMLInputElement | null>(null);
+ const archiveInput = useRef<HTMLInputElement | null>(null);
+ const importFromLink = useImportSkill();
+
+ const reset = useCallback(() => {
+ setMode("choose");
+ setPicked([]);
+ setReport(null);
+ setInspecting(false);
+ setInstalling(false);
+ setError(null);
+ setDragging(false);
+ setLink("");
+ }, []);
+
+ useEffect(() => {
+ if (!open) reset();
+ }, [open, reset]);
+
+ // `webkitdirectory` has to be set through a ref: React does not know the
+ // attribute, and writing it into JSX drops it silently.
+ const setFolderInput = (node: HTMLInputElement | null) => {
+ folderInput.current = node;
+ if (node) {
+ node.setAttribute("webkitdirectory", "");
+ node.setAttribute("directory", "");
+ }
+ };
+
+ const inspect = useCallback(
+ async (files: PickedFile[]) => {
+ setPicked(files);
+ setReport(null);
+ setError(null);
+ if (files.length === 0) return;
+ setInspecting(true);
+ try {
+ setReport(await inspectSkillUpload(files));
+ } catch (err) {
+ setError(err instanceof Error ? err.message : String(err));
+ } finally {
+ setInspecting(false);
+ }
+ },
+ [],
+ );
+
+ const onDrop = (event: React.DragEvent) => {
+ event.preventDefault();
+ setDragging(false);
+ setMode("files");
+ void collectDroppedFiles(event.dataTransfer).then(inspect);
+ };
+
+ const install = async () => {
+ if (picked.length === 0) return;
+ setInstalling(true);
+ setError(null);
+ try {
+ const detail = await uploadSkill<{ name: string }>(picked);
+ await qc.invalidateQueries({ queryKey: ["skills"] });
+ onInstalled?.(detail.name);
+ onClose();
+ } catch (err) {
+ setError(err instanceof Error ? err.message : String(err));
+ } finally {
+ setInstalling(false);
+ }
+ };
+
+ const installFromLink = () => {
+ if (!link.trim()) return;
+ setError(null);
+ importFromLink.mutate(link.trim(), {
+ onSuccess: (detail) => {
+ onInstalled?.(detail.name);
+ onClose();
+ },
+ onError: (err) => setError(err instanceof Error ? err.message : String(err)),
+ });
+ };
+
+ if (!open) return null;
+
+ const blocker = describeBlocker(report, picked.length, t);
+
+ return (
+ <div
+ className="fixed inset-0 z-50 flex items-center justify-center bg-scrim/60 p-6"
+ onDragOver={(event) => {
+ event.preventDefault();
+ setDragging(true);
+ }}
+ onDragLeave={() => setDragging(false)}
+ onDrop={onDrop}
+ >
+ <div className="flex max-h-full w-[640px] flex-col overflow-hidden rounded-lg border border-border bg-card shadow-xl">
+ <header className="flex items-start justify-between gap-4 border-b border-border px-6 py-4">
+ <div>
+ <h3 className="flex items-center gap-2 text-base font-semibold">
+ <Upload className="h-4 w-4 text-primary" />
+ {t("skill_upload.title")}
+ </h3>
+ <p className="mt-1 text-sm text-muted-foreground">
+ {t("skill_upload.subtitle")}
+ </p>
+ </div>
+ <Button size="sm" variant="ghost" onClick={onClose} aria-label={t("common.cancel")}>
+ <X className="h-4 w-4" />
+ </Button>
+ </header>
+
+ <ScrollArea className="min-h-0 flex-1">
+ <div className="px-6 py-5">
+ {mode === "choose" && (
+ <div className="grid gap-3">
+ <SourceCard
+ icon={<FolderOpen className="h-5 w-5" />}
+ title={t("skill_upload.source_files_title")}
+ description={t("skill_upload.source_files_desc")}
+ action={t("skill_upload.source_files_action")}
+ onSelect={() => setMode("files")}
+ />
+ <SourceCard
+ icon={<Link2 className="h-5 w-5" />}
+ title={t("skill_upload.source_link_title")}
+ description={t("skill_upload.source_link_desc")}
+ action={t("skill_upload.source_link_action")}
+ onSelect={() => setMode("link")}
+ />
+ </div>
+ )}
+
+ {mode === "files" && (
+ <div className="flex flex-col gap-4">
+ <BackLink label={t("skill_upload.back")} onClick={reset} />
+
+ <input
+ ref={setFolderInput}
+ type="file"
+ multiple
+ className="sr-only"
+ data-testid="skill-folder-input"
+ onChange={(event) => void inspect(filesFromInput(event.target.files))}
+ />
+ <input
+ ref={archiveInput}
+ type="file"
+ accept=".zip,.tgz,.tar.gz"
+ className="sr-only"
+ data-testid="skill-archive-input"
+ onChange={(event) => void inspect(filesFromInput(event.target.files))}
+ />
+
+ {picked.length === 0 ? (
+ <div
+ className={cn(
+ "flex flex-col items-center gap-3 rounded-lg border-2 border-dashed px-6 py-10 text-center transition-colors",
+ dragging
+ ? "border-primary bg-primary/5"
+ : "border-border bg-muted/20",
+ )}
+ >
+ <Upload className="h-5 w-5 text-muted-foreground" />
+ <div>
+ <p className="text-sm font-medium">{t("skill_upload.drop_title")}</p>
+ <p className="mt-1 text-xs text-muted-foreground">
+ {t("skill_upload.drop_hint")}
+ </p>
+ </div>
+ <div className="mt-1 flex items-center gap-2">
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => folderInput.current?.click()}
+ className="gap-1.5"
+ >
+ <FolderOpen className="h-3.5 w-3.5" />
+ {t("skill_upload.choose_folder")}
+ </Button>
+ <Button
+ size="sm"
+ variant="ghost"
+ onClick={() => archiveInput.current?.click()}
+ className="gap-1.5"
+ >
+ <FileArchive className="h-3.5 w-3.5" />
+ {t("skill_upload.choose_archive")}
+ </Button>
+ </div>
+ </div>
+ ) : (
+ <UploadReport
+ report={report}
+ inspecting={inspecting}
+ fileCount={picked.length}
+ onReplace={() => folderInput.current?.click()}
+ onClear={() => void inspect([])}
+ />
+ )}
+ </div>
+ )}
+
+ {mode === "link" && (
+ <div className="flex flex-col gap-4">
+ <BackLink label={t("skill_upload.back")} onClick={reset} />
+ <div className="flex flex-col gap-2">
+ <label htmlFor="skill-import-link" className="text-sm font-medium">
+ {t("skill_upload.link_label")}
+ </label>
+ <input
+ id="skill-import-link"
+ autoFocus
+ value={link}
+ onChange={(event) => setLink(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") installFromLink();
+ }}
+ placeholder="https://github.com/.../SKILL.md"
+ className="w-full rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary"
+ />
+ <p className="text-xs text-muted-foreground">
+ {t("skill_upload.link_hint")}
+ </p>
+ </div>
+ </div>
+ )}
+
+ {error && (
+ <p className="mt-4 flex items-start gap-2 text-sm text-destructive" role="alert">
+ <AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0" />
+ {error}
+ </p>
+ )}
+ </div>
+ </ScrollArea>
+
+ {mode !== "choose" && (
+ <footer className="flex items-center justify-between gap-4 border-t border-border px-6 py-4">
+ <p className="min-w-0 text-xs text-muted-foreground">{blocker}</p>
+ <div className="flex shrink-0 items-center gap-2">
+ <Button size="sm" variant="ghost" onClick={onClose}>
+ {t("common.cancel")}
+ </Button>
+ {mode === "files" ? (
+ <Button
+ size="sm"
+ onClick={() => void install()}
+ disabled={!report?.ready || installing || inspecting}
+ className="gap-1.5"
+ >
+ {installing ? (
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <Check className="h-3.5 w-3.5" />
+ )}
+ {t("skill_upload.install")}
+ </Button>
+ ) : (
+ <Button
+ size="sm"
+ onClick={installFromLink}
+ disabled={!link.trim() || importFromLink.isPending}
+ className="gap-1.5"
+ >
+ {importFromLink.isPending ? (
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <Check className="h-3.5 w-3.5" />
+ )}
+ {t("skill_upload.install")}
+ </Button>
+ )}
+ </div>
+ </footer>
+ )}
+ </div>
+ </div>
+ );
+}
+
+/** What is stopping the install, in one sentence — or what will happen. */
+function describeBlocker(
+ report: SkillUploadReport | null,
+ fileCount: number,
+ t: (key: string) => string,
+): string {
+ if (fileCount === 0) return t("skill_upload.blocker_no_files");
+ if (!report) return "";
+ if (report.problems.length > 0) return report.problems[0];
+ if (report.lint_findings.length > 0) return t("skill_upload.will_land_as_draft");
+ return t("skill_upload.ready");
+}
+
+function BackLink({ label, onClick }: { label: string; onClick: () => void }) {
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ className="flex w-fit items-center gap-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground"
+ >
+ <ArrowLeft className="h-3 w-3" />
+ {label}
+ </button>
+ );
+}
+
+function SourceCard({
+ icon,
+ title,
+ description,
+ action,
+ onSelect,
+}: {
+ icon: React.ReactNode;
+ title: string;
+ description: string;
+ action: string;
+ onSelect: () => void;
+}) {
+ return (
+ <button
+ type="button"
+ onClick={onSelect}
+ className="group flex items-start gap-4 rounded-lg border border-border bg-muted/20 p-4 text-left transition-colors hover:border-primary hover:bg-muted/40"
+ >
+ <span className="mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-md border border-border bg-card text-primary">
+ {icon}
+ </span>
+ <span className="min-w-0 flex-1">
+ <span className="block text-sm font-semibold">{title}</span>
+ <span className="mt-0.5 block text-xs text-muted-foreground">{description}</span>
+ </span>
+ <span className="mt-2 flex shrink-0 items-center gap-1 text-xs font-medium text-muted-foreground transition-colors group-hover:text-foreground">
+ {action}
+ <ArrowRight className="h-3 w-3" />
+ </span>
+ </button>
+ );
+}
+
+/** What the upload holds, once the server has looked at it. */
+function UploadReport({
+ report,
+ inspecting,
+ fileCount,
+ onReplace,
+ onClear,
+}: {
+ report: SkillUploadReport | null;
+ inspecting: boolean;
+ fileCount: number;
+ onReplace: () => void;
+ onClear: () => void;
+}) {
+ const t = useT();
+
+ if (inspecting || !report) {
+ return (
+ <div className="flex items-center gap-2 rounded-lg border border-border bg-muted/20 px-4 py-6 text-sm text-muted-foreground">
+ <Loader2 className="h-4 w-4 animate-spin" />
+ {`${t("skill_upload.inspecting")} (${fileCount})`}
+ </div>
+ );
+ }
+
+ return (
+ <div className="flex flex-col gap-3">
+ <div className="flex items-start justify-between gap-4 rounded-lg border border-border bg-muted/20 px-4 py-3">
+ <div className="min-w-0">
+ {report.skill ? (
+ <>
+ <p className="truncate text-sm font-semibold">{report.skill.name}</p>
+ <p className="mt-0.5 line-clamp-2 text-xs text-muted-foreground">
+ {report.skill.description}
+ </p>
+ </>
+ ) : (
+ <p className="text-sm font-medium text-muted-foreground">
+ {t("skill_upload.no_skill_detected")}
+ </p>
+ )}
+ <p className="mt-1.5 text-[11px] text-muted-foreground">
+ {`${report.files.length} ${t("skill_upload.files")} · ${formatBytes(report.total_bytes)}`}
+ </p>
+ </div>
+ <div className="flex shrink-0 items-center gap-1">
+ <Button size="sm" variant="outline" onClick={onReplace}>
+ {t("skill_upload.replace")}
+ </Button>
+ <Button size="sm" variant="ghost" onClick={onClear}>
+ {t("skill_upload.clear")}
+ </Button>
+ </div>
+ </div>
+
+ {report.files.length > 0 && (
+ <div className="max-h-[180px] overflow-y-auto rounded-lg border border-border bg-background">
+ <ul className="flex flex-col gap-0.5 p-2">
+ {report.files.map((path) => (
+ <li
+ key={path}
+ className="truncate rounded px-2 py-1 font-mono text-[11px] text-muted-foreground"
+ title={path}
+ >
+ {path}
+ </li>
+ ))}
+ </ul>
+ </div>
+ )}
+
+ {report.problems.map((problem) => (
+ <Notice key={problem} tone="error" icon={<AlertTriangle className="h-3.5 w-3.5" />}>
+ {problem}
+ </Notice>
+ ))}
+
+ {report.lint_findings.length > 0 && (
+ <Notice tone="warn" icon={<ShieldAlert className="h-3.5 w-3.5" />}>
+ <span className="font-medium">{t("skill_upload.lint_title")}</span>{" "}
+ {t("skill_upload.lint_body")}
+ <ul className="mt-1 list-disc pl-4">
+ {report.lint_findings.slice(0, 4).map((finding) => (
+ <li key={finding}>{finding}</li>
+ ))}
+ </ul>
+ </Notice>
+ )}
+
+ {report.ignored.length > 0 && (
+ <p className="text-[11px] text-muted-foreground">
+ {`${t("skill_upload.ignored")} (${report.ignored.length}): ${report.ignored
+ .slice(0, 3)
+ .map((path) => path.split("/").pop())
+ .join(", ")}${report.ignored.length > 3 ? ", …" : ""}`}
+ </p>
+ )}
+ </div>
+ );
+}
+
+function Notice({
+ tone,
+ icon,
+ children,
+}: {
+ tone: "error" | "warn";
+ icon: React.ReactNode;
+ children: React.ReactNode;
+}) {
+ return (
+ <div
+ className={cn(
+ "flex items-start gap-2 rounded-md border px-3 py-2 text-xs",
+ // Amber rather than a token: the app has no warning colour, and its
+ // brand accent IS amber — so the shade is spelled out for both
+ // appearances instead of borrowing one that only reads in the dark.
+ tone === "error"
+ ? "border-destructive/40 bg-destructive/10 text-destructive"
+ : "border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300",
+ )}
+ >
+ <span className="mt-0.5 shrink-0">{icon}</span>
+ <div className="min-w-0">{children}</div>
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/views/SkillsView.tsx b/jarvis/ui/web/frontend/src/views/SkillsView.tsx
index f53c62910b..130d59b3a9 100644
--- a/jarvis/ui/web/frontend/src/views/SkillsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/SkillsView.tsx
@@ -30,9 +30,11 @@ import {
GripVertical,
ListChecks,
Check,
+ Upload,
} from "lucide-react";
import { SkillFinderDialog } from "@/views/SkillFinderDialog";
import { SkillCreateDialog } from "@/views/SkillCreateDialog";
+import { SkillUploadDialog } from "@/views/SkillUploadDialog";
import { ViewHeader } from "@/views/ChatsView";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Button } from "@/components/ui/button";
@@ -122,6 +124,7 @@ export function SkillsView() {
const [selected, setSelected] = useState<string | null>(null);
const [finderOpen, setFinderOpen] = useState(false);
const [createOpen, setCreateOpen] = useState(false);
+ const [uploadOpen, setUploadOpen] = useState(false);
const [confirmDelete, setConfirmDelete] = useState<SkillSummary | null>(null);
// Multi-select: a "selection mode" turns the per-row drag handle into a
@@ -275,6 +278,15 @@ export function SkillsView() {
<Plus className="h-3.5 w-3.5" />
Neuer Skill
</Button>
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => setUploadOpen(true)}
+ className="gap-1.5"
+ >
+ <Upload className="h-3.5 w-3.5" />
+ {t("skill_upload.button")}
+ </Button>
<Button
size="sm"
variant="outline"
@@ -325,6 +337,12 @@ export function SkillsView() {
onCreated={(name) => setSelected(name)}
/>
+ <SkillUploadDialog
+ open={uploadOpen}
+ onClose={() => setUploadOpen(false)}
+ onInstalled={(name) => setSelected(name)}
+ />
+
{confirmDelete && (
<DeleteConfirmDialog
skill={confirmDelete}