Elffuss BraidHub

utopia-ia/elffuss-code public

Extensions: verdict for per-platform builds and code-free packs

Search results published per platform (debugpy, Pyrefly, Ruff...) keep
their package.json under /<platform>/<version>/, so the one request per
row got a 404 and those rows showed no verdict at all. The platform now
comes from the result's download URL.

An extension with no code no longer "partly works" because of the
categories it tags itself with (a snippet pack labelled Machine Learning):
categories describe what code would do, and there is none.

The facts the verdict is built from move to verdict.js with an explicit
host, so the panel, the tests and the popular-list generator share them.
Changeset03f5ed99c36d0505b5400e0030f7477792b29ccbcf46aecd51a69beb1250eb84
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-12 12:17 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-12 12:17 +02:00
Parentsd66451cc104e

Browse the files at this changeset

2 files changed

modified web/js/ext/openvsx.js +11 −2
@@ -29,8 +29,17 @@
2929 }
3030 const seg = s => encodeURIComponent(String(s));
3131
32+// «…/api/ns/name/<plataforma>/<versión>/file/x.vsix» → la plataforma, o ''
33+// (las publicadas por plataforma no tienen package.json en la ruta sin ella)
34+function plataformaDe(download) {
35+ try {
36+ const p = new URL(download).pathname.split('/').filter(Boolean);
37+ return p[0] === 'api' && p.length === 7 && p[5] === 'file' && /^[a-z0-9-]+$/.test(p[3]) ? p[3] : '';
38+ } catch { return ''; }
39+}
3240 const resumen = e => ({
3341 namespace: String(e.namespace || ''), name: String(e.name || ''), version: String(e.version || ''),
42+ platform: plataformaDe(e.files?.download),
3443 displayName: String(e.displayName || e.name || ''), description: String(e.description || ''),
3544 downloadCount: Number(e.downloadCount) || 0, verified: !!e.verified, deprecated: !!e.deprecated,
3645 icon: (() => { try { const u = new URL(e.files?.icon); return ORIGENES_ICONO.has(u.origin) ? u.href : null; } catch { return null; } })(),
@@ -64,8 +73,8 @@
6473
6574 // El package.json de un resultado de búsqueda, sin pedir antes sus metadatos:
6675 // una sola petición por fila para decir qué haría antes de instalarla.
67-export function manifestOf({ namespace, name, version }, { signal } = {}) {
68- return getJson(`${BASE}/api/${seg(namespace)}/${seg(name)}/${seg(version)}/file/package.json`, signal);
76+export function manifestOf({ namespace, name, version, platform = '' }, { signal } = {}) {
77+ return getJson(`${BASE}/api/${seg(namespace)}/${seg(name)}/${platform ? seg(platform) + '/' : ''}${seg(version)}/file/package.json`, signal);
6978 }
7079
7180 export async function text(url, { signal, max = 200_000 } = {}) {
modified web/js/ext/verdict.js +65 −1
@@ -48,7 +48,9 @@
4848 // Funciones que no funcionan, en llano y sin repetir.
4949 export function missingFeatures(f) {
5050 const claves = [];
51- for (const c of f.categories || []) if (POR_CATEGORIA[c]) claves.push(POR_CATEGORIA[c]);
51+ // las categorías hablan de lo que hace su código: sin código no falta nada
52+ // (un paquete de snippets que se etiqueta «Machine Learning» no deja de funcionar)
53+ if (f.hasCode) for (const c of f.categories || []) if (POR_CATEGORIA[c]) claves.push(POR_CATEGORIA[c]);
5254 const principales = [...new Set(claves)];
5355 for (const i of f.ignored || []) {
5456 const k = Object.hasOwn(POR_CLAVE, i.key) ? POR_CLAVE[i.key] : 'fOther';
@@ -64,6 +66,68 @@
6466 return lista((principales.length ? principales : concretas.length ? concretas : [tx('fOwn')]).slice(0, 3));
6567 }
6668
69+// ── de un package.json analizado (vsix.js analyzeManifest) o de un registro
70+// instalado a los «hechos» de arriba. `h` es el host de extensiones (host.js)
71+// o algo con la misma forma: builtinLanguage, grammarSkippedFor, languageName,
72+// languageExtensions. Así el panel, las pruebas y el generador de la lista de
73+// populares (tests/ext_popular_build.mjs) dicen lo mismo.
74+const BONITOS = {
75+ javascript: 'JavaScript', typescript: 'TypeScript', javascriptreact: 'JavaScript React', typescriptreact: 'TypeScript React',
76+ html: 'HTML', css: 'CSS', scss: 'SCSS', less: 'Less', json: 'JSON', jsonc: 'JSON', vue: 'Vue', python: 'Python', markdown: 'Markdown',
77+ shellscript: 'Shell', go: 'Go', rust: 'Rust', java: 'Java', php: 'PHP', ruby: 'Ruby', csharp: 'C#', cpp: 'C++', c: 'C', yaml: 'YAML',
78+};
79+export function languageName(h, id, langs = []) {
80+ return langs.find(l => l.id === id && esTexto(l.name))?.name || h?.languageName?.(id) || BONITOS[id] || id;
81+}
82+export function languageExts(h, id, langs = []) {
83+ const propias = langs.filter(l => l.id === id).flatMap(l => l.extensions || []);
84+ return [...new Set(propias.length ? propias : h?.languageExtensions?.(id) || [])];
85+}
86+function facts(h, base, { themes = [], grammarLangs = [], langs = [], snippets = [] }) {
87+ const salta = l => !!h?.grammarSkippedFor?.(l);
88+ const deSerie = id => !!h?.builtinLanguage?.(id);
89+ const conGram = [...new Set(grammarLangs.filter(l => l && !salta(l)))];
90+ // snippets de un lenguaje que Code no tiene (javascriptreact, vue…) no
91+ // saldrían nunca: ni se cuentan ni se prometen. Y un mismo fichero que sirve
92+ // a varios lenguajes se cuenta una vez.
93+ const existe = id => langs.some(l => l.id === id) || !!h?.languageName?.(id) || deSerie(id);
94+ const porLang = new Map();
95+ const vistos = new Set();
96+ for (const s of snippets.filter(x => existe(x.language))) {
97+ const n = !Number.isFinite(s.count) ? NaN : s.key && vistos.has(s.key) ? 0 : s.count;
98+ if (s.key) vistos.add(s.key);
99+ porLang.set(s.language, (porLang.has(s.language) ? porLang.get(s.language) : 0) + n);
100+ }
101+ return {
102+ ...base, themes,
103+ highlight: conGram.map(id => ({ id, name: languageName(h, id, langs), exts: languageExts(h, id, langs) })),
104+ settingsOnly: langs.filter(l => l.config && !deSerie(l.id) && !conGram.includes(l.id)).map(l => languageName(h, l.id, langs)),
105+ keepsBuiltin: [...new Set(grammarLangs.filter(l => l && salta(l)))].map(id => languageName(h, id, langs)),
106+ snippets: [...porLang].map(([id, n]) => ({ id, name: languageName(h, id, langs), count: Number.isFinite(n) ? n : null })),
107+ };
108+}
109+export function factsFromManifest(h, a) {
110+ return facts(h, { hasCode: a.hasCode, browserEntry: a.browserEntry, categories: a.categories || [], sizes: a.sizes || {}, webviews: a.webviews, ignored: a.ignored || [], pack: a.pack || [] }, {
111+ themes: a.themeLabels || [], grammarLangs: a.grammarLangs || [], langs: a.languageList || [],
112+ snippets: (a.snippetLangs || []).map(language => ({ language, count: null })),
113+ });
114+}
115+export function factsFromRecord(h, e) {
116+ // registros de antes de guardar categorías: se asume que lo que se aplica es lo principal
117+ const categories = e.categories || ['Programming Languages'];
118+ return facts(h, { hasCode: e.hasCode, browserEntry: !!e.browserEntry, categories, sizes: e.sizes || {}, webviews: e.webviews, ignored: e.ignored || [], pack: e.pack || [] }, {
119+ themes: (e.themes || []).map(t => t.label), grammarLangs: (e.grammars || []).map(g => g.language ?? null),
120+ langs: (e.languages || []).map(l => ({ id: l.id, name: l.aliases?.[0], extensions: l.extensions || [], config: !!l.configKey })),
121+ snippets: (e.snippets || []).map(s => ({ language: s.language, key: s.key, count: Number.isFinite(s.count) ? s.count : null })),
122+ });
123+}
124+
125+// ¿Hace algo al instalarla? Lo que decide el filtro «Solo las que funcionan en
126+// Code» del panel: entera o en parte (lo principal funciona). Las que solo
127+// funcionarían por su código, o en las que lo principal es su código y solo
128+// quedaría un resto (unos snippets de una extensión de depurar), no.
129+export const works = v => v.kind === 'full' || v.kind === 'partial';
130+
67131 export function describe(f) {
68132 const partes = []; // { tipo, texto }
69133 const themes = f.themes || [], highlight = f.highlight || [], settingsOnly = f.settingsOnly || [], snippets = f.snippets || [];