Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

feat(cli): adicionar omniroute skills e marketplace (Fases 3.2 e 3.3)

diegosouzapw2468ebf8f71f
diff --git a/bin/cli/commands/registry.mjs b/bin/cli/commands/registry.mjs
index d4a8cb20c2..d3eb5b7d50 100644
--- a/bin/cli/commands/registry.mjs
+++ b/bin/cli/commands/registry.mjs
@@ -1,4 +1,5 @@
import { registerMemory } from "./memory.mjs";
+import { registerSkills } from "./skills.mjs";
import { registerChat } from "./chat.mjs";
import { registerStream } from "./stream.mjs";
import { registerSimulate } from "./simulate.mjs";
@@ -32,6 +33,7 @@ import { registerCompletion } from "./completion.mjs";
export function registerCommands(program) {
registerMemory(program);
+ registerSkills(program);
registerChat(program);
registerStream(program);
registerSimulate(program);
diff --git a/bin/cli/commands/skills.mjs b/bin/cli/commands/skills.mjs
new file mode 100644
index 0000000000..8d40714a95
--- /dev/null
+++ b/bin/cli/commands/skills.mjs
@@ -0,0 +1,373 @@
+import { readFileSync } from "node:fs";
+import { apiFetch } from "../api.mjs";
+import { emit } from "../output.mjs";
+import { t } from "../i18n.mjs";
+
+function truncate(v, len = 40) {
+ if (v == null) return "-";
+ const s = String(v);
+ return s.length > len ? s.slice(0, len - 1) + "…" : s;
+}
+
+function fmtTs(v) {
+ if (!v) return "-";
+ try {
+ return new Date(v).toLocaleString();
+ } catch {
+ return String(v);
+ }
+}
+
+async function confirm(question) {
+ return new Promise((resolve) => {
+ process.stdout.write(`${question} (yes/no) `);
+ process.stdin.setEncoding("utf8");
+ process.stdin.once("data", (chunk) => {
+ resolve(chunk.toString().trim().toLowerCase().startsWith("y"));
+ });
+ });
+}
+
+const skillSchema = [
+ { key: "id", header: "ID", width: 22 },
+ { key: "name", header: "Name", width: 28 },
+ { key: "type", header: "Type", width: 12 },
+ { key: "version", header: "Ver", width: 8 },
+ { key: "enabled", header: "Enabled", formatter: (v) => (v ? "✓" : "✗") },
+ { key: "lastRun", header: "Last Run", formatter: fmtTs },
+];
+
+const executionSchema = [
+ { key: "id", header: "Exec ID", width: 22 },
+ { key: "skillId", header: "Skill", width: 22 },
+ { key: "status", header: "Status", width: 12 },
+ { key: "startedAt", header: "Started", formatter: fmtTs },
+ { key: "duration", header: "Duration", formatter: (v) => (v != null ? `${v}ms` : "-") },
+ { key: "error", header: "Error", formatter: truncate },
+];
+
+const marketplaceSchema = [
+ { key: "id", header: "Package ID", width: 22 },
+ { key: "name", header: "Name", width: 28 },
+ { key: "category", header: "Category", width: 14 },
+ { key: "version", header: "Latest", width: 10 },
+ { key: "downloads", header: "DLs", formatter: (v) => (v != null ? v.toLocaleString() : "0") },
+ { key: "rating", header: "★", formatter: (v) => (v ? "★".repeat(Math.round(v)) : "-") },
+ { key: "author", header: "Author", width: 18 },
+];
+
+export async function runSkillsList(opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const params = new URLSearchParams();
+ if (opts.type) params.set("type", opts.type);
+ if (opts.enabled) params.set("enabled", "true");
+ if (opts.disabled) params.set("enabled", "false");
+ if (opts.apiKey) params.set("apiKey", opts.apiKey);
+ const res = await apiFetch(`/api/skills?${params}`);
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data.items ?? data, globalOpts, skillSchema);
+}
+
+export async function runSkillsGet(id, opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const res = await apiFetch(`/api/skills/${id}`);
+ if (!res.ok) {
+ process.stderr.write(`Not found: ${id}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data, globalOpts, skillSchema);
+}
+
+export async function runSkillsInstall(opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ let body = {};
+ if (opts.fromFile) {
+ body = JSON.parse(readFileSync(opts.fromFile, "utf8"));
+ } else if (opts.fromUrl) {
+ body = { url: opts.fromUrl };
+ } else {
+ process.stderr.write("--from-file or --from-url required\n");
+ process.exit(2);
+ }
+ if (opts.type) body.type = opts.type;
+ if (opts.enable) body.enabled = true;
+ const res = await apiFetch("/api/skills/install", { method: "POST", body });
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data, globalOpts, skillSchema);
+}
+
+export async function runSkillsEnable(id, opts, cmd) {
+ const res = await apiFetch("/api/mcp/tools/call", {
+ method: "POST",
+ body: { name: "omniroute_skills_enable", arguments: { skillId: id, enabled: true } },
+ });
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ process.stdout.write(`Enabled: ${id}\n`);
+}
+
+export async function runSkillsDisable(id, opts, cmd) {
+ if (!opts.yes) {
+ const ok = await confirm(`Disable ${id}?`);
+ if (!ok) return;
+ }
+ const res = await apiFetch("/api/mcp/tools/call", {
+ method: "POST",
+ body: { name: "omniroute_skills_enable", arguments: { skillId: id, enabled: false } },
+ });
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ process.stdout.write(`Disabled: ${id}\n`);
+}
+
+export async function runSkillsDelete(id, opts, cmd) {
+ if (!opts.yes) {
+ const ok = await confirm(`Delete skill ${id}?`);
+ if (!ok) return;
+ }
+ const res = await apiFetch(`/api/skills/${id}`, { method: "DELETE" });
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ process.stdout.write(`Deleted: ${id}\n`);
+}
+
+export async function runSkillsExecute(id, opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const input = opts.input
+ ? JSON.parse(opts.input)
+ : opts.inputFile
+ ? JSON.parse(readFileSync(opts.inputFile, "utf8"))
+ : {};
+ const res = await apiFetch("/api/mcp/tools/call", {
+ method: "POST",
+ body: { name: "omniroute_skills_execute", arguments: { skillId: id, input } },
+ timeout: opts.timeout ?? 30000,
+ });
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data, globalOpts);
+}
+
+export async function runSkillsExecutions(opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const params = new URLSearchParams({ limit: String(opts.limit ?? 50) });
+ if (opts.skill) params.set("skillId", opts.skill);
+ if (opts.status) params.set("status", opts.status);
+ const res = await apiFetch(`/api/skills/executions?${params}`);
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data.items ?? data, globalOpts, executionSchema);
+}
+
+export async function runSkillsshList(opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const res = await apiFetch("/api/skills/skillssh");
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data.items ?? data, globalOpts, skillSchema);
+}
+
+export async function runSkillsshInstall(url, opts, cmd) {
+ const res = await apiFetch("/api/skills/skillssh/install", {
+ method: "POST",
+ body: { url },
+ });
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ process.stdout.write(`Installed: ${data.skillId ?? url}\n`);
+}
+
+export async function runMarketplaceSearch(query, opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const params = new URLSearchParams({ limit: String(opts.limit ?? 30) });
+ if (query) params.set("q", query);
+ if (opts.category) params.set("category", opts.category);
+ if (opts.tag) params.set("tag", opts.tag);
+ if (opts.sort) params.set("sort", opts.sort);
+ const res = await apiFetch(`/api/skills/marketplace?${params}`);
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data.items ?? data, globalOpts, marketplaceSchema);
+}
+
+export async function runMarketplaceInfo(packageId, opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const res = await apiFetch(`/api/skills/marketplace?id=${packageId}`);
+ if (!res.ok) {
+ process.stderr.write(`Not found: ${packageId}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data, globalOpts, marketplaceSchema);
+ if (globalOpts.output !== "json" && globalOpts.output !== "jsonl") {
+ process.stdout.write("\nReadme:\n");
+ process.stdout.write(data.readme ?? "(no readme)");
+ process.stdout.write("\n");
+ }
+}
+
+export async function runMarketplaceInstall(packageId, opts, cmd) {
+ if (!opts.yes) {
+ const infoRes = await apiFetch(`/api/skills/marketplace?id=${packageId}`);
+ if (infoRes.ok) {
+ const info = await infoRes.json();
+ process.stdout.write(`Installing: ${info.name ?? packageId} v${info.version ?? "?"}\n`);
+ process.stdout.write(`Permissions: ${(info.permissions ?? []).join(", ") || "(none)"}\n`);
+ }
+ const ok = await confirm("Continue?");
+ if (!ok) process.exit(0);
+ }
+ const res = await apiFetch("/api/skills/marketplace/install", {
+ method: "POST",
+ body: { packageId, version: opts.version ?? "latest", enable: !!opts.enable },
+ });
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ process.stdout.write(`Installed: ${data.skillId ?? packageId}\n`);
+}
+
+export async function runMarketplaceCategories(opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const res = await apiFetch("/api/skills/marketplace?facets=categories");
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data.categories ?? data, globalOpts);
+}
+
+export async function runMarketplaceFeatured(opts, cmd) {
+ const globalOpts = cmd.optsWithGlobals();
+ const res = await apiFetch("/api/skills/marketplace?featured=true");
+ if (!res.ok) {
+ process.stderr.write(`Error: ${res.status}\n`);
+ process.exit(1);
+ }
+ const data = await res.json();
+ emit(data.items ?? data, globalOpts, marketplaceSchema);
+}
+
+function registerSkillsMarketplace(skills) {
+ const mp = skills.command("marketplace").description(t("skills.marketplace.description"));
+
+ mp.command("search [query]")
+ .description(t("skills.mp.search.description"))
+ .option("--category <c>", t("skills.mp.search.category"))
+ .option("--tag <t>", t("skills.mp.search.tag"))
+ .option("--limit <n>", t("skills.mp.search.limit"), parseInt, 30)
+ .option("--sort <s>", t("skills.mp.search.sort"))
+ .action(runMarketplaceSearch);
+
+ mp.command("info <packageId>")
+ .description(t("skills.mp.info.description"))
+ .action(runMarketplaceInfo);
+
+ mp.command("install <packageId>")
+ .description(t("skills.mp.install.description"))
+ .option("--version <v>", t("skills.mp.install.version"), "latest")
+ .option("--enable", t("skills.mp.install.enable"))
+ .option("--yes", t("skills.mp.install.yes"))
+ .action(runMarketplaceInstall);
+
+ mp.command("categories")
+ .description(t("skills.mp.categories.description"))
+ .action(runMarketplaceCategories);
+
+ mp.command("featured")
+ .description(t("skills.mp.featured.description"))
+ .action(runMarketplaceFeatured);
+}
+
+export function registerSkills(program) {
+ const skills = program.command("skills").description(t("skills.description"));
+
+ skills
+ .command("list")
+ .description(t("skills.list.description"))
+ .option("--type <type>", t("skills.list.type"))
+ .option("--enabled", t("skills.list.enabled"))
+ .option("--disabled", t("skills.list.disabled"))
+ .option("--api-key <key>", t("skills.list.api_key"))
+ .action(runSkillsList);
+
+ skills.command("get <id>").description(t("skills.get.description")).action(runSkillsGet);
+
+ skills
+ .command("install")
+ .description(t("skills.install.description"))
+ .option("--from-file <path>", t("skills.install.from_file"))
+ .option("--from-url <url>", t("skills.install.from_url"))
+ .option("--type <type>", t("skills.install.type"))
+ .option("--enable", t("skills.install.enable"))
+ .action(runSkillsInstall);
+
+ skills.command("enable <id>").description(t("skills.enable.description")).action(runSkillsEnable);
+
+ skills
+ .command("disable <id>")
+ .description(t("skills.disable.description"))
+ .option("--yes", t("skills.disable.yes"))
+ .action(runSkillsDisable);
+
+ skills
+ .command("delete <id>")
+ .description(t("skills.delete.description"))
+ .option("--yes", t("skills.delete.yes"))
+ .action(runSkillsDelete);
+
+ skills
+ .command("execute <id>")
+ .description(t("skills.execute.description"))
+ .option("--input <json>", t("skills.execute.input"))
+ .option("--input-file <path>", t("skills.execute.input_file"))
+ .option("--timeout <ms>", t("skills.execute.timeout"), parseInt, 30000)
+ .action(runSkillsExecute);
+
+ skills
+ .command("executions")
+ .description(t("skills.executions.description"))
+ .option("--skill <id>", t("skills.executions.skill"))
+ .option("--limit <n>", t("skills.executions.limit"), parseInt, 50)
+ .option("--status <s>", t("skills.executions.status"))
+ .action(runSkillsExecutions);
+
+ const skillssh = skills.command("skillssh").description(t("skills.skillssh.description"));
+ skillssh.command("list").action(runSkillsshList);
+ skillssh.command("install <url>").action(runSkillsshInstall);
+
+ registerSkillsMarketplace(skills);
+}
diff --git a/bin/cli/locales/en.json b/bin/cli/locales/en.json
index 60e77ced6a..b000ef1f46 100644
--- a/bin/cli/locales/en.json
+++ b/bin/cli/locales/en.json
@@ -274,6 +274,79 @@
"noServer": "Server not running. Start with: omniroute serve",
"noModels": "No models found."
},
+ "skills": {
+ "description": "Manage OmniRoute skills (sandbox, builtin, custom, hybrid, skillssh)",
+ "list": {
+ "description": "List installed skills",
+ "type": "Filter by type (sandbox|custom|builtin|hybrid|skillssh)",
+ "enabled": "Show only enabled skills",
+ "disabled": "Show only disabled skills",
+ "api_key": "Filter by API key"
+ },
+ "get": {
+ "description": "Get details for a skill by ID"
+ },
+ "install": {
+ "description": "Install a skill from file or URL",
+ "from_file": "Path to skill JSON definition file",
+ "from_url": "URL of remote skill definition",
+ "type": "Skill type (sandbox|custom|hybrid)",
+ "enable": "Enable skill after install"
+ },
+ "enable": {
+ "description": "Enable a skill by ID"
+ },
+ "disable": {
+ "description": "Disable a skill by ID",
+ "yes": "Skip confirmation prompt"
+ },
+ "delete": {
+ "description": "Delete a skill by ID",
+ "yes": "Skip confirmation prompt"
+ },
+ "execute": {
+ "description": "Execute a skill by ID",
+ "input": "JSON input object",
+ "input_file": "Path to JSON input file",
+ "timeout": "Execution timeout in ms (default: 30000)"
+ },
+ "executions": {
+ "description": "List skill execution history",
+ "skill": "Filter by skill ID",
+ "limit": "Maximum results (default: 50)",
+ "status": "Filter by status (running|completed|failed)"
+ },
+ "skillssh": {
+ "description": "Manage skills installed via SSH"
+ },
+ "marketplace": {
+ "description": "Browse and install skills from the marketplace"
+ },
+ "mp": {
+ "search": {
+ "description": "Search marketplace packages",
+ "category": "Filter by category",
+ "tag": "Filter by tag",
+ "limit": "Maximum results (default: 30)",
+ "sort": "Sort by: downloads|rating|recent"
+ },
+ "info": {
+ "description": "Show package details and readme"
+ },
+ "install": {
+ "description": "Install a marketplace package",
+ "version": "Package version (default: latest)",
+ "enable": "Enable after install",
+ "yes": "Skip confirmation prompt"
+ },
+ "categories": {
+ "description": "List marketplace categories"
+ },
+ "featured": {
+ "description": "Show featured marketplace packages"
+ }
+ }
+ },
"memory": {
"description": "Manage OmniRoute conversational memory (FTS5 + vector)",
"search": {
diff --git a/bin/cli/locales/pt-BR.json b/bin/cli/locales/pt-BR.json
index 61c498a890..87b02ea04d 100644
--- a/bin/cli/locales/pt-BR.json
+++ b/bin/cli/locales/pt-BR.json
@@ -274,6 +274,79 @@
"noServer": "Servidor não está em execução. Inicie com: omniroute serve",
"noModels": "Nenhum modelo encontrado."
},
+ "skills": {
+ "description": "Gerenciar skills do OmniRoute (sandbox, builtin, custom, hybrid, skillssh)",
+ "list": {
+ "description": "Listar skills instaladas",
+ "type": "Filtrar por tipo (sandbox|custom|builtin|hybrid|skillssh)",
+ "enabled": "Mostrar apenas skills habilitadas",
+ "disabled": "Mostrar apenas skills desabilitadas",
+ "api_key": "Filtrar por chave de API"
+ },
+ "get": {
+ "description": "Obter detalhes de uma skill por ID"
+ },
+ "install": {
+ "description": "Instalar uma skill a partir de arquivo ou URL",
+ "from_file": "Caminho para o arquivo JSON de definição da skill",
+ "from_url": "URL da definição remota da skill",
+ "type": "Tipo de skill (sandbox|custom|hybrid)",
+ "enable": "Habilitar skill após instalar"
+ },
+ "enable": {
+ "description": "Habilitar uma skill por ID"
+ },
+ "disable": {
+ "description": "Desabilitar uma skill por ID",
+ "yes": "Pular confirmação"
+ },
+ "delete": {
+ "description": "Deletar uma skill por ID",
+ "yes": "Pular confirmação"
+ },
+ "execute": {
+ "description": "Executar uma skill por ID",
+ "input": "Objeto JSON de entrada",
+ "input_file": "Caminho para arquivo JSON de entrada",
+ "timeout": "Timeout de execução em ms (padrão: 30000)"
+ },
+ "executions": {
+ "description": "Listar histórico de execuções de skills",
+ "skill": "Filtrar por ID de skill",
+ "limit": "Máximo de resultados (padrão: 50)",
+ "status": "Filtrar por status (running|completed|failed)"
+ },
+ "skillssh": {
+ "description": "Gerenciar skills instaladas via SSH"
+ },
+ "marketplace": {
+ "description": "Explorar e instalar skills do marketplace"
+ },
+ "mp": {
+ "search": {
+ "description": "Buscar pacotes no marketplace",
+ "category": "Filtrar por categoria",
+ "tag": "Filtrar por tag",
+ "limit": "Máximo de resultados (padrão: 30)",
+ "sort": "Ordenar por: downloads|rating|recent"
+ },
+ "info": {
+ "description": "Exibir detalhes e readme do pacote"
+ },
+ "install": {
+ "description": "Instalar um pacote do marketplace",
+ "version": "Versão do pacote (padrão: latest)",
+ "enable": "Habilitar após instalar",
+ "yes": "Pular confirmação"
+ },
+ "categories": {
+ "description": "Listar categorias do marketplace"
+ },
+ "featured": {
+ "description": "Exibir pacotes em destaque do marketplace"
+ }
+ }
+ },
"memory": {
"description": "Gerenciar memória conversacional do OmniRoute (FTS5 + vetorial)",
"search": {
diff --git a/tests/unit/cli-skills-commands.test.ts b/tests/unit/cli-skills-commands.test.ts
new file mode 100644
index 0000000000..c2e11512c2
--- /dev/null
+++ b/tests/unit/cli-skills-commands.test.ts
@@ -0,0 +1,221 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+
+const SKILLS_DATA = [
+ { id: "sk_pdf", name: "PDF Parser", type: "sandbox", version: "1.0.0", enabled: true },
+ { id: "sk_img", name: "Image Resize", type: "custom", version: "2.1.0", enabled: false },
+];
+
+const EXECUTIONS_DATA = [
+ {
+ id: "ex_001",
+ skillId: "sk_pdf",
+ status: "completed",
+ startedAt: "2026-05-10T10:00:00Z",
+ duration: 342,
+ },
+ {
+ id: "ex_002",
+ skillId: "sk_pdf",
+ status: "failed",
+ startedAt: "2026-05-09T12:00:00Z",
+ duration: 100,
+ error: "timeout",
+ },
+];
+
+const MARKETPLACE_DATA = [
+ {
+ id: "pkg_pdf",
+ name: "PDF Toolkit",
+ category: "documents",
+ version: "1.0.0",
+ downloads: 1200,
+ rating: 4.5,
+ author: "acme",
+ },
+];
+
+function makeResp(data: unknown, status = 200) {
+ const obj = {
+ ok: status < 400,
+ status,
+ exitCode: status < 400 ? 0 : 1,
+ json: () => Promise.resolve(data),
+ text: () => Promise.resolve(JSON.stringify(data)),
+ headers: new Headers(),
+ };
+ obj.json = obj.json.bind(obj);
+ obj.text = obj.text.bind(obj);
+ return obj;
+}
+
+async function captureStdout(fn: () => Promise<void>): Promise<string> {
+ const chunks: string[] = [];
+ const orig = process.stdout.write.bind(process.stdout);
+ process.stdout.write = (c: string | Uint8Array) => {
+ chunks.push(typeof c === "string" ? c : c.toString());
+ return true;
+ };
+ try {
+ await fn();
+ } finally {
+ process.stdout.write = orig;
+ }
+ return chunks.join("");
+}
+
+function makeCmd(output = "json") {
+ return { optsWithGlobals: () => ({ output, quiet: output !== "table" }) };
+}
+
+test("runSkillsList retorna lista de skills", async () => {
+ const origFetch = globalThis.fetch;
+ globalThis.fetch = (() => Promise.resolve(makeResp({ items: SKILLS_DATA }))) as any;
+
+ const { runSkillsList } = await import("../../bin/cli/commands/skills.mjs");
+ const out = await captureStdout(() => runSkillsList({}, makeCmd() as any));
+
+ globalThis.fetch = origFetch;
+ const parsed = JSON.parse(out);
+ assert.ok(Array.isArray(parsed));
+ assert.equal(parsed[0].id, "sk_pdf");
+});
+
+test("runSkillsList filtra por --enabled", async () => {
+ let capturedUrl = "";
+ const origFetch = globalThis.fetch;
+ globalThis.fetch = ((url: string) => {
+ capturedUrl = url;
+ return Promise.resolve(makeResp({ items: [SKILLS_DATA[0]] }));
+ }) as any;
+
+ const { runSkillsList } = await import("../../bin/cli/commands/skills.mjs");
+ await captureStdout(() => runSkillsList({ enabled: true }, makeCmd() as any));
+
+ globalThis.fetch = origFetch;
+ assert.ok(capturedUrl.includes("enabled=true"));
+});
+
+test("runSkillsGet busca /api/skills/:id", async () => {
+ let capturedUrl = "";
+ const origFetch = globalThis.fetch;
+ globalThis.fetch = ((url: string) => {
+ capturedUrl = url;
+ return Promise.resolve(makeResp(SKILLS_DATA[0]));
+ }) as any;
+
+ const { runSkillsGet } = await import("../../bin/cli/commands/skills.mjs");
+ const out = await captureStdout(() => runSkillsGet("sk_pdf", {}, makeCmd() as any));
+
+ globalThis.fetch = origFetch;
+ assert.ok(capturedUrl.includes("/api/skills/sk_pdf"));
+ const parsed = JSON.parse(out);
+ assert.equal(parsed.id, "sk_pdf");
+});
+
+test("runSkillsEnable envia POST para tools/call", async () => {
+ let capturedUrl = "";
+ let capturedInit: any = null;
+ const origFetch = globalThis.fetch;
+ globalThis.fetch = ((url: string, init: any) => {
+ capturedUrl = url;
+ capturedInit = init;
+ return Promise.resolve(makeResp({ ok: true }));
+ }) as any;
+
+ const { runSkillsEnable } = await import("../../bin/cli/commands/skills.mjs");
+ const out = await captureStdout(() => runSkillsEnable("sk_pdf", {}, makeCmd() as any));
+
+ globalThis.fetch = origFetch;
+ assert.ok(capturedUrl.includes("/api/mcp/tools/call"));
+ const body = JSON.parse(capturedInit?.body);
+ assert.equal(body.name, "omniroute_skills_enable");
+ assert.equal(body.arguments.skillId, "sk_pdf");
+ assert.equal(body.arguments.enabled, true);
+ assert.ok(out.includes("sk_pdf"));
+});
+
+test("runSkillsExecute envia POST com skillId e input", async () => {
+ let capturedBody: any = null;
+ const origFetch = globalThis.fetch;
+ globalThis.fetch = ((_url: string, init: any) => {
+ capturedBody = JSON.parse(init.body);
+ return Promise.resolve(makeResp({ result: "ok", output: "parsed" }));
+ }) as any;
+
+ const { runSkillsExecute } = await import("../../bin/cli/commands/skills.mjs");
+ await captureStdout(() =>
+ runSkillsExecute("sk_pdf", { input: '{"file":"doc.pdf"}' }, makeCmd() as any)
+ );
+
+ globalThis.fetch = origFetch;
+ assert.equal(capturedBody.name, "omniroute_skills_execute");
+ assert.equal(capturedBody.arguments.skillId, "sk_pdf");
+ assert.deepEqual(capturedBody.arguments.input, { file: "doc.pdf" });
+});
+
+test("runSkillsExecutions filtra por skill e status", async () => {
+ let capturedUrl = "";
+ const origFetch = globalThis.fetch;
+ globalThis.fetch = ((url: string) => {
+ capturedUrl = url;
+ return Promise.resolve(makeResp({ items: EXECUTIONS_DATA }));
+ }) as any;
+
+ const { runSkillsExecutions } = await import("../../bin/cli/commands/skills.mjs");
+ const out = await captureStdout(() =>
+ runSkillsExecutions({ skill: "sk_pdf", limit: 20, status: "completed" }, makeCmd() as any)
+ );
+
+ globalThis.fetch = origFetch;
+ assert.ok(capturedUrl.includes("skillId=sk_pdf"));
+ assert.ok(capturedUrl.includes("status=completed"));
+ const parsed = JSON.parse(out);
+ assert.ok(Array.isArray(parsed));
+});
+
+test("runMarketplaceSearch retorna pacotes com query e filtros", async () => {
+ let capturedUrl = "";
+ const origFetch = globalThis.fetch;
+ globalThis.fetch = ((url: string) => {
+ capturedUrl = url;
+ return Promise.resolve(makeResp({ items: MARKETPLACE_DATA }));
+ }) as any;
+
+ const { runMarketplaceSearch } = await import("../../bin/cli/commands/skills.mjs");
+ const out = await captureStdout(() =>
+ runMarketplaceSearch("pdf", { limit: 30, category: "documents" }, makeCmd() as any)
+ );
+
+ globalThis.fetch = origFetch;
+ assert.ok(capturedUrl.includes("q=pdf"));
+ assert.ok(capturedUrl.includes("category=documents"));
+ const parsed = JSON.parse(out);
+ assert.ok(Array.isArray(parsed));
+ assert.equal(parsed[0].id, "pkg_pdf");
+});
+
+test("runMarketplaceInstall --yes envia POST sem confirmação", async () => {
+ let capturedBody: any = null;
+ const origFetch = globalThis.fetch;
+ globalThis.fetch = ((_url: string, init: any) => {
+ capturedBody = JSON.parse(init?.body ?? "{}");
+ return Promise.resolve(makeResp({ skillId: "sk_pdf_installed" }));
+ }) as any;
+
+ const { runMarketplaceInstall } = await import("../../bin/cli/commands/skills.mjs");
+ const out = await captureStdout(() =>
+ runMarketplaceInstall(
+ "pkg_pdf",
+ { yes: true, version: "latest", enable: true },
+ makeCmd() as any
+ )
+ );
+
+ globalThis.fetch = origFetch;
+ assert.equal(capturedBody.packageId, "pkg_pdf");
+ assert.equal(capturedBody.version, "latest");
+ assert.equal(capturedBody.enable, true);
+ assert.ok(out.includes("sk_pdf_installed"));
+});