Elffuss BraidHub

utopia-ia/elffuss-code public

Read the whole Open VSX catalog once and give exact counts

The README gave a catalog size typed by hand (19,335, while every other
place implied 19,320) and an extrapolation from a 2,000-manifest sample
whose data and sampling were not in the repository. catalog_census.mjs
now read every extension the Open VSX search lists on 2026-10-11:
19,338 listed (the size when the listing ended), 19,337 package.json
read, one publishes none; about 20,000 requests at most 2.5 a second;
nothing downloaded as a .vsix, installed or run.

- Listing: by downloads from both ends (the search stops at 10,000), and
  always completed by a pass sorted by date, which found 11 extensions
  the download order did not return (ties in the order, and extensions
  published while it was being read).
- Platform-specific extensions: the web build of the listed version if it
  has one (as the runtime census does), else the listed platform build;
  an older web build is not what an install gets.
- Raw manifests stay in tests/.cache/catalog/ (resumable; --recount
  classifies again without the network). Classification is the panel's,
  with Monaco's built-in languages and the runtime census.
- tests/catalog-census/summary.json has the counts and the date;
  extensions.tsv one line per extension. x2_unit recomputes every count
  from the lines, and checks the top 500's 89 with a browser entry are
  the runtime census's 89.

Counts: browser entry 893 (4.6%), of which 849 could run in the sandbox;
Node only 15,729 (81.3%); no code 2,715; something applies without code
5,610; works in Code either way 6,152 (31.8%), 542 only through its code;
nothing works 13,185. Only the top 500's 89 have been run.

Changeseta234cd1861f12986fa3ae9bcd8bda9a30f18e644556c1bed61b2e32551c98d67
AuthorKikoCis <kikocisneros@gmail.com> · 2026-10-11 23:18 +02:00
CommitterKikoCis <kikocisneros@gmail.com> · 2026-10-12 09:38 +02:00
Parents5bf78e316b3c

Browse the files at this changeset

6 files changed

modified README.md +30 −8
@@ -167,7 +167,7 @@
167167 bytes against the committed `web/js/ext2/vendor-manifest.json`. It is built by a
168168 pinned, reproducible script and deployed separately; see
169169 [`vendor/vscode-ext2/README.md`](vendor/vscode-ext2/README.md).
170-- **What doesn't work:** Node-only extensions (most of the catalog), anything that needs
170+- **What doesn't work:** Node-only extensions (81% of the catalog), anything that needs
171171 the full VS Code interface (views, webviews, custom editors, notebooks, terminal,
172172 debugger, source control, status bar), the network or the whole project, extensions that
173173 replace typing (Vim, Emacs), `createQuickPick` and `createInputBox`, gutter icons, and
@@ -213,13 +213,35 @@
213213 network, a workspace), so the census is an upper bound; per-extension results are in
214214 `web/js/ext2/tested.json` and feed the panel's "Tested in Code" lines.
215215
216-Across the whole catalog (19,335 extensions on 2026-10-11) only a static sample has been
217-read: 2,000 manifests put the share with a browser entry at about 5%, roughly 470 to 1,430
218-extensions. That is an extrapolation, not a count; none of them was run.
219-`tests/catalog_census.mjs` reads every extension's `package.json` once (no `.vsix`, nothing
220-runs) and classifies it with the panel's own rules, for exact counts. It is manual, about
221-40,000 requests to Open VSX at 4 at a time, and has not been run on the whole catalog yet;
222-`--ranks 1-20,19301-19320` tries it on a few.
216+**Across the whole catalog (static census, 2026-10-11).** `tests/catalog_census.mjs` listed
217+every extension the Open VSX search returns (19,338 that day, the catalog's size when the
218+listing ended) and read each one's latest `package.json`: 19,337, one publishes none.
219+Nothing was downloaded as a `.vsix`, installed or run; about 20,000 requests to the API at
220+most 2.5 a second. Each manifest was classified with the panel's own rules
221+(`web/js/ext2/classify.js`, Monaco's built-in languages, the runtime census above):
222+
223+| | All (19,337) | Top 1,000 | Top 500 | Top 100 |
224+|---|---|---|---|---|
225+| Browser entry | 893 (4.6%) | 151 | 89 | 24 |
226+| …whose code could run in the sandbox | 849 (4.4%) | 116 | 56 | 15 |
227+| Node only (`main`, no `browser`) | 15,729 (81.3%) | 694 | 307 | 70 |
228+| No code at all | 2,715 (14.0%) | 155 | 104 | 6 |
229+| Something applies without code (themes, grammars, snippets, languages) | 5,610 (29.0%) | 449 | 246 | 51 |
230+| Works in Code, either way | 6,152 (31.8%) | 516 | 280 | 58 |
231+| …only through its code | 542 (2.8%) | 67 | 34 | 7 |
232+| Nothing works in Code | 13,185 (68.2%) | 484 | 220 | 42 |
233+
234+These are counts, not a sample: `tests/catalog-census/summary.json` has them with the date
235+and `extensions.tsv` has one line per extension, from which `tests/x2_unit.mjs` recomputes
236+every count. They are static: "could run" means a browser entry and nothing in the manifest
237+or the runtime census that rules it out (384 of the 849 also contribute views or other
238+parts that won't appear here and 32 declare proposed APIs; 52 of the 893 depend on another
239+extension), and it holds where level 2 runs (Chrome or Edge, a site with its sandbox). Only the top
240+500's 89 were actually run (the runtime census above); the other 804 with a browser entry
241+have not been run. An earlier extrapolation from 2,000 manifests (about 950, 4.9%) is
242+replaced by these counts. `node tests/catalog_census.mjs` repeats it (a stopped run resumes;
243+`--recount` classifies again without the network; `--ranks 1-20,10001-10020` tries it on a
244+few).
223245
224246 Tests (each starts its own loopback server; nothing goes to production):
225247
added tests/catalog-census/extensions.tsv +0 −0

Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.

added tests/catalog-census/summary.json +104 −0
@@ -0,0 +1,104 @@
1+{
2+ "schema": 1,
3+ "date": "2026-10-11",
4+ "method": "Static census: every extension that the Open VSX search lists, its latest package.json (for one published per platform, the web build of that version if it has one, else the listed platform build), classified with Elffuss Code's panel rules (web/js/ext2/classify.js; Monaco 0.52.2's built-in languages; the runtime census in web/js/ext2/tested.json for the top 500). Nothing was downloaded as a .vsix, installed or run. \"Runs in the sandbox\" assumes a browser and a site where level 2 is available.",
5+ "catalog": 19338,
6+ "catalogWhenTheListingStarted": 19336,
7+ "listed": 19338,
8+ "notReachableBySearch": 0,
9+ "ranks": "all",
10+ "read": 19337,
11+ "unreadable": 1,
12+ "requests": 20244,
13+ "extensions": 19337,
14+ "browserEntry": 893,
15+ "runsInSandbox": 849,
16+ "nodeOnly": 15729,
17+ "noCode": 2715,
18+ "declarativeApplies": 5610,
19+ "worksInCode": 6152,
20+ "worksOnlyThroughCode": 542,
21+ "nothingWorks": 13185,
22+ "browser": {
23+ "runsAndShowsWorkbenchParts": 384,
24+ "runsWithProposedApis": 32,
25+ "cannotRun": 44,
26+ "whyCannotRun": {
27+ "engine": 3,
28+ "never": 11,
29+ "census": 32
30+ },
31+ "missingDependencies": 52,
32+ "testedInCode": 89
33+ },
34+ "workbenchContributions": {
35+ "views": 6221,
36+ "viewsContainers": 5502,
37+ "viewsWelcome": 1494,
38+ "customEditors": 990,
39+ "notebooks": 86,
40+ "notebookRenderer": 66,
41+ "walkthroughs": 709,
42+ "debuggers": 487,
43+ "breakpoints": 401,
44+ "terminal": 91,
45+ "taskDefinitions": 333,
46+ "problemMatchers": 174,
47+ "authentication": 98,
48+ "chatParticipants": 248,
49+ "languageModelTools": 233,
50+ "mcpServerDefinitionProviders": 376,
51+ "resourceLabelFormatters": 68,
52+ "statusBarItems": 3,
53+ "remoteHelp": 2,
54+ "typescriptServerPlugins": 73
55+ },
56+ "packs": 452,
57+ "webBuilds": 15,
58+ "bands": {
59+ "top100": {
60+ "extensions": 100,
61+ "browserEntry": 24,
62+ "runsInSandbox": 15,
63+ "nodeOnly": 70,
64+ "noCode": 6,
65+ "declarativeApplies": 51,
66+ "worksInCode": 58,
67+ "worksOnlyThroughCode": 7,
68+ "nothingWorks": 42
69+ },
70+ "top500": {
71+ "extensions": 500,
72+ "browserEntry": 89,
73+ "runsInSandbox": 56,
74+ "nodeOnly": 307,
75+ "noCode": 104,
76+ "declarativeApplies": 246,
77+ "worksInCode": 280,
78+ "worksOnlyThroughCode": 34,
79+ "nothingWorks": 220
80+ },
81+ "top1000": {
82+ "extensions": 1000,
83+ "browserEntry": 151,
84+ "runsInSandbox": 116,
85+ "nodeOnly": 694,
86+ "noCode": 155,
87+ "declarativeApplies": 449,
88+ "worksInCode": 516,
89+ "worksOnlyThroughCode": 67,
90+ "nothingWorks": 484
91+ },
92+ "top5000": {
93+ "extensions": 4999,
94+ "browserEntry": 433,
95+ "runsInSandbox": 397,
96+ "nodeOnly": 3894,
97+ "noCode": 672,
98+ "declarativeApplies": 1709,
99+ "worksInCode": 1933,
100+ "worksOnlyThroughCode": 224,
101+ "nothingWorks": 3066
102+ }
103+ }
104+}
modified tests/catalog_census.mjs +214 −107
@@ -1,151 +1,258 @@
11 // Static census of the WHOLE Open VSX catalog (manual, run once by the owner):
2-// one package.json per extension, classified with Code's own rules, so the
3-// README can give exact counts instead of an extrapolation from a sample.
2+// every extension's package.json, classified with the panel's own rules
3+// (web/js/ext2/classify.js), so the README gives exact counts instead of an
4+// extrapolation from a sample.
45 //
56 // node tests/catalog_census.mjs
6-// every extension: tens of thousands of requests to Open VSX, 4 at a
7-// time with a pause between batches; resumable (see below)
8-// node tests/catalog_census.mjs --ranks 1-20,19301-19320
9-// only those download ranks, to try it (a few dozen requests)
10-// options: --pause <ms between batches, 300> --out <summary file>
7+// every extension: about 20,000 requests to the Open VSX API, at most
8+// 2.5 a second (the API allows 3), resumable (see below); writes
9+// tests/catalog-census/summary.json and extensions.tsv (committed)
10+// node tests/catalog_census.mjs --ranks 1-20,10001-10020
11+// only those download ranks (one block from each end of the paging),
12+// to try it: a few dozen requests; writes
13+// tests/.cache/catalog/summary-ranks.json
14+// node tests/catalog_census.mjs --recount
15+// no network: classify again what the cache holds (after a rule change)
16+// options: --gap <ms between two requests, 400> --out <folder>
1117 //
12-// Paging: the search API stops at offset 10,000, so ranks up to 10,000 are read
13-// by downloads, descending, and the rest from the other end, ascending. Every
14-// extension is then read once: its metadata (for a platform-specific one, its
15-// "web" build if it has one, as an install would) and its package.json. No
16-// .vsix is ever downloaded, and nothing is installed or run: that is
17-// tests/x2_census.mjs, on the top 500.
18+// Listing: the search API stops at offset 10,000, so ranks up to 10,000 are
19+// read by downloads, descending, and the rest from the other end, ascending.
20+// Extensions with equal download counts can come back in a different order
21+// from the two ends, so one may appear twice and another never: the listing is
22+// always completed by a second pass sorted by publication date (those found
23+// only there have no rank), and whatever is still missing is counted and said.
1824 //
19-// Each extension is classified with level 1's analyzeManifest and
20-// web/js/ext2/classify.js: declarative parts that apply, browser code that
21-// can run in the sandbox (or why not), Node only, workbench parts that won't
22-// appear. What it reads goes to tests/.cache/catalog/ (one line per extension),
23-// so a stopped run continues where it was and a second run only recounts.
24-// The summary (counts, the date, no timings) is printed and written as JSON.
25+// Manifests: for an extension published for all platforms, its package.json
26+// by its listed version (one request). For one published per platform, the
27+// "web" build of that same version if it has one (as tests/x2_census.mjs
28+// does; an older web build is not what an install gets), or else the listed
29+// platform's (two requests). No .vsix is ever downloaded and nothing is
30+// installed or run: that is tests/x2_census.mjs, on the top 500.
31+//
32+// What it reads goes to tests/.cache/catalog/raw.jsonl (one line per
33+// extension, the manifest without its build-only fields), so a stopped run
34+// continues where it was, and --recount classifies again without the network.
35+// Built-in languages are Monaco 0.52.2's (tests/lib/monaco-languages.json), as
36+// the panel sees them. The summary has counts, the date and the number of
37+// requests; no timings.
2538 import fs from 'node:fs';
2639 import path from 'node:path';
2740 import { fileURLToPath } from 'node:url';
28-import { classify } from '../web/js/ext2/classify.js';
41+import { classify, WORKBENCH } from '../web/js/ext2/classify.js';
2942
3043 const HERE = path.dirname(fileURLToPath(import.meta.url));
3144 const API = 'https://open-vsx.org';
3245 const CAP = 10000; // la búsqueda no pasa de este desplazamiento
3346 const arg = (k, d) => { const i = process.argv.indexOf(k); return i > 0 ? process.argv[i + 1] : d; };
34-const PAUSE = Number(arg('--pause', 300));
47+const GAP = Number(arg('--gap', 400));
3548 const RANKS = arg('--ranks', '') ? arg('--ranks').split(',').map(r => r.split('-').map(Number)) : null;
49+const RECOUNT = process.argv.includes('--recount');
3650 const CACHE = path.join(HERE, '.cache', 'catalog');
37-const OUT = path.resolve(arg('--out', path.join(CACHE, RANKS ? 'summary-ranks.json' : 'summary.json')));
51+const OUTDIR = path.resolve(arg('--out', RANKS ? CACHE : path.join(HERE, 'catalog-census')));
3852 fs.mkdirSync(CACHE, { recursive: true });
53+fs.mkdirSync(OUTDIR, { recursive: true });
3954 const sleep = ms => new Promise(r => setTimeout(r, ms));
40-const inRanks = r => !RANKS || RANKS.some(([a, b]) => r >= a && r <= (b || a));
55+const inRanks = r => !RANKS || (r != null && RANKS.some(([a, b]) => r >= a && r <= (b || a)));
56+const today = new Date().toISOString().slice(0, 10);
4157
42-let requests = 0;
43-async function getJson(url) {
44- for (let attempt = 0; attempt < 4; attempt++) {
58+// ── peticiones: como mucho una cada GAP ms a la API, y paciencia con el 429 ──
59+let requests = 0, nextSlot = 0;
60+async function slot() {
61+ const now = Date.now();
62+ const at = Math.max(now, nextSlot);
63+ nextSlot = at + GAP;
64+ if (at > now) await sleep(at - now);
65+}
66+async function getJson(url, { notFound = false } = {}) {
67+ for (let attempt = 1; attempt <= 6; attempt++) {
68+ await slot();
4569 requests++;
4670 let r;
47- try { r = await fetch(url, { headers: { 'User-Agent': 'elffuss-code-census' }, signal: AbortSignal.timeout(30000) }); }
48- catch (e) { if (attempt === 3) throw e; await sleep(5000 * (attempt + 1)); continue; }
49- if (r.status === 429 || r.status >= 500) { await sleep(15000 * (attempt + 1)); continue; }
50- if (!r.ok) throw Object.assign(new Error(`HTTP ${r.status}`), { status: r.status });
71+ try { r = await fetch(url, { headers: { 'User-Agent': 'elffuss-code-census' }, signal: AbortSignal.timeout(60000) }); }
72+ catch (e) { if (attempt === 6) throw e; await sleep(5000 * attempt); continue; }
73+ // cerca del tope: más despacio (una respuesta de la caché de Open VSX no trae la cabecera)
74+ const left = r.headers.get('x-ratelimit-remaining');
75+ if (left !== null && /^\d+$/.test(left) && Number(left) < 300) nextSlot = Math.max(nextSlot, Date.now() + 5000);
76+ if (r.status === 429 || r.status >= 500) { await r.body?.cancel(); await sleep((r.status === 429 ? 60000 : 15000) * attempt); continue; }
77+ if (r.status === 404 && notFound) { await r.body?.cancel(); return null; }
78+ if (!r.ok) { await r.body?.cancel(); throw Object.assign(new Error(`HTTP ${r.status}`), { status: r.status }); }
5179 return r.json();
5280 }
5381 throw new Error('gave up after retries');
5482 }
5583
56-// ── 1. la lista, por descargas ──
57-const search = (offset, order) => getJson(`${API}/api/-/search?size=100&offset=${offset}&sortBy=downloadCount&sortOrder=${order}&includeAllVersions=false`);
58-const first = await search(0, 'desc');
59-const total = first.totalSize;
60-const today = new Date().toISOString().slice(0, 10);
61-const listFile = path.join(CACHE, `list-${today}.json`);
62-let list;
63-if (fs.existsSync(listFile)) list = JSON.parse(fs.readFileSync(listFile, 'utf8'));
64-else {
65- list = [];
66- const take = (exts, rankOf) => exts.forEach((e, i) => list.push({ rank: rankOf(i), id: `${e.namespace}.${e.name}`, namespace: e.namespace, name: e.name, version: e.version }));
67- const want = page => !RANKS || RANKS.some(([a, b]) => page.lo <= (b || a) && page.hi >= a);
84+// «…/api/ns/name/<plataforma>/<versión>/file/x.vsix» → la plataforma (o null)
85+function platformOf(download) {
86+ try {
87+ const parts = new URL(download).pathname.split('/').filter(Boolean);
88+ return parts[0] === 'api' && parts.length === 7 && parts[5] === 'file' ? parts[3] : null;
89+ } catch { return null; }
90+}
91+
92+// ── 1. la lista, por descargas (y, si faltan, por fecha) ──
93+const listFile = path.join(CACHE, RANKS ? `list-ranks.json` : `list-${today}.json`);
94+async function listing() {
95+ if (RECOUNT || (!RANKS && fs.existsSync(listFile))) {
96+ const files = fs.readdirSync(CACHE).filter(f => /^list-\d{4}-\d\d-\d\d\.json$/.test(f)).sort();
97+ if (!files.length) throw new Error('--recount: no listing in the cache');
98+ return JSON.parse(fs.readFileSync(path.join(CACHE, files.at(-1)), 'utf8'));
99+ }
100+ const search = (offset, sortBy, order) => getJson(`${API}/api/-/search?size=100&offset=${offset}&sortBy=${sortBy}&sortOrder=${order}&includeAllVersions=false`);
101+ const first = await search(0, 'downloadCount', 'desc');
102+ const total = first.totalSize;
103+ const byId = new Map();
104+ let repeated = 0;
105+ const take = (exts, rankOf) => exts.forEach((e, i) => {
106+ const id = `${e.namespace}.${e.name}`;
107+ if (byId.has(id.toLowerCase())) { repeated++; return; }
108+ byId.set(id.toLowerCase(), { rank: rankOf(i), id, namespace: e.namespace, name: e.name, version: e.version, platform: platformOf(e.files?.download), downloads: e.downloadCount ?? null });
109+ });
110+ const want = (lo, hi) => !RANKS || RANKS.some(([a, b]) => lo <= (b || a) && hi >= a);
68111 for (let off = 0; off < Math.min(total, CAP); off += 100) {
69- const page = { lo: off + 1, hi: off + 100 };
70- if (!want(page)) continue;
71- const j = off === 0 ? first : await search(off, 'desc');
112+ if (!want(off + 1, off + 100)) continue;
113+ const j = off === 0 ? first : await search(off, 'downloadCount', 'desc');
72114 take(j.extensions, i => off + i + 1);
73- await sleep(PAUSE);
74115 }
75116 for (let off = 0; off < total - CAP; off += 100) { // del final hacia arriba
76- const page = { lo: total - off - 99, hi: total - off };
77- if (!want(page)) continue;
78- const j = await search(off, 'asc');
117+ if (!want(total - off - 99, total - off)) continue;
118+ const j = await search(off, 'downloadCount', 'asc');
79119 take(j.extensions, i => total - off - i);
80- await sleep(PAUSE);
81120 }
82- if (!RANKS) fs.writeFileSync(listFile, JSON.stringify(list));
121+ // los que el empate de descargas dejó fuera (puede haberlos aunque la lista
122+ // no se quede corta: entre las dos puntas del orden pueden entrar extensiones
123+ // nuevas): por fecha de publicación, siempre que se lee el catálogo entero
124+ let filled = 0, totalAtEnd = total;
125+ if (!RANKS) {
126+ const seen = new Set(byId.keys());
127+ const add = j => { totalAtEnd = j.totalSize; for (const e of j.extensions) { const k = `${e.namespace}.${e.name}`.toLowerCase(); if (!seen.has(k)) { seen.add(k); filled++; byId.set(k, { rank: null, id: `${e.namespace}.${e.name}`, namespace: e.namespace, name: e.name, version: e.version, platform: platformOf(e.files?.download), downloads: e.downloadCount ?? null }); } } };
128+ for (let off = 0; off < Math.min(total, CAP); off += 100) add(await search(off, 'timestamp', 'desc'));
129+ for (let off = 0; off < total - CAP; off += 100) add(await search(off, 'timestamp', 'asc'));
130+ }
131+ // (el catálogo crece mientras se lista: su tamaño al acabar es el que cuenta)
132+ const list = { date: today, total, totalAtEnd, repeated, filledByDate: filled, missing: RANKS ? null : Math.max(0, totalAtEnd - byId.size), extensions: [...byId.values()] };
133+ fs.writeFileSync(listFile, JSON.stringify(list));
134+ return list;
135+}
136+
137+// ── 2. cada package.json, una vez, guardado tal cual (sin lo de compilar) ──
138+const DROP = ['scripts', 'devDependencies', 'dependencies', 'optionalDependencies', 'peerDependencies', 'bundledDependencies', 'resolutions', 'overrides', 'readme', 'files', 'jest', 'eslintConfig', 'prettier', 'lint-staged', 'husky', 'packageManager', 'volta', 'pnpm', 'workspaces', '__metadata'];
139+const slim = m => { if (!m || typeof m !== 'object' || Array.isArray(m)) return null; const o = { ...m }; for (const k of DROP) delete o[k]; return o; };
140+async function read(e) {
141+ const base = `${API}/api/${encodeURIComponent(e.namespace)}/${encodeURIComponent(e.name)}`;
142+ const v = encodeURIComponent(e.version);
143+ let variant = 'universal', url = `${base}/${v}/file/package.json`;
144+ if (e.platform) {
145+ // la web de ESTA versión, si la publica (una compilación web más vieja no
146+ // es la que se instalaría), o la de la plataforma de la lista
147+ const meta = await getJson(`${base}/${v}`, { notFound: true });
148+ if (meta?.downloads?.web) { variant = 'web'; url = `${base}/web/${v}/file/package.json`; }
149+ else { variant = 'platform'; url = `${base}/${encodeURIComponent(e.platform)}/${v}/file/package.json`; }
150+ }
151+ const manifest = await getJson(url, { notFound: true });
152+ if (!manifest) return { id: e.id, version: e.version, rank: e.rank, variant, error: 'no package.json published' };
153+ return { id: e.id, version: e.version, rank: e.rank, variant, manifest: slim(manifest) };
83154 }
84-const seen = new Map();
85-for (const e of list) if (!seen.has(e.id.toLowerCase())) seen.set(e.id.toLowerCase(), e);
86-const todo = [...seen.values()].filter(e => inRanks(e.rank)).sort((a, b) => a.rank - b.rank);
87-console.log(`Open VSX today: ${total} extensions; to classify: ${todo.length}${RANKS ? ' (ranks ' + arg('--ranks') + ')' : ''}; repeated in the paging: ${list.length - seen.size}`);
88155
89-// ── 2. cada package.json, una vez (4 a la vez, con pausa), y su clase ──
90-const progress = path.join(CACHE, 'manifests.jsonl');
156+const list = await listing();
157+const todo = list.extensions.filter(e => inRanks(e.rank)).sort((a, b) => (a.rank ?? 1e9) - (b.rank ?? 1e9));
158+console.log(`Open VSX on ${list.date}: ${list.total} extensions; listed ${list.extensions.length}${list.missing ? `, ${list.missing} not reachable by the search` : ''}; to classify: ${todo.length}${RANKS ? ' (ranks ' + arg('--ranks') + ')' : ''}`);
159+
160+const rawFile = path.join(CACHE, 'raw.jsonl');
91161 const done = new Map();
92-if (fs.existsSync(progress)) {
93- for (const line of fs.readFileSync(progress, 'utf8').split('\n')) {
162+if (fs.existsSync(rawFile)) {
163+ for (const line of fs.readFileSync(rawFile, 'utf8').split('\n')) {
94164 if (!line.trim()) continue;
95165 try { const x = JSON.parse(line); done.set(x.id.toLowerCase(), x); } catch { /* línea a medias de una parada */ }
96166 }
97167 }
98-function classOf(manifest) {
99- const c = classify(manifest);
100- return {
101- browser: typeof manifest.browser === 'string', main: typeof manifest.main === 'string', runtime: c.runtime,
102- declarative: c.hasDeclarative, eligible: !!c.eligible, works: !!c.works, workbench: c.unavailable.length > 0,
103- reasons: c.reasons || [], pack: Array.isArray(c.pack) && c.pack.length > 0,
168+const runsFile = path.join(CACHE, 'runs.json');
169+const runs = fs.existsSync(runsFile) ? JSON.parse(fs.readFileSync(runsFile, 'utf8')) : [];
170+if (!RECOUNT) {
171+ // (una por extensión y versión: si la lista trae otra versión, se vuelve a leer)
172+ const pending = todo.filter(e => { const d = done.get(e.id.toLowerCase()); return !d || d.version !== e.version; });
173+ const out = fs.openSync(rawFile, 'a');
174+ let n = 0;
175+ const worker = async () => {
176+ while (pending.length) {
177+ const e = pending.shift();
178+ const x = await read(e).catch(err => ({ id: e.id, version: e.version, rank: e.rank, error: String(err.message || err).slice(0, 200) }));
179+ x.rank = e.rank;
180+ done.set(x.id.toLowerCase(), x);
181+ fs.writeSync(out, JSON.stringify(x) + '\n');
182+ if (++n % 500 === 0) console.log(` ${n} read, ${pending.length} to go`);
183+ }
104184 };
185+ await Promise.all([1, 2, 3, 4].map(worker));
186+ fs.closeSync(out);
187+ runs.push({ date: today, ranks: RANKS ? arg('--ranks') : 'all', requests, read: n });
188+ if (!RANKS) fs.writeFileSync(runsFile, JSON.stringify(runs, null, 1));
105189 }
106-async function read(e) {
107- const base = `${API}/api/${encodeURIComponent(e.namespace)}/${encodeURIComponent(e.name)}`;
108- let meta = await getJson(base);
109- let variant = (meta.targetPlatform || 'universal') === 'universal' ? 'universal' : 'platform';
110- if (variant === 'platform' && meta.downloads && meta.downloads.web) { meta = await getJson(base + '/web'); variant = 'web'; }
111- if (!meta.files?.manifest) return { id: e.id, version: meta.version || e.version, rank: e.rank, variant, error: 'no package.json published' };
112- const manifest = await getJson(meta.files.manifest);
113- return { id: e.id, version: meta.version || e.version, rank: e.rank, variant, ...classOf(manifest) };
114-}
115-const out = fs.openSync(progress, 'a');
116-let fresh = 0;
117-// (una por extensión: para volver a leerlas otro día, bórrese tests/.cache/catalog/)
118-const pending = todo.filter(e => !done.has(e.id.toLowerCase()));
119-for (let i = 0; i < pending.length; i += 4) {
120- const batch = pending.slice(i, i + 4);
121- const got = await Promise.all(batch.map(e => read(e).catch(err => ({ id: e.id, version: e.version, rank: e.rank, error: String(err.message || err).slice(0, 200) }))));
122- for (const x of got) { done.set(x.id.toLowerCase(), x); fs.writeSync(out, JSON.stringify(x) + '\n'); fresh++; }
123- if ((i / 4) % 50 === 0) console.log(` ${Math.min(i + 4, pending.length)} of ${pending.length} read`);
124- await sleep(PAUSE);
125-}
126-fs.closeSync(out);
127190
128-// ── 3. recuento ──
129-const rows = todo.map(e => done.get(e.id.toLowerCase())).filter(Boolean);
130-const ok = rows.filter(r => !r.error);
131-const n = f => ok.filter(f).length;
191+// ── 3. recuento, con las reglas del panel ──
192+const langs = JSON.parse(fs.readFileSync(path.join(HERE, 'lib/monaco-languages.json'), 'utf8'));
193+const builtin = new Set(langs.languages.map(l => l.id));
194+const monarch = new Set(langs.languages.filter(l => l.monarch).map(l => l.id));
195+const tested = JSON.parse(fs.readFileSync(path.join(HERE, '../web/js/ext2/tested.json'), 'utf8'));
196+const opts = { tested, builtinLanguage: id => builtin.has(id), grammarSkippedFor: id => builtin.has(id) && !monarch.has(id) };
197+const rows = todo.map(e => ({ e, x: done.get(e.id.toLowerCase()) })).filter(r => r.x);
198+const classes = rows.map(({ e, x }) => {
199+ if (x.error || !x.manifest) return { e, x, c: null };
200+ return { e, x, c: classify(x.manifest, opts) };
201+});
202+const ok = classes.filter(r => r.c);
203+const count = (set, f) => set.filter(f).length;
204+const tally = set => ({
205+ extensions: set.length,
206+ browserEntry: count(set, r => r.c.runtime === 'browser'),
207+ runsInSandbox: count(set, r => r.c.eligible),
208+ nodeOnly: count(set, r => r.c.runtime === 'node'),
209+ noCode: count(set, r => r.c.runtime === 'none'),
210+ declarativeApplies: count(set, r => r.c.hasDeclarative),
211+ worksInCode: count(set, r => r.c.works),
212+ worksOnlyThroughCode: count(set, r => r.c.works && !r.c.hasDeclarative),
213+ nothingWorks: count(set, r => !r.c.works),
214+});
215+const bands = {};
216+for (const n of [100, 500, 1000, 5000]) bands['top' + n] = tally(ok.filter(r => r.e.rank != null && r.e.rank <= n));
132217 const summary = {
133- date: today, catalog: total, classified: ok.length, unreadable: rows.length - ok.length,
134- ranks: RANKS ? arg('--ranks') : 'all', requestsThisRun: requests, readThisRun: fresh,
135- browserEntry: n(r => r.browser),
136- browserRunsInSandbox: n(r => r.browser && r.eligible),
137- browserRunsAndShowsWorkbenchParts: n(r => r.browser && r.eligible && r.workbench),
138- browserCannotRun: n(r => r.browser && !r.eligible),
139- nodeOnly: n(r => r.main && !r.browser),
140- noCode: n(r => !r.main && !r.browser),
141- declarativeApplies: n(r => r.declarative),
142- worksInCode: n(r => r.works),
143- worksOnlyThroughCode: n(r => r.works && !r.declarative),
144- nothingWorks: n(r => !r.works),
145- packs: n(r => r.pack),
146- whyBrowserCannotRun: Object.fromEntries(['engine', 'proposals', 'never', 'deps'].map(k => [k, n(r => r.browser && !r.eligible && r.reasons.includes(k))])),
147- webBuilds: n(r => r.variant === 'web'),
218+ schema: 1,
219+ date: list.date,
220+ method: 'Static census: every extension that the Open VSX search lists, its latest package.json (for one published per platform, the web build of that version if it has one, else the listed platform build), classified with Elffuss Code\'s panel rules (web/js/ext2/classify.js; Monaco 0.52.2\'s built-in languages; the runtime census in web/js/ext2/tested.json for the top 500). Nothing was downloaded as a .vsix, installed or run. "Runs in the sandbox" assumes a browser and a site where level 2 is available.',
221+ catalog: list.totalAtEnd ?? list.total,
222+ catalogWhenTheListingStarted: list.total,
223+ listed: list.extensions.length,
224+ notReachableBySearch: list.missing,
225+ ranks: RANKS ? arg('--ranks') : 'all',
226+ read: ok.length,
227+ unreadable: classes.length - ok.length,
228+ // las peticiones que pide leerlo todo una vez: dos listados de páginas de 100
229+ // (por descargas y por fecha), un package.json por extensión y, en las
230+ // publicadas por plataforma, la consulta de su compilación web
231+ requests: RANKS ? requests : 2 * Math.ceil((list.totalAtEnd ?? list.total) / 100) + classes.length + classes.filter(r => r.e.platform).length,
232+ ...tally(ok),
233+ browser: {
234+ runsAndShowsWorkbenchParts: count(ok, r => r.c.eligible && r.c.unavailable.length > 0),
235+ runsWithProposedApis: count(ok, r => r.c.eligible && r.c.apiProposals > 0),
236+ cannotRun: count(ok, r => r.c.runtime === 'browser' && !r.c.eligible),
237+ whyCannotRun: Object.fromEntries(['engine', 'never', 'census'].map(k => [k, count(ok, r => r.c.runtime === 'browser' && !r.c.eligible && r.c.reasons.includes(k))])),
238+ missingDependencies: count(ok, r => r.c.runtime === 'browser' && r.c.deps.missing.length > 0),
239+ testedInCode: count(ok, r => r.c.runtime === 'browser' && !!r.c.census),
240+ },
241+ workbenchContributions: Object.fromEntries(WORKBENCH.map(k => [k, count(ok, r => r.c.unavailable.includes(k))]).filter(([, n]) => n)),
242+ packs: count(ok, r => r.c.pack.length > 0),
243+ webBuilds: count(ok, r => r.x.variant === 'web'),
244+ bands,
148245 };
149-fs.writeFileSync(OUT, JSON.stringify(summary, null, 1) + '\n');
246+const name = RANKS ? 'summary-ranks.json' : 'summary.json';
247+fs.writeFileSync(path.join(OUTDIR, name), JSON.stringify(summary, null, 1) + '\n');
248+if (!RANKS) {
249+ // una línea por extensión, para poder comprobar cada recuento
250+ const b = v => (v ? 1 : 0);
251+ const lines = ['rank\tid\tversion\tvariant\truntime\tdeclarative\truns_in_sandbox\tworks\tworkbench\twhy_not'];
252+ for (const { e, x, c } of classes.sort((p, q) => (p.e.rank ?? 1e9) - (q.e.rank ?? 1e9) || p.e.id.localeCompare(q.e.id))) {
253+ lines.push([e.rank ?? '-', e.id, x.version, x.variant || '-', c ? c.runtime : 'unreadable', b(c?.hasDeclarative), b(c?.eligible), b(c?.works), b(c && c.unavailable.length), c ? c.reasons.join(',') : (x.error || '')].join('\t'));
254+ }
255+ fs.writeFileSync(path.join(OUTDIR, 'extensions.tsv'), lines.join('\n') + '\n');
256+}
150257 console.log(JSON.stringify(summary, null, 1));
151-console.log(`summary: ${path.relative(path.resolve(HERE, '..'), OUT)}`);
258+console.log(`summary: ${path.relative(path.resolve(HERE, '..'), path.join(OUTDIR, name))}`);
modified tests/suites.txt +1 −1
@@ -99,4 +99,4 @@
9999 shot_utopiaia: a screenshot of a production site
100100 warmup_code: warms up the real model in a persistent profile
101101 x2_census: manual: downloads and runs the top-500's browser extensions from Open VSX
102-catalog_census: manual: reads every extension's package.json in Open VSX (tens of thousands of requests)
102+catalog_census: manual: reads every extension's package.json in Open VSX (about 20,000 requests); its last run is in tests/catalog-census/
modified tests/x2_unit.mjs +22 −0
@@ -437,6 +437,28 @@
437437 ok(`censo, con sus manifiestos reales (${reales.length}): ninguna que arrancó sale como «no puede correr» ni escondida`, !malR.length, malR.join(' '));
438438 }
439439
440+// ── el censo estático del catálogo entero (tests/catalog-census/): cada recuento sale de sus líneas ──
441+const cat = JSON.parse(fs.readFileSync(path.join(HERE, 'catalog-census/summary.json'), 'utf8'));
442+const tsv = fs.readFileSync(path.join(HERE, 'catalog-census/extensions.tsv'), 'utf8').split('\n').filter(Boolean);
443+const [head, ...lineas] = tsv;
444+const cols = head.split('\t');
445+const filas = lineas.map(l => Object.fromEntries(l.split('\t').map((v, i) => [cols[i], v])));
446+const leidas = filas.filter(r => r.runtime !== 'unreadable');
447+const cuenta = f => leidas.filter(f).length;
448+const recount = {
449+ read: leidas.length, unreadable: filas.length - leidas.length,
450+ browserEntry: cuenta(r => r.runtime === 'browser'), runsInSandbox: cuenta(r => r.runs_in_sandbox === '1'), nodeOnly: cuenta(r => r.runtime === 'node'), noCode: cuenta(r => r.runtime === 'none'),
451+ declarativeApplies: cuenta(r => r.declarative === '1'), worksInCode: cuenta(r => r.works === '1'), worksOnlyThroughCode: cuenta(r => r.works === '1' && r.declarative === '0'), nothingWorks: cuenta(r => r.works === '0'),
452+};
453+const top = n => leidas.filter(r => r.rank !== '-' && Number(r.rank) <= n);
454+ok('catálogo: cada recuento del resumen sale de extensions.tsv (una línea por extensión), también el del top 500', Object.entries(recount).every(([k, v]) => cat[k] === v)
455+ && cat.bands.top500.browserEntry === top(500).filter(r => r.runtime === 'browser').length && cat.bands.top100.worksInCode === top(100).filter(r => r.works === '1').length,
456+ JSON.stringify(Object.fromEntries(Object.entries(recount).filter(([k, v]) => cat[k] !== v).map(([k, v]) => [k, [cat[k], v]]))));
457+ok('catálogo: con fecha y tamaño, todo listado, sin tiempos', /^\d{4}-\d\d-\d\d$/.test(cat.date) && cat.listed === filas.length && cat.listed >= cat.catalog && cat.notReachableBySearch === 0
458+ && !JSON.stringify(cat).match(/"(ms|millis|seconds|duration|elapsed|time)[A-Za-z]*"\s*:/i), JSON.stringify({ date: cat.date, catalog: cat.catalog, listed: cat.listed, lines: filas.length }));
459+ok('catálogo y censo en ejecución: las del top 500 con entrada de navegador son las mismas 89', top(500).filter(r => r.runtime === 'browser').length === results.length
460+ && top(500).filter(r => r.runtime === 'browser').every(r => results.some(([k]) => k.split('@')[0] === r.id.toLowerCase())));
461+
440462 const files = [...fs.readdirSync(path.join(REPO, 'web/js/ext2')).map(f => 'web/js/ext2/' + f), 'sandbox/x2/headers.json', 'sandbox/x2/headers.mjs', 'sandbox/x2/v1/sandbox.html', 'sandbox/x2/v1/exthost-iframe.html'];
441463 const home = ['/', 'Users', '/'].join(''), linuxHome = ['/', 'home', '/'].join('');
442464 ok('ni rutas de usuario ni prefijos de home en el nivel 2', files.every(f => { const t = fs.readFileSync(path.join(REPO, f), 'utf8'); return !t.includes(home) && !t.includes(linuxHome); }));