Elffuss BraidHub

utopia-ia/elffuss-code public

Add the Extensions panel and a Color Theme picker

A new activity-bar button opens an Extensions panel, drawn in the same box
as Settings and Skills. It searches Open VSX, with All / Themes / Snippets /
Languages chips, and sends nothing until the user searches or picks a chip.
Expanding a result reads the published package.json and says what would
apply and what would not (code-only contributions, icon themes for later,
packs), with the licence; install shows download progress and asks before
anything over 25 MB. Installed extensions can be enabled, disabled,
uninstalled, their licence read, and their themes chosen; an
"Install .vsix…" button takes a local file.

"Color Theme…" (panel and command palette) lists the built-in and installed
themes, previews them with the arrow keys and restores on Escape.

Extension-provided text always goes in with textContent. The panel strings
(ES/EN) live in js/ext/i18n.js so js/i18n.js stays untouched; the
inventory gains an "Extensiones" entry and the theme preference.
Changeset9d01cb86068a0ed1550838a205121ea3951b91c7bd1d4595fb564123e04296b2
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-10 15:09 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-11 14:16 +02:00
Parents6f0e1e16a05f

Browse the files at this changeset

6 files changed

added web/css/ext.css +61 −0
@@ -0,0 +1,61 @@
1+/* Panel de extensiones (Open VSX) y selector de tema. Se carga solo al abrir
2+ el panel; reutiliza las variables y las filas del panel de Skills. */
3+.ext-panel h3 { margin: 0 0 4px; font-size: 1rem; }
4+.ext-panel h3 .muted { font-weight: 400; font-size: .8rem; }
5+.ext-intro { margin: 0 0 8px; font-size: .76rem; line-height: 1.45; max-width: 760px; }
6+.ext-paused { margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; font-size: .76rem; background: rgba(229,165,58,.12); border: 1px solid rgba(229,165,58,.4); }
7+.ext-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
8+.ext-toolbar .ghost { font-size: .76rem; padding: 6px 12px; }
9+.ext-toolbar .ghost:hover { color: var(--fg); border-color: var(--accent2); }
10+.ext-search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
11+.ext-search input { flex: 1 1 260px; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 7px; padding: 7px 10px; font-size: .8rem; }
12+.ext-search input:focus { outline: none; border-color: var(--accent2); }
13+.ext-chips { display: flex; gap: 6px; flex-wrap: wrap; }
14+.ext-chip { background: var(--bg3); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 4px 11px; font-size: .74rem; cursor: pointer; }
15+.ext-chip:hover { color: var(--fg); border-color: var(--accent2); }
16+.ext-chip.on { color: #fff; border-color: var(--accent2); background: rgba(130,114,255,.22); }
17+.ext-msg { margin: 8px 0 0; padding: 6px 10px; border-radius: 8px; font-size: .78rem; background: rgba(63,185,112,.12); border: 1px solid rgba(63,185,112,.35); }
18+.ext-msg.err { background: rgba(255,107,139,.1); border-color: rgba(255,107,139,.4); }
19+.ext-msg[hidden] { display: none; }
20+.ext-hint { font-size: .78rem; margin: 10px 0 2px; }
21+.ext-results, .ext-installed { margin-top: 4px; }
22+.ext-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; background: var(--bg3); border: 1px solid var(--line); border-radius: 9px; margin-bottom: 6px; font-size: .8rem; }
23+.ext-row.off { opacity: .6; }
24+.ext-ico { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 7px; object-fit: contain; background: var(--bg2); }
25+.ext-ico-letra { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); border: 1px solid var(--line); }
26+.ext-main { flex: 1; min-width: 0; cursor: default; }
27+.ext-results .ext-main { cursor: pointer; }
28+.ext-title { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
29+.ext-title b { font-size: .84rem; overflow-wrap: anywhere; }
30+.ext-title .muted { font-size: .72rem; overflow-wrap: anywhere; }
31+.ext-badge { font-size: .66rem; color: #3fb970; }
32+.ext-desc { color: #b8c0d4; font-size: .76rem; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
33+.ext-meta { font-size: .7rem; margin-top: 4px; }
34+.ext-meta a { color: var(--accent2); }
35+.ext-detail { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
36+.ext-detail[hidden] { display: none; }
37+.ext-applies { font-size: .74rem; color: #7ee787; margin-top: 3px; }
38+.ext-nothing, .ext-ignored { font-size: .72rem; color: #e5a53a; margin-top: 3px; }
39+.ext-theme-chips { margin-top: 6px; }
40+.ext-license { margin: 6px 0 0; max-height: 180px; overflow: auto; white-space: pre-wrap; font-size: .68rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
41+.ext-license[hidden] { display: none; }
42+.ext-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
43+.ext-actions button { font-size: .74rem; padding: 5px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
44+.ext-actions .primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; color: #fff; }
45+.ext-actions .ghost { background: none; border: 1px solid var(--line); color: var(--muted); }
46+.ext-actions .ghost:hover:not(:disabled) { color: var(--fg); border-color: var(--accent2); }
47+.ext-actions button:disabled { cursor: default; opacity: .75; }
48+.ext-more { display: block; margin: 4px auto 10px; font-size: .76rem; }
49+@media (max-width: 560px) {
50+ .ext-row { flex-wrap: wrap; }
51+ .ext-actions { flex-direction: row; width: 100%; justify-content: flex-end; }
52+}
53+
54+/* selector de tema: como la paleta de comandos */
55+#ext-themepick { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 140; width: min(560px, calc(100vw - 32px)); background: var(--bg3); border: 1px solid var(--accent2); border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6); overflow: hidden; }
56+#ext-themepick input { width: 100%; background: var(--bg); border: none; border-bottom: 1px solid var(--line); color: var(--fg); padding: 11px 14px; font-size: .88rem; outline: none; }
57+#ext-themepick .tp-list { max-height: 55vh; overflow-y: auto; padding: 4px; }
58+#ext-themepick .tp-group { font-size: .64rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px 3px; }
59+#ext-themepick .tp-item { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: none; border: none; color: var(--fg); padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: .84rem; }
60+#ext-themepick .tp-item.sel, #ext-themepick .tp-item:hover { background: rgba(130,114,255,.2); }
61+#ext-themepick .tp-item .muted { font-size: .72rem; color: var(--muted); }
modified web/index.html +1 −0
@@ -96,6 +96,7 @@
9696 <button id="act-city" title="Ciudad 3D"></button>
9797 <button id="act-term" title="Terminal (Ctrl+`)"></button>
9898 <button id="act-skills" title="Skills"></button>
99+ <button id="act-ext" title="Extensiones"></button>
99100 <button id="act-settings" title="Ajustes y modelo"></button>
100101 <button id="act-mind" title="Mente de Elffuss — cerebro autónomo" aria-label="Mente de Elffuss"><img src="img/elffuss-code.svg" alt=""></button>
101102 </nav>
added web/js/ext/i18n.js +75 −0
@@ -0,0 +1,75 @@
1+// Textos del panel de extensiones (ES/EN). Van aparte de js/i18n.js para no
2+// tocar ese fichero; mismo idioma (uiLang) y misma sustitución {var}.
3+import { uiLang } from '../i18n.js';
4+
5+const L = {
6+ es: {
7+ title: 'Extensiones', sub: 'Open VSX',
8+ intro: 'Temas de color, gramáticas, snippets y ajustes de lenguaje de extensiones de VS Code. Aquí no se ejecuta el código de ninguna extensión, y tu proyecto no sale del navegador: a Open VSX solo va lo que buscas y lo que instalas.',
9+ paused: 'Extensiones en pausa en esta sesión (?noext): no se aplica ninguna. Puedes desactivarlas o desinstalarlas.',
10+ searchPh: 'Buscar extensiones en Open VSX…',
11+ catAll: 'Todo', catThemes: 'Temas', catSnippets: 'Snippets', catLangs: 'Lenguajes',
12+ vsix: 'Instalar .vsix…', themeBtn: 'Tema de color…',
13+ installedH: 'Instaladas ({n})', none: 'Ninguna todavía. Busca arriba o instala un .vsix.',
14+ popular: 'Populares', results: '{n} resultados', noResults: 'Sin resultados.', searching: 'Buscando…', more: 'Más resultados',
15+ install: 'Instalar', installing: 'Instalando…', downloading: 'Descargando… {pct}%', installedOk: 'Instalada ✓', update: 'Actualizar a {v}',
16+ enable: 'Activar', disable: 'Desactivar', disabled: 'desactivada', uninstall: 'Desinstalar', confirmUninstall: '¿Desinstalar «{name}»?',
17+ details: 'Detalles', loadingDetails: 'Leyendo el manifiesto…',
18+ applies: 'Aplica: {list}', ignores: 'No aplica: {list}', nothing: 'Nada de esta extensión se puede aplicar aquí.',
19+ needsCode: 'necesita su código', notYet: 'aún no',
20+ hasCode: 'Trae código (main/browser): no se ejecuta — haría falta un host de extensiones.',
21+ pack: 'Es un paquete de {n} extensiones: instálalas una a una.',
22+ themes: '{n} tema|{n} temas', grammars: '{n} gramática|{n} gramáticas', snippets: 'snippets ({langs})', languages: '{n} lenguaje|{n} lenguajes',
23+ license: 'Licencia: {l}', viewLicense: 'ver licencia', noLicense: 'sin licencia declarada',
24+ verified: 'suma SHA-256 comprobada', unverified: 'Open VSX no publica suma SHA-256', fromFile: 'desde fichero',
25+ downloads: '{n} descargas',
26+ bigConfirm: 'Esta extensión pesa {mb} MB. ¿Descargarla igualmente?',
27+ errNet: 'No pude hablar con Open VSX: {e}', errRate: 'Open VSX está limitando peticiones: espera un momento y reintenta.',
28+ errSha: 'La suma SHA-256 del paquete no coincide con la publicada: no se instala.',
29+ errNothing: 'Esta extensión no trae nada que se pueda aplicar aquí (temas, gramáticas, snippets o lenguajes).',
30+ errNotVsix: 'Eso no es un .vsix de VS Code.',
31+ err: 'No se pudo: {e}', cancelled: 'Cancelado.',
32+ installedMsg: '«{name}» instalada.', grammarSkipped: 'La gramática de {lang} no se aplica: Monaco conserva su coloreado de serie.',
33+ pickPh: 'Tema de color (↑↓ para previsualizar, Enter para elegir)', builtinGroup: 'Integrados',
34+ builtinDark: 'Oscuro (por defecto)', builtinLight: 'Claro', builtinHc: 'Alto contraste oscuro', builtinHcLight: 'Alto contraste claro',
35+ current: 'actual', palExt: 'Extensiones…', palTheme: 'Tema de color…',
36+ },
37+ en: {
38+ title: 'Extensions', sub: 'Open VSX',
39+ intro: 'Color themes, grammars, snippets and language settings from VS Code extensions. No extension code runs here, and your project never leaves the browser: Open VSX only sees what you search for and what you install.',
40+ paused: 'Extensions are paused for this session (?noext): none is applied. You can still disable or uninstall them.',
41+ searchPh: 'Search extensions on Open VSX…',
42+ catAll: 'All', catThemes: 'Themes', catSnippets: 'Snippets', catLangs: 'Languages',
43+ vsix: 'Install .vsix…', themeBtn: 'Color Theme…',
44+ installedH: 'Installed ({n})', none: 'None yet. Search above or install a .vsix.',
45+ popular: 'Popular', results: '{n} results', noResults: 'No results.', searching: 'Searching…', more: 'More results',
46+ install: 'Install', installing: 'Installing…', downloading: 'Downloading… {pct}%', installedOk: 'Installed ✓', update: 'Update to {v}',
47+ enable: 'Enable', disable: 'Disable', disabled: 'disabled', uninstall: 'Uninstall', confirmUninstall: 'Uninstall “{name}”?',
48+ details: 'Details', loadingDetails: 'Reading the manifest…',
49+ applies: 'Applies: {list}', ignores: 'Not applied: {list}', nothing: 'Nothing in this extension can be applied here.',
50+ needsCode: 'needs its code', notYet: 'not yet',
51+ hasCode: 'Ships code (main/browser): it does not run here — that needs an extension host.',
52+ pack: 'This is a pack of {n} extensions: install them one by one.',
53+ themes: '{n} theme|{n} themes', grammars: '{n} grammar|{n} grammars', snippets: 'snippets ({langs})', languages: '{n} language|{n} languages',
54+ license: 'Licence: {l}', viewLicense: 'view licence', noLicense: 'no licence declared',
55+ verified: 'SHA-256 checked', unverified: 'Open VSX publishes no SHA-256', fromFile: 'from file',
56+ downloads: '{n} downloads',
57+ bigConfirm: 'This extension is {mb} MB. Download it anyway?',
58+ errNet: 'Could not reach Open VSX: {e}', errRate: 'Open VSX is rate-limiting requests: wait a moment and retry.',
59+ errSha: 'The package SHA-256 does not match the published one: not installed.',
60+ errNothing: 'This extension brings nothing that can be applied here (themes, grammars, snippets or languages).',
61+ errNotVsix: 'That is not a VS Code .vsix.',
62+ err: 'Could not do it: {e}', cancelled: 'Cancelled.',
63+ installedMsg: '“{name}” installed.', grammarSkipped: 'The {lang} grammar is not applied: Monaco keeps its built-in highlighting.',
64+ pickPh: 'Color theme (↑↓ to preview, Enter to select)', builtinGroup: 'Built-in',
65+ builtinDark: 'Dark (default)', builtinLight: 'Light', builtinHc: 'Dark High Contrast', builtinHcLight: 'Light High Contrast',
66+ current: 'current', palExt: 'Extensions…', palTheme: 'Color Theme…',
67+ },
68+};
69+
70+export function tx(key, vars) {
71+ const tabla = L[uiLang()] || L.en;
72+ let s = tabla[key] ?? L.en[key] ?? key;
73+ if (s.includes('|') && vars && 'n' in vars) s = s.split('|')[Number(vars.n) === 1 ? 0 : 1];
74+ return vars ? s.replace(/\{(\w+)\}/g, (_, k) => (vars[k] ?? '')) : s;
75+}
added web/js/ext/panel.js +402 −0
@@ -0,0 +1,402 @@
1+// Panel de extensiones: buscar en Open VSX, ver qué aplicaría cada una,
2+// instalar (o un .vsix suelto), activar/desactivar, desinstalar, licencia, y
3+// el selector de tema de color. Mismo patrón que el panel de Skills: se pinta
4+// dentro de #settings-panel. Todo texto que viene de una extensión entra con
5+// textContent, nunca como HTML.
6+import { tx } from './i18n.js';
7+
8+const $ = id => document.getElementById(id);
9+const el = (tag, cls, txt) => { const e = document.createElement(tag); if (cls) e.className = cls; if (txt != null) e.textContent = txt; return e; };
10+const CATS = [['', 'catAll'], ['Themes', 'catThemes'], ['Snippets', 'catSnippets'], ['Programming Languages', 'catLangs']];
11+
12+let host = null;
13+let cssPuesto = false;
14+const estado = { q: '', cat: null, items: [], total: 0, cargando: false, msg: null, ctl: null };
15+let temporizador = null;
16+let desuscribe = null;
17+
18+function ponCss() {
19+ if (cssPuesto) return;
20+ cssPuesto = true;
21+ const l = document.createElement('link');
22+ l.rel = 'stylesheet';
23+ l.href = new URL('../../css/ext.css', import.meta.url).href;
24+ document.head.appendChild(l);
25+}
26+
27+export function open(h, { themes = false } = {}) {
28+ host = h;
29+ ponCss();
30+ desuscribe?.();
31+ desuscribe = h.onChange(() => { if ($('ext-panel')?.isConnected) pintaInstaladas(); });
32+ if (themes) return openThemePicker(h);
33+ estado.msg = null; // un aviso viejo no se repite al volver a abrir
34+ pinta();
35+}
36+
37+// ── mensajes de error legibles ──
38+function textoError(e) {
39+ if (e?.code === 'rate') return tx('errRate');
40+ if (e?.code === 'net') return tx('errNet', { e: e.message });
41+ if (e?.code === 'sha') return tx('errSha');
42+ if (e?.code === 'nothing') return tx('errNothing');
43+ if (e?.code === 'notvsix') return tx('errNotVsix');
44+ if (e?.code === 'cancel' || e?.name === 'AbortError') return tx('cancelled');
45+ return tx('err', { e: e?.message || String(e) });
46+}
47+function aviso(texto, error = false) {
48+ estado.msg = texto ? { texto, error } : null;
49+ const m = $('ext-msg');
50+ if (!m) return;
51+ m.textContent = texto || '';
52+ m.hidden = !texto;
53+ m.classList.toggle('err', !!error);
54+}
55+
56+// «Aplica: 2 temas · No aplica: commands (necesita su código)»
57+function lineasResumen({ themes = 0, grammars = 0, languages = 0, snippetLangs = [], ignored = [], hasCode = false, pack = [] }) {
58+ const aplica = [];
59+ if (themes) aplica.push(tx('themes', { n: themes }));
60+ if (grammars) aplica.push(tx('grammars', { n: grammars }));
61+ if (languages) aplica.push(tx('languages', { n: languages }));
62+ if (snippetLangs.length) aplica.push(tx('snippets', { langs: snippetLangs.slice(0, 6).join(', ') + (snippetLangs.length > 6 ? '…' : '') }));
63+ const porMotivo = { code: [], later: [] };
64+ for (const i of ignored) (porMotivo[i.why] || porMotivo.later).push(i.key);
65+ const no = [];
66+ if (porMotivo.code.length) no.push(`${porMotivo.code.join(', ')} (${tx('needsCode')})`);
67+ if (porMotivo.later.length) no.push(`${porMotivo.later.join(', ')} (${tx('notYet')})`);
68+ const out = [];
69+ out.push(aplica.length ? { cls: 'ext-applies', t: tx('applies', { list: aplica.join(' · ') }) } : { cls: 'ext-nothing', t: tx('nothing') });
70+ if (no.length) out.push({ cls: 'ext-ignored', t: tx('ignores', { list: no.join(' · ') }) });
71+ if (hasCode) out.push({ cls: 'ext-ignored', t: tx('hasCode') });
72+ if (pack.length) out.push({ cls: 'ext-ignored', t: tx('pack', { n: pack.length }) });
73+ return out;
74+}
75+
76+// ── panel ──
77+function pinta() {
78+ const box = $('settings-panel');
79+ box.hidden = false;
80+ box.replaceChildren();
81+ const cerrar = el('button', null, '✕');
82+ cerrar.id = 'settings-close';
83+ cerrar.onclick = () => { box.hidden = true; };
84+ const wrap = el('div', 'ext-panel');
85+ wrap.id = 'ext-panel';
86+ const h3 = el('h3', null, tx('title') + ' ');
87+ h3.appendChild(el('span', 'muted', '· ' + tx('sub')));
88+ wrap.append(h3, el('p', 'muted ext-intro', tx('intro')));
89+ if (host.paused) wrap.appendChild(el('p', 'ext-paused', tx('paused')));
90+
91+ const barra = el('div', 'ext-toolbar');
92+ const fichero = el('input');
93+ fichero.type = 'file';
94+ fichero.accept = '.vsix,application/zip,application/vsix';
95+ fichero.hidden = true;
96+ fichero.id = 'ext-file';
97+ fichero.onchange = async () => {
98+ const f = fichero.files?.[0];
99+ fichero.value = '';
100+ if (f) await instala(f, null);
101+ };
102+ const bVsix = el('button', 'ghost', tx('vsix'));
103+ bVsix.id = 'ext-install-vsix';
104+ bVsix.onclick = () => fichero.click();
105+ const bTema = el('button', 'ghost', tx('themeBtn'));
106+ bTema.id = 'ext-theme-btn';
107+ bTema.onclick = () => openThemePicker(host);
108+ barra.append(bVsix, bTema, fichero);
109+ wrap.appendChild(barra);
110+
111+ const busca = el('div', 'ext-search');
112+ const inp = el('input');
113+ inp.id = 'ext-q';
114+ inp.type = 'search';
115+ inp.placeholder = tx('searchPh');
116+ inp.autocomplete = 'off';
117+ inp.spellcheck = false;
118+ inp.value = estado.q;
119+ inp.oninput = () => { estado.q = inp.value.trim(); clearTimeout(temporizador); temporizador = setTimeout(() => busca_(), 350); };
120+ inp.onkeydown = e => { if (e.key === 'Enter') { clearTimeout(temporizador); busca_(); } };
121+ const chips = el('div', 'ext-chips');
122+ for (const [cat, key] of CATS) {
123+ const c = el('button', 'ext-chip' + (estado.cat === cat ? ' on' : ''), tx(key));
124+ c.dataset.cat = cat;
125+ c.onclick = () => { estado.cat = estado.cat === cat && cat ? '' : cat; busca_(); };
126+ chips.appendChild(c);
127+ }
128+ busca.append(inp, chips);
129+ wrap.appendChild(busca);
130+
131+ const msg = el('div', 'ext-msg');
132+ msg.id = 'ext-msg';
133+ msg.hidden = true;
134+ wrap.appendChild(msg);
135+ const res = el('div', 'ext-results');
136+ res.id = 'ext-results';
137+ wrap.appendChild(res);
138+ const inst = el('div', 'ext-installed');
139+ inst.id = 'ext-installed';
140+ wrap.appendChild(inst);
141+ box.append(cerrar, wrap);
142+
143+ if (estado.msg) aviso(estado.msg.texto, estado.msg.error);
144+ pintaResultados();
145+ pintaInstaladas();
146+ inp.focus();
147+}
148+
149+async function busca_({ mas = false } = {}) {
150+ estado.ctl?.abort();
151+ const ctl = new AbortController();
152+ estado.ctl = ctl;
153+ const ovsx = await import('./openvsx.js');
154+ if (!estado.q && estado.cat == null) { estado.items = []; estado.total = 0; pintaResultados(); return; }
155+ estado.cargando = true;
156+ if (!mas) { estado.items = []; estado.total = 0; }
157+ aviso(null);
158+ pintaResultados();
159+ document.querySelectorAll('.ext-chip').forEach(c => c.classList.toggle('on', c.dataset.cat === (estado.cat || '') && estado.cat != null));
160+ try {
161+ const r = await ovsx.search(estado.q, { category: estado.cat || '', offset: mas ? estado.items.length : 0, size: 20, signal: ctl.signal });
162+ if (estado.ctl !== ctl) return;
163+ estado.items = mas ? estado.items.concat(r.items) : r.items;
164+ estado.total = r.total;
165+ } catch (e) {
166+ if (e.name === 'AbortError') return;
167+ aviso(textoError(e), true);
168+ } finally {
169+ if (estado.ctl === ctl) { estado.cargando = false; pintaResultados(); }
170+ }
171+}
172+
173+function pintaResultados() {
174+ const res = $('ext-results');
175+ if (!res) return;
176+ res.replaceChildren();
177+ if (estado.cargando && !estado.items.length) { res.appendChild(el('div', 'muted ext-hint', tx('searching'))); return; }
178+ if (!estado.items.length) {
179+ if (estado.q || estado.cat != null) res.appendChild(el('div', 'muted ext-hint', estado.cargando ? tx('searching') : tx('noResults')));
180+ return;
181+ }
182+ res.appendChild(el('div', 'sk-h', estado.q ? tx('results', { n: estado.total }) : tx('popular')));
183+ const instaladas = new Map(host.list().map(e => [e.id, e]));
184+ for (const it of estado.items) res.appendChild(filaResultado(it, instaladas.get(`${it.namespace}.${it.name}`.toLowerCase())));
185+ if (estado.items.length < estado.total) {
186+ const mas = el('button', 'ghost ext-more', tx('more'));
187+ mas.onclick = () => busca_({ mas: true });
188+ res.appendChild(mas);
189+ }
190+}
191+
192+function icono(url, nombre) {
193+ if (url) {
194+ const img = el('img', 'ext-ico');
195+ img.alt = '';
196+ img.loading = 'lazy';
197+ img.referrerPolicy = 'no-referrer';
198+ img.src = url;
199+ img.onerror = () => img.replaceWith(icono(null, nombre));
200+ return img;
201+ }
202+ return el('div', 'ext-ico ext-ico-letra', (nombre || '?').trim().charAt(0).toUpperCase());
203+}
204+
205+function filaResultado(it, instalada) {
206+ const row = el('div', 'ext-row');
207+ row.dataset.id = `${it.namespace}.${it.name}`;
208+ const main = el('div', 'ext-main');
209+ const t = el('div', 'ext-title');
210+ t.append(el('b', null, it.displayName), el('span', 'muted', ` ${it.namespace} · v${it.version}`));
211+ if (it.verified) t.appendChild(el('span', 'ext-badge', '✓'));
212+ main.append(t, el('div', 'ext-desc', it.description));
213+ main.appendChild(el('div', 'ext-meta muted', tx('downloads', { n: it.downloadCount.toLocaleString() })));
214+ const det = el('div', 'ext-detail');
215+ det.hidden = true;
216+ main.appendChild(det);
217+ main.onclick = () => detalle(it, det);
218+ main.title = tx('details');
219+
220+ const acc = el('div', 'ext-actions');
221+ const b = el('button', 'primary ext-install');
222+ if (instalada && instalada.version === it.version) { b.textContent = tx('installedOk'); b.className = 'ghost ext-install'; b.disabled = true; }
223+ else b.textContent = instalada ? tx('update', { v: it.version }) : tx('install');
224+ b.onclick = e => { e.stopPropagation(); instala(it, b); };
225+ acc.appendChild(b);
226+ row.append(icono(it.icon, it.displayName), main, acc);
227+ return row;
228+}
229+
230+async function detalle(it, det) {
231+ if (!det.hidden) { det.hidden = true; return; }
232+ det.hidden = false;
233+ if (det.dataset.listo) return;
234+ det.replaceChildren(el('div', 'muted', tx('loadingDetails')));
235+ try {
236+ const ovsx = await import('./openvsx.js');
237+ const { analyzeManifest } = await import('./vsix.js');
238+ const meta = await ovsx.metadata(it.namespace, it.name, it.version);
239+ const a = analyzeManifest(await ovsx.manifest(meta));
240+ det.replaceChildren();
241+ for (const l of lineasResumen({ ...a.applies, snippetLangs: a.snippetLangs, ignored: a.ignored, hasCode: a.hasCode, pack: a.pack })) det.appendChild(el('div', l.cls, l.t));
242+ const lic = el('div', 'ext-meta muted', tx('license', { l: meta.license || tx('noLicense') }) + ' ');
243+ if (meta.files.license) {
244+ const a2 = el('a', null, tx('viewLicense'));
245+ a2.href = meta.files.license;
246+ a2.target = '_blank';
247+ a2.rel = 'noopener noreferrer';
248+ lic.appendChild(a2);
249+ }
250+ det.appendChild(lic);
251+ det.dataset.listo = '1';
252+ // nada aplicable: instalarla solo daría un error, mejor decirlo en el botón
253+ const boton = det.closest('.ext-row')?.querySelector('.ext-install');
254+ if (!a.any && boton && !boton.disabled) { boton.disabled = true; boton.title = tx('nothing'); boton.className = 'ghost ext-install'; }
255+ } catch (e) { det.replaceChildren(el('div', 'ext-ignored', textoError(e))); }
256+}
257+
258+async function instala(src, boton) {
259+ const nombre = src instanceof Blob ? src.name : src.displayName;
260+ const original = boton?.textContent;
261+ if (boton) { boton.disabled = true; boton.textContent = tx('installing'); }
262+ aviso(null);
263+ try {
264+ const rec = await host.install(src instanceof Blob ? src : { namespace: src.namespace, name: src.name, version: src.version }, {
265+ onProgress: (n, total) => { if (boton && total) boton.textContent = tx('downloading', { pct: Math.round(n / total * 100) }); },
266+ confirmLarge: async mb => confirm(tx('bigConfirm', { mb })),
267+ });
268+ if (boton) { boton.textContent = tx('installedOk'); boton.className = 'ghost ext-install'; }
269+ aviso(tx('installedMsg', { name: rec.displayName || nombre }));
270+ } catch (e) {
271+ if (boton) { boton.disabled = false; boton.textContent = original; }
272+ aviso(textoError(e), true);
273+ }
274+}
275+
276+function pintaInstaladas() {
277+ const box = $('ext-installed');
278+ if (!box) return;
279+ const lista = host.list();
280+ box.replaceChildren(el('div', 'sk-h', tx('installedH', { n: lista.length })));
281+ if (!lista.length) { box.appendChild(el('p', 'muted ext-hint', tx('none'))); return; }
282+ const saltadas = host.skippedGrammars();
283+ for (const e of lista.slice().reverse()) {
284+ const row = el('div', 'ext-row installed' + (e.enabled ? '' : ' off'));
285+ row.dataset.id = e.id;
286+ const main = el('div', 'ext-main');
287+ const t = el('div', 'ext-title');
288+ t.append(el('b', null, e.displayName), el('span', 'muted', ` ${e.id} · v${e.version}${e.enabled ? '' : ' · ' + tx('disabled')}`));
289+ main.append(t);
290+ if (e.description) main.appendChild(el('div', 'ext-desc', e.description));
291+ const langsSnip = [...new Set((e.snippets || []).map(s => s.language))];
292+ for (const l of lineasResumen({ themes: e.themes?.length, grammars: e.grammars?.length, languages: e.languages?.length, snippetLangs: langsSnip, ignored: e.ignored || [], hasCode: e.hasCode, pack: e.pack || [] })) main.appendChild(el('div', l.cls, l.t));
293+ for (const g of saltadas.filter(g => g.ext === e.id)) main.appendChild(el('div', 'ext-ignored', tx('grammarSkipped', { lang: g.language })));
294+ if (e.enabled && e.themes?.length) {
295+ const chips = el('div', 'ext-chips ext-theme-chips');
296+ for (const th of e.themes) {
297+ const c = el('button', 'ext-chip' + (host.currentTheme() === th.themeId ? ' on' : ''), '◐ ' + th.label);
298+ c.dataset.theme = th.themeId;
299+ c.onclick = async () => { await host.setTheme(th.themeId); pintaInstaladas(); };
300+ chips.appendChild(c);
301+ }
302+ main.appendChild(chips);
303+ }
304+ const meta = el('div', 'ext-meta muted', tx('license', { l: e.license || tx('noLicense') }) + ' · ' + (e.source === 'file' ? tx('fromFile') : e.verified ? tx('verified') : tx('unverified')) + ' ');
305+ if (e.licenseKey) {
306+ const ver = el('a', null, tx('viewLicense'));
307+ ver.href = '#';
308+ const pre = el('pre', 'ext-license');
309+ pre.hidden = true;
310+ ver.onclick = async ev => {
311+ ev.preventDefault();
312+ if (pre.hidden && !pre.textContent) pre.textContent = await host.licenseText(e.id);
313+ pre.hidden = !pre.hidden;
314+ };
315+ meta.appendChild(ver);
316+ main.append(meta, pre);
317+ } else main.appendChild(meta);
318+
319+ const acc = el('div', 'ext-actions');
320+ const bOn = el('button', 'ghost ext-toggle', e.enabled ? tx('disable') : tx('enable'));
321+ bOn.onclick = async () => { bOn.disabled = true; try { await host.setEnabled(e.id, !e.enabled); } catch (err) { aviso(textoError(err), true); } pintaInstaladas(); };
322+ const bDel = el('button', 'ghost ext-uninstall', tx('uninstall'));
323+ bDel.onclick = async () => {
324+ if (!confirm(tx('confirmUninstall', { name: e.displayName }))) return;
325+ bDel.disabled = true;
326+ try { await host.uninstall(e.id); } catch (err) { aviso(textoError(err), true); }
327+ pintaInstaladas();
328+ pintaResultados();
329+ };
330+ acc.append(bOn, bDel);
331+ row.append(icono(null, e.displayName), main, acc);
332+ box.appendChild(row);
333+ }
334+}
335+
336+// ── selector de tema (estilo «Color Theme» de VS Code) ──
337+export function openThemePicker(h) {
338+ host = h;
339+ ponCss();
340+ $('ext-themepick')?.remove();
341+ const original = h.currentTheme();
342+ const caja = el('div');
343+ caja.id = 'ext-themepick';
344+ const inp = el('input');
345+ inp.placeholder = tx('pickPh');
346+ inp.autocomplete = 'off';
347+ inp.spellcheck = false;
348+ const lista = el('div', 'tp-list');
349+ caja.append(inp, lista);
350+ document.body.appendChild(caja);
351+
352+ let items = [], sel = 0, cerrado = false;
353+ const etiqueta = t => (t.builtin ? tx(t.labelKey) : t.label);
354+ const cerrar = async aplicar => {
355+ if (cerrado) return;
356+ cerrado = true;
357+ document.removeEventListener('mousedown', fuera, true);
358+ caja.remove();
359+ if (aplicar) await h.setTheme(aplicar);
360+ else await h.previewTheme(original);
361+ if ($('ext-panel')?.isConnected) pintaInstaladas();
362+ };
363+ const fuera = e => { if (!caja.contains(e.target)) cerrar(null); };
364+ setTimeout(() => document.addEventListener('mousedown', fuera, true), 0);
365+
366+ function pintaLista() {
367+ const q = inp.value.trim().toLowerCase();
368+ const todos = h.themes();
369+ items = todos.filter(t => !q || (etiqueta(t) + ' ' + (t.extName || '')).toLowerCase().includes(q));
370+ lista.replaceChildren();
371+ let grupo = null;
372+ items.forEach((t, i) => {
373+ const g = t.builtin ? tx('builtinGroup') : t.extName;
374+ if (g !== grupo) { grupo = g; lista.appendChild(el('div', 'tp-group', g)); }
375+ const row = el('button', 'tp-item' + (i === sel ? ' sel' : ''));
376+ row.dataset.theme = t.id;
377+ row.append(el('span', null, etiqueta(t)));
378+ if (t.id === original) row.appendChild(el('span', 'muted', tx('current')));
379+ row.onclick = () => cerrar(t.id);
380+ lista.appendChild(row);
381+ });
382+ }
383+ const marca = () => {
384+ lista.querySelectorAll('.tp-item').forEach((r, i) => r.classList.toggle('sel', i === sel));
385+ lista.querySelectorAll('.tp-item')[sel]?.scrollIntoView({ block: 'nearest' });
386+ };
387+ inp.oninput = () => { sel = 0; pintaLista(); };
388+ inp.onkeydown = e => {
389+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
390+ e.preventDefault();
391+ if (!items.length) return;
392+ sel = (sel + (e.key === 'ArrowDown' ? 1 : -1) + items.length) % items.length;
393+ marca();
394+ h.previewTheme(items[sel].id);
395+ } else if (e.key === 'Enter') { e.preventDefault(); if (items[sel]) cerrar(items[sel].id); }
396+ else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); cerrar(null); }
397+ };
398+ pintaLista();
399+ sel = Math.max(0, items.findIndex(t => t.id === original));
400+ marca();
401+ inp.focus();
402+}
modified web/js/icons.js +2 −0
@@ -64,4 +64,6 @@
6464 <circle cx="12" cy="12" r="3"/><path d="M12 3v2.5M12 18.5V21M3 12h2.5M18.5 12H21M5.6 5.6l1.8 1.8M16.6 16.6l1.8 1.8M18.4 5.6l-1.8 1.8M7.4 16.6l-1.8 1.8"/></svg>`,
6565 chat: `<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6">
6666 <path d="M4 5h16v11H9l-5 4z"/></svg>`,
67+ extensions: `<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round">
68+ <path d="M3.5 9.5h6v6h-6zM3.5 15.5h6v6h-6zM9.5 15.5h6v6h-6z"/><path d="M14.2 6.2l4.3-4.3 4.3 4.3-4.3 4.3z"/></svg>`,
6769 };
modified web/js/main.js +20 −3
@@ -4,7 +4,7 @@
44 import * as codeTools from './tools/code.js';
55 import * as db from './db.js';
66 import * as settings from './settings.js';
7-import { initEditor, refreshTree, openFile, gotoLine, triggerEditor, hasEditor, saveActive, activeFile, focusEditor } from './ide.js';
7+import { initEditor, refreshTree, openFile, gotoLine, triggerEditor, hasEditor, saveActive, activeFile, focusEditor, loadExt } from './ide.js';
88 import { ACTIVITY, UI } from './icons.js';
99 import { renderMarkdown } from './md.js';
1010 import * as skills from './skills.js';
@@ -16,7 +16,7 @@
1616 import * as mind from './mind.js';
1717 import { buildCityAdapter, loadThoughtsAdapter } from './mind-adapter.js';
1818 import { humanizeStreamPreview } from './humanize.js';
19-import { t, applyI18n } from './i18n.js';
19+import { t, applyI18n, uiLang } from './i18n.js';
2020 import * as bridge from './bridge.js';
2121 import * as conv from './conversations.js';
2222 import { TASK_PREFIX } from './goal.js';
@@ -32,7 +32,10 @@
3232 { id: 'skills', label: 'Skills', icon: '🧩', kind: 'idb-key', store: 'kv', key: 'skills',
3333 files: { ext: '.md', name: s => s.name, body: s => `---\nname: ${s.name}\ndescription: ${s.description || ''}\n---\n\n${s.content || ''}` } },
3434 { id: 'prefs', label: 'Preferencias', icon: '⚙️', kind: 'ls',
35- keys: ['elffusscode.model', 'elffusscode.autoedit', 'elffusscode.goalmode', 'elffuss.acer', 'elffuss.resumen', 'elffuss.semantic'] },
35+ keys: ['elffusscode.model', 'elffusscode.autoedit', 'elffusscode.goalmode', 'elffuss.acer', 'elffuss.resumen', 'elffuss.semantic', 'elffusscode.theme'] },
36+ // extensiones de VS Code instaladas: solo la lista (id, versión, activa);
37+ // los paquetes viven en su propia base (js/ext/store.js)
38+ { id: 'extensions', label: 'Extensiones', icon: '🧱', kind: 'idb-key', store: 'kv', key: 'extensions' },
3639 ],
3740 });
3841 workspace.restore().catch(() => {});
@@ -2495,6 +2498,8 @@
24952498 { label: t('pToggleTerm'), hint: 'Ctrl+`', run: () => { closePalette(); toggleTerminal(); } },
24962499 { label: t('pSave', { k: atajo('S') }), run: () => saveActive() },
24972500 { label: t('mLab'), run: () => abrirLab() },
2501+ { label: extTexto('Extensiones…', 'Extensions…'), run: () => { closePalette(); openExtensions(); } },
2502+ { label: extTexto('Tema de color…', 'Color Theme…'), run: () => { closePalette(); openExtensions({ themes: true }); } },
24982503 ];
24992504 // El banco de pruebas (lab.html) existía pero no había forma de llegar a él
25002505 // desde el IDE: solo escribiendo la URL. Se abre en otra pestaña para no
@@ -2791,6 +2796,18 @@
27912796 $('act-skills').innerHTML = UI.puzzle;
27922797 $('act-skills').addEventListener('click', () => openSkillsPanel());
27932798
2799+// Extensiones de VS Code (temas, gramáticas, snippets, lenguajes): js/ext/.
2800+// Nada de eso se carga hasta que se usa; el panel y el host llegan al pulsar.
2801+function extTexto(es, en) { return uiLang() === 'es' ? es : en; }
2802+async function openExtensions(opts = {}) {
2803+ const host = await loadExt();
2804+ if (!host) { $('statusbar').textContent = t('openProjFirst'); return; }
2805+ (await import('./ext/panel.js')).open(host, opts);
2806+}
2807+$('act-ext').innerHTML = ACTIVITY.extensions;
2808+$('act-ext').title = extTexto('Extensiones (temas, gramáticas, snippets)', 'Extensions (themes, grammars, snippets)');
2809+$('act-ext').addEventListener('click', () => openExtensions());
2810+
27942811 rebuildSelect();
27952812 skills.initSkills();
27962813 boot();