Changesets · Branches · Tags · Compare
| Changeset | 4006725820882d04005c5ddae48a569681594e8041add76bcec25230b4159878 |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-08-18 20:08 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-08-18 20:08 +02:00 |
| Parents | 26b03efb6034 |
1 file changed
modified core/skills.js +36 −31
| @@ -1,14 +1,14 @@ | ||
| 1 | -// Elffuss Code skills: markdown instructions (Claude Code's SKILL.md format) | |
| 2 | -// that the model follows when they apply. They install from the big OFFICIAL | |
| 3 | -// catalogue (github.com/anthropics/skills), from the official plugins, or from | |
| 4 | -// ANY public repo (community marketplaces such as OpenClaude/openclaw). | |
| 5 | -// Everything is transparent: you see the repo, the list, and the SKILL.md that | |
| 6 | -// gets injected. They are stored in IndexedDB (nothing leaves the browser). | |
| 1 | +// Skills de Elffuss Code: instrucciones en markdown (formato SKILL.md de | |
| 2 | +// Claude Code) que el modelo sigue cuando aplican. Se instalan desde el | |
| 3 | +// catálogo grande OFICIAL (github.com/anthropics/skills), desde los plugins | |
| 4 | +// oficiales, o desde CUALQUIER repo público (marketplaces de la comunidad | |
| 5 | +// tipo OpenClaude/openclaw). Todo transparente: se ve el repo, la lista y el | |
| 6 | +// SKILL.md que se inyecta. Se guardan en IndexedDB (nada sale del navegador). | |
| 7 | 7 | import * as db from './db.js'; |
| 8 | 8 | |
| 9 | -const KEY = 'skills'; // installed skills | |
| 10 | -const SRC_KEY = 'skills.sources'; // custom repos added by the user | |
| 11 | -const MAX_SKILL = 12_000; // characters of the body injected into the model | |
| 9 | +const KEY = 'skills'; // skills instaladas | |
| 10 | +const SRC_KEY = 'skills.sources'; // repos personalizados añadidos por el usuario | |
| 11 | +const MAX_SKILL = 12_000; // caracteres del cuerpo que se inyectan al modelo | |
| 12 | 12 | |
| 13 | 13 | export const CATALOG_REPO = 'anthropics/skills'; |
| 14 | 14 | export const DEFAULT_SOURCES = [ |
| @@ -17,11 +17,12 @@ | ||
| 17 | 17 | { repo: 'anthropics/claude-plugins-official', label: 'Anthropic · Claude Code Plugins (oficial)', official: true }, |
| 18 | 18 | ]; |
| 19 | 19 | |
| 20 | -let cache = []; // installed, in memory (so that systemPrompt can be synchronous) | |
| 20 | +let cache = []; // instaladas, en memoria (para que el systemPrompt sea síncrono) | |
| 21 | 21 | |
| 22 | -// `loaded` tells "there are no skills" apart from "we could not read them". A | |
| 23 | -// transient IndexedDB failure used to leave the cache empty, and the next | |
| 24 | -// install() then persisted that emptiness — wiping every installed skill. | |
| 22 | +// `loaded` distingue «no hay skills» de «no se pudo leer»: si la lectura | |
| 23 | +// falla, cache queda vacío pero loaded=false, y install() se niega a persistir | |
| 24 | +// (antes, un fallo transitorio de IndexedDB borraba TODAS las skills al | |
| 25 | +// guardar la siguiente). | |
| 25 | 26 | let loaded = false; |
| 26 | 27 | export async function initSkills() { |
| 27 | 28 | try { |
| @@ -31,7 +32,7 @@ | ||
| 31 | 32 | } catch (e) { |
| 32 | 33 | cache = []; |
| 33 | 34 | loaded = false; |
| 34 | - console.warn('[elffuss] could not read skills; refusing to overwrite them', e); | |
| 35 | + console.warn('[elffuss] no se pudieron leer las skills; no las sobrescribiré', e); | |
| 35 | 36 | } |
| 36 | 37 | return cache; |
| 37 | 38 | } |
| @@ -42,21 +43,20 @@ | ||
| 42 | 43 | export function isInstalled(repo, path) { return cache.some(s => s.repo === repo && s.path === path); } |
| 43 | 44 | |
| 44 | 45 | export async function install(skill) { |
| 45 | - // If the initial read failed, `cache` does not represent what is installed: | |
| 46 | - // retry before writing, and refuse rather than destroy. | |
| 46 | + // Si la carga inicial falló, cache no representa lo instalado: reintentar | |
| 47 | + // leer antes de escribir. Sin esto, guardar aquí borraría las skills reales. | |
| 47 | 48 | if (!loaded) { |
| 48 | 49 | await initSkills(); |
| 49 | - if (!loaded) throw new Error('Could not read your saved skills; not installing, so none are lost. Reload and try again.'); | |
| 50 | + if (!loaded) throw new Error('No pude leer tus skills guardadas; no instalo para no perderlas. Recarga la página e inténtalo otra vez.'); | |
| 50 | 51 | } |
| 51 | 52 | cache = cache.filter(s => !(s.repo === skill.repo && s.path === skill.path) && s.name !== skill.name); |
| 52 | 53 | const entry = { ...skill, content: (skill.content || '').slice(0, MAX_SKILL) }; |
| 53 | 54 | cache.push(entry); |
| 54 | 55 | await db.set('kv', KEY, cache); |
| 55 | - return entry; // returns the full skill (name, description…) | |
| 56 | + return entry; // devuelve la skill completa (name, description…) | |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | -// "How to use it" message after installing: what it does + an example of what | |
| 59 | -// to ask for. The returned copy is user-facing and stays in Spanish. | |
| 59 | +// Mensaje «cómo usarla» tras instalar: qué hace + un ejemplo de qué pedir. | |
| 60 | 60 | export function usageMessage(skill) { |
| 61 | 61 | const desc = (skill.description || '').trim(); |
| 62 | 62 | const ejemplo = firstExample(skill) || `algo relacionado con «${skill.name}»`; |
| @@ -65,7 +65,7 @@ | ||
| 65 | 65 | `Ya la sigo en cada conversación. Para usarla, pídeme por ejemplo:\n\n> ${ejemplo}`; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -// Tries to pull a usage example out of the SKILL.md body (example/usage lines). | |
| 68 | +// Intenta sacar un ejemplo de uso del cuerpo del SKILL.md (líneas de ejemplo/uso). | |
| 69 | 69 | function firstExample(skill) { |
| 70 | 70 | const body = skill.content || ''; |
| 71 | 71 | const m = body.match(/(?:ejemplo|example|uso|usage|prueba|try)[^\n:]*[::]\s*["“]?([^\n"”]{6,90})/i) |
| @@ -82,7 +82,7 @@ | ||
| 82 | 82 | return cache.find(s => s.name.toLowerCase() === String(name).toLowerCase()) || null; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -// ---- sources (repos) ---- | |
| 85 | +// ---- fuentes (repos) ---- | |
| 86 | 86 | export async function sources() { |
| 87 | 87 | const custom = (await db.get('kv', SRC_KEY).catch(() => null)) || []; |
| 88 | 88 | return [...DEFAULT_SOURCES, ...custom]; |
| @@ -101,8 +101,8 @@ | ||
| 101 | 101 | await db.set('kv', SRC_KEY, custom.filter(s => s.repo !== repo)); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | -// ---- catalogue from GitHub ---- | |
| 105 | -// A single call to the repo's git tree → every SKILL.md. | |
| 104 | +// ---- catálogo desde GitHub ---- | |
| 105 | +// Una sola llamada al árbol git del repo → todos los SKILL.md. | |
| 106 | 106 | export async function listFromRepo(repo) { |
| 107 | 107 | let tree, branch; |
| 108 | 108 | for (const b of ['main', 'master']) { |
| @@ -117,7 +117,7 @@ | ||
| 117 | 117 | .sort((a, b) => a.dir.localeCompare(b.dir)); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | -// Downloads the SKILL.md and installs it (simple YAML frontmatter). | |
| 120 | +// Descarga el SKILL.md y lo instala (frontmatter YAML simple). | |
| 121 | 121 | export async function installFromRepo(entry) { |
| 122 | 122 | let md = null; |
| 123 | 123 | for (const b of [entry.branch, 'main', 'master'].filter(Boolean)) { |
| @@ -139,9 +139,9 @@ | ||
| 139 | 139 | return { name, description, content }; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | -// Skill maker: Elffuss builds a skill of its own (SKILL.md) out of whatever the | |
| 143 | -// user wants, and installs it instantly. It shows up in the Skills tab and is | |
| 144 | -// injected into the prompt of the following turns. | |
| 142 | +// Creador de skills: Elffuss fabrica una skill propia (SKILL.md) a partir de | |
| 143 | +// lo que el usuario quiere, y la instala al instante. Aparece en la pestaña | |
| 144 | +// Skills y se inyecta en el prompt de los siguientes turnos. | |
| 145 | 145 | export async function createSkill({ name, description, instructions } = {}) { |
| 146 | 146 | if (!name || !instructions) throw new Error('Faltan name o instructions'); |
| 147 | 147 | const skill = { |
| @@ -155,11 +155,16 @@ | ||
| 155 | 155 | return `Skill «${skill.name}» creada e instalada. Ya la sigo en cada conversación (mírala en la pestaña Skills).`; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | -// Block for the systemPrompt (synchronous, straight from the cache). The | |
| 159 | -// injected wording is prompt content, not documentation: it stays in Spanish. | |
| 158 | +// Bloque para el systemPrompt (síncrono, desde la caché). | |
| 160 | 159 | export function skillsPromptBlock() { |
| 161 | 160 | if (!cache.length) return ''; |
| 161 | + const nombres = cache.map(s => `«${s.name}»`).join(', '); | |
| 162 | 162 | const parts = cache.map(s => |
| 163 | 163 | `### Skill «${s.name}»${s.repo ? ` (de ${s.repo})` : ''}\n${s.description || ''}\n${(s.content || '').slice(0, MAX_SKILL)}`); |
| 164 | - return `\n\nSKILLS ACTIVAS (instrucciones especializadas; síguelas cuando la tarea encaje):\n${parts.join('\n\n')}`; | |
| 164 | + return `\n\nSKILLS INSTALADAS — son capacidades que TIENES AHORA MISMO: ${nombres}.\n` + | |
| 165 | + `REGLAS con las skills:\n` + | |
| 166 | + `- Si la petición encaja con una skill (aunque el usuario la nombre con otras palabras o un nombre parecido, empareja por el TEMA de su descripción), ÚSALA siguiendo sus instrucciones al pie de la letra.\n` + | |
| 167 | + `- NUNCA digas que no tienes esa skill o esa capacidad: la tienes, está aquí abajo.\n` + | |
| 168 | + `- Si la skill incluye una plantilla de app (HTML), créala con la herramienta app.create COPIANDO esa plantilla y adaptando solo lo que la skill indique — no inventes una app genérica distinta.\n\n` + | |
| 169 | + parts.join('\n\n'); | |
| 165 | 170 | } |