Elffuss BraidHub

utopia-ia/elffuss-code public

main · 22.8 KiBRenderedRawPermalink
1# 🧑‍💻 Elffuss Code — a VS Code-style IDE with an AI soul, 100% in your browser
2
3**Open a local folder and a full web IDE unfolds around it — real Monaco (the VS Code
4editor), a file tree, tabs — with an AI agent that reads, searches and edits your project
5for real. Everything runs in your browser: your code never leaves your machine.**
6
7**[▶️ Live demo](https://code.elffuss.com)** ·
8**[✳️ Elffuss Claw (sibling project)](https://github.com/utopia-ia/elffuss-claw)** ·
9**[🧬 Shared core](https://github.com/utopia-ia/elffuss)** ·
10**License: Apache-2.0**
11
12> Elffuss Code now lives in the UtopiaIA organization on GitHub, at github.com/utopia-ia/elffuss-code. It moved from github.com/KikoCis/elffuss-code on 23 October 2026; the old address redirects.
13
14<p align="center">
15 <a href="https://code.elffuss.com">
16 <img src="https://utopiaia.com/demos/elffuss/elffuss-code-demo.gif" alt="Elffuss Code — the agent reads calc.py, finds a real bug and fixes it, all locally" width="820">
17 </a>
18</p>
19
20> In the demo above, a **small model running entirely in the browser** reads `calc.py`,
21> finds a real bug and fixes it with a minimal edit — using genuine tool-calling, not
22> autocomplete.
23
24---
25
26## Why it's different
27
28- **Your code stays on your machine.** No upload, no account, no server round-trip. The
29 folder is opened locally via the [File System Access API](https://developer.mozilla.org/docs/Web/API/File_System_Access_API).
30- **The model runs on *your* GPU** via WebGPU — nothing is sent to a cloud API by default.
31- **Real tool-calling, not autocomplete.** The agent reads files, greps the project and
32 makes minimal, surgical edits — and you watch each tool call happen.
33- **Real editor.** Monaco (the actual VS Code editor core), file tree, tabs, `Ctrl+S`.
34- **Zero install, zero build.** Vanilla ES modules. Open the URL and you're in.
35
36## How it works
37
381. **Landing** → "📁 Open code folder" (File System Access — Chrome/Edge).
392. **IDE** → file tree (left) · Monaco with tabs and `Ctrl+S` (center) · AI chat (right).
403. The agent works **only inside your project**, through a small set of tools:
41 - `code.tree` — list the project
42 - `code.read` — read a file (paginated, 100 lines at a time, can center on a line)
43 - `code.search` — grep across the project, with line numbers
44 - `code.edit` / `code.write` — make edits (the editor refreshes instantly)
454. **Local brain by default:** Gemma-4 (E4B on desktop, E2B on mobile) via **LiteRT-LM on
46 WebGPU**, with an **ONNX / transformers.js** fallback (Qwen2.5-0.5B `q4`) when WebGPU
47 isn't available. External providers (OpenAI, Anthropic, Ollama) are **opt-in** in ⚙️ —
48 keys stay in your browser and calls go straight to the provider.
495. **Optional real terminal.** A tiny local **Bridge** (opt-in) lets the agent run real
50 `node` / `npm` / `python` and read the output — still on your machine, nothing hosted.
51
52## VS Code extensions: themes, grammars, snippets
53
54The **Extensions** button in the activity bar (also *View → Extensions…*, or `/extensions`
55in the chat on small screens) searches [Open VSX](https://open-vsx.org)
56and installs the *declarative* part of VS Code extensions: **color themes** (with a
57Color Theme picker), **TextMate grammars**, **snippets** and **language configurations**
58(comments, brackets, indentation). You can also install a `.vsix` file.
59
60- **No extension code runs** unless you turn it on for one extension (level 2, below).
61 Otherwise `main`/`browser` are ignored; the panel says what each extension applies and
62 what would need an extension host (commands, views, debuggers…).
63- **Your project stays in the browser.** Open VSX only sees what you search for and install.
64- Packages are checked against the SHA-256 that Open VSX publishes and kept in IndexedDB.
65- Grammars run on the same engine as VS Code (vscode-textmate + Oniguruma), loaded only
66 when a file needs one: the engine is vendored in `web/js/ext/vendor/` (unchanged, MIT)
67 and the Oniguruma WebAssembly comes from jsDelivr with an integrity check. Without
68 extensions, nothing extra loads.
69- What a package brings is treated as untrusted data: grammars and themes are cleaned
70 of names that would reach `Object.prototype`, snippet details are plain text (no remote
71 images), regular expressions that repeat a repetition are dropped, and `firstLine`
72 patterns run in a Worker with a time limit. The panel lists anything it had to skip.
73- `?noext` starts with every extension paused (to rescue a tab from a bad grammar).
74
75### Extensions that run code (level 2)
76
77Web extensions (a `browser` entry, never Node) can run their code in a **sealed sandbox**:
78a headless VS Code (`@codingame/monaco-vscode-api` 37.3.11, VS Code 1.138.0) inside an
79invisible iframe on **another site**, with no network host in any CSP. Code's own editor
80stays Monaco 0.52; it only talks to the sandbox through one validated message channel and
81renders what extensions return as plain text or escaped markdown.
82
83**In the Extensions panel**, before you install anything, each result says what will work:
84the declarative parts (counted the way they apply: a language Monaco already has does not
85count), *"Runs in Code's sandbox"* (with its commands, keybindings and settings),
86*"Needs Node: not available in the browser"*, the parts that *won't appear here* (views,
87webviews, debugger…) and *"Tested in Code"* from the runtime census below. Where level 2
88cannot run (Firefox, Safari, `?noext2`, a site with no sandbox) the line says so with the
89reason, the run button is inert, and the **Works in Code** chip keeps only what works
90there. An extension that declares proposed VS Code APIs is marked: Code does not turn those
91APIs on, so some of its parts may fail (the census shows many such extensions start). The
92chip reads each result's manifest, which Open VSX then sees; the panel says so. **Install**
93on a result that only brings code reads its manifest first (no download) and offers
94**Install and run its code…**, which first shows what the extension will see, that it has no
95internet and cannot save, the runtime's size and the extension's own (from a HEAD request to
96Open VSX); nothing is downloaded until you accept. Installed extensions with code get: run or turn off
97their code (no reload), state, their commands with Run buttons (the way in on a phone),
98settings as JSON checked against what they declare, the formatter per language (theirs
99or the built-in one), keybindings that were not bound and why, a log, and the number of
100calls the sandbox refused. Their commands also appear in Code's palette (`>`), in F1 and
101in the editor's context menu.
102
103What keeps your data in your browser, and what enforces it:
104
105- **No network at all.** The sandbox's CSPs name no host, not even its own; it refuses to
106 start if a self-test request is not blocked; WebRTC and `window.open` are removed and
107 navigation is cancelled in both of its documents. Extension files are fetched and
108 checked by Code's page at install time (the SHA-256 that Open VSX publishes is required)
109 and handed over as blobs, so the sandbox never talks to Open VSX.
110- **No access to Code's storage.** The sandbox is a different site: separate IndexedDB,
111 OPFS, localStorage, cookies and process.
112- **One checked channel.** Every message from the sandbox is validated by type, shape and
113 size; repeated violations tear the sandbox down. Inside the sandbox an RPC firewall
114 (`web/js/ext2/rpc-allowlist.json`) refuses the extension host's calls that are not on the
115 list: webviews, terminal, debug, SCM, tasks, sign-in, language models, chat, tunnels,
116 notebooks, saving and more.
117- **Text stays text.** Hovers, completion details, signatures, diagnostics, notifications,
118 dialogs and pickers are drawn with `textContent` or as markdown in which every
119 punctuation character is escaped: no remote image, link or HTML. Decoration styles go
120 through a whitelist (no `url()`, no `fontFamily`); gutter icons are not shown.
121- **Every address asks first** and shows the full URL (control and bidi characters made
122 visible, the host in Unicode and punycode, the site repeated next to the buttons, a long
123 address scrolling in its own box): `openExternal`, also when a completion or a code
124 action runs it, and Cmd+click in the editor while extensions run. A `vscode.Uri` opens
125 the way VS Code opens it (`encodeURI(uri.toString(true))`, so `=`, `&` and `+` stay as
126 written). *Block requests for this session* blocks extensions' requests only (your own
127 Cmd+click still asks); each dropped request is reported in the status bar, and the panel
128 shows the block with an *Unblock* button. Links inside what extensions show are plain
129 text. Clipboard writes need a recent click or key. A notification that waits for an
130 answer is reachable from the editor with F6 (F6 again goes back) or from Code's palette.
131- **Open documents only, no saving.** Extensions see the files you have open, as
132 `file:///<project path>`; their edits go to the active document as one undo step and stay
133 unsaved until you save with Cmd+S as always. An edit computed on text that changed in
134 the meantime (the agent wrote the file, you typed) is discarded and the status bar says
135 so. The agent's tools are unchanged.
136- **Off means off.** VS Code cannot unload an extension that already started, so turning
137 one's code off (or disabling, updating or uninstalling it) while others run rebuilds the
138 sandbox with the others; with none left, the sandbox goes away. No reload either way.
139- **Two gates in Code.** The HTML preview of a file an extension wrote into asks first (the
140 preview runs scripts with network). While extensions run, the agent's web requests and
141 local runtimes (node, npm, python… through the Bridge) ask first, showing the full URL or
142 command.
143
144Proof: `node tests/x2_canary.mjs` runs an extension that tries every channel it has (30
145from the worker, plus poisoned hovers, completions, signatures, diagnostics, decorations,
146notifications, pickers, a code action and a completion that open addresses, forged RPC
147frames) with Chromium resolving `*.test` to a beacon and recording a NetLog; it also runs
148attack code directly inside both sandbox documents. The beacon must see 0 requests, 0
149connections and 0 UDP packets; accepting one address must produce exactly one visit, to the
150address the dialog showed; and positive controls show the setup does catch leaks.
151
152- **Nothing of level 2 loads until you turn an extension's code on.** `tests/x2_bytes.mjs`
153 compares Code with its main before level 2 (which has level 1) request by request,
154 uncompressed: with no extension it asks for exactly the same files and 616 bytes more
155 (short hooks in `main.js` and `ide.js`: the palette list, the preview gate and the list
156 of open tabs); with level 1 extensions only, the same files and 4.2 KB more (the hooks in
157 `js/ext/host.js` and `store.js` that decide when to load `js/ext2/host2.js`); with the
158 Extensions panel open and a search done, the same files and 20,165 bytes more, within the
159 suite's 20 KB budget
160 (what the panel now tells everyone: what will work, the Works in Code filter, how
161 extensions are isolated, the check before Install, which for a result that applies
162 without code loads nothing of level 2). In none of these is anything fetched from
163 `vendor/x2/`, `js/ext2/` or the
164 sandbox site. Once code is on, the runtime is 2.6 MB gzip (from the manifest), fetched
165 once and then served from the HTTP cache. `?noext` pauses every extension, `?noext2` only
166 their code, `"enabled": false` in the manifest is a global kill switch, and the panel can
167 turn all extension code off.
168- **The runtime is verified at load:** SRI on each `.gz`, then the sha256 of the inflated
169 bytes against the committed `web/js/ext2/vendor-manifest.json`. It is built by a
170 pinned, reproducible script and deployed separately; see
171 [`vendor/vscode-ext2/README.md`](vendor/vscode-ext2/README.md).
172- **What doesn't work:** Node-only extensions (81% of the catalog), anything that needs
173 the full VS Code interface (views, webviews, custom editors, notebooks, terminal,
174 debugger, source control, status bar), the network or the whole project, extensions that
175 replace typing (Vim, Emacs), `createQuickPick` and `createInputBox`, gutter icons, and
176 Firefox and Safari in this version.
177- **Where the sandbox lives:** for code.elffuss.com, on `https://x2.utopiaia.com`, another
178 registrable domain. `web/js/ext2/config.js` names it and refuses a sandbox on the same
179 site as Code (a subdomain of elffuss.com would share cookies and a process);
180 `sandbox/x2/headers.json` names the same origin for the headers and nginx, and
181 `deploy-sandbox.sh` checks that both agree before uploading. Code on any other host gets
182 no sandbox. To publish, in order: the `deploy.sh` filter for `vendor/x2/` on main (any
183 deploy without it deletes the bundle; `deploy-vendor.sh` refuses until main has it),
184 `sandbox/x2/nginx.conf.example` for x2.utopiaia.com and Code's vendor location
185 (Cache-Control without `always`, so a missing file is never cached as immutable),
186 `deploy-sandbox.sh`, `deploy-vendor.sh`, a read-only check with
187 `X2_SANDBOX=https://x2.utopiaia.com node tests/x2_headers.mjs`, and `deploy.sh` last
188 (it refuses to ship a manifest whose build the server lacks). Locally, open Code on
189 `http://127.0.0.1:<port>` with `tests/lib/x2-server.mjs`, which serves the sandbox on
190 `localhost:<port>` (a different site).
191
192**What actually runs (runtime census, 2026-10-11).** Of the 500 most downloaded extensions
193on Open VSX, 89 have a browser entry. `tests/x2_census.mjs` installed each one from its
194verified package (the web build, when the publisher ships one), started it alone in the
195real sandbox with a beacon listening, and once the sandbox ran opened one sample document
196per language it declares:
197
198| Result | Extensions |
199|---|---|
200| Too large to install (over 32 MiB per file or 64 MiB per extension) | 8 |
201| Start | 50 |
202| …and register a command, a language feature or diagnostics | 34 |
203| …and register language features (completion, hover, formatting…) | 14 |
204| Fail while starting (Node modules or globals in their browser build, services or proposed APIs Code doesn't have, blocked network requests) | 23 |
205| Never start (what starts them doesn't exist in Code: a workspace, the Markdown preview, custom editors, notebooks, sign-in; one starts and never finishes) | 7 |
206| Refused: Vim replaces typing | 1 |
207| Requests that reached the beacon | 0 |
208
209It ran with the finished sandbox (the RPC firewall on, and notifications, dialogs and
210pickers answered the way a hurried user would: closed or cancelled). 9 of the 89 asked the
211user something while starting (8 notifications and 1 picker); GitHub Pull Requests stops at
212the firewall's refusal of sign-in. An earlier run opened the sample documents while the
213sandbox was still starting, when Code showed extensions only the active tab: CSS and
214configuration-editing were counted as never starting and TypeScript's language features
215were missed. Code now shows extensions every open tab, also the ones opened before the
216sandbox started (`tests/x2_ux.mjs`, X11), and the census opens its samples once the sandbox
217runs. Some extensions that start still need things Code doesn't have (webviews, the
218network, a workspace), so the census is an upper bound; per-extension results are in
219`web/js/ext2/tested.json` and feed the panel's "Tested in Code" lines.
220
221**Across the whole catalog (static census, 2026-10-11).** `tests/catalog_census.mjs` listed
222every extension the Open VSX search returns (19,338 that day, the catalog's size when the
223listing ended) and read each one's latest `package.json`: 19,337, one publishes none.
224Nothing was downloaded as a `.vsix`, installed or run; about 20,000 requests to the API at
225most 2.5 a second. Each manifest was classified with the panel's own rules
226(`web/js/ext2/classify.js`, Monaco's built-in languages, the runtime census above):
227
228| | All (19,337) | Top 1,000 | Top 500 | Top 100 |
229|---|---|---|---|---|
230| Browser entry | 893 (4.6%) | 151 | 89 | 24 |
231| …whose code could run in the sandbox | 849 (4.4%) | 116 | 56 | 15 |
232| Node only (`main`, no `browser`) | 15,729 (81.3%) | 694 | 307 | 70 |
233| No code at all | 2,715 (14.0%) | 155 | 104 | 6 |
234| Something applies without code (themes, grammars, snippets, languages) | 5,610 (29.0%) | 449 | 246 | 51 |
235| Works in Code, either way | 6,152 (31.8%) | 516 | 280 | 58 |
236| …only through its code | 542 (2.8%) | 67 | 34 | 7 |
237| Nothing works in Code | 13,185 (68.2%) | 484 | 220 | 42 |
238
239These are counts, not a sample: `tests/catalog-census/summary.json` has them with the date
240and `extensions.tsv` has one line per extension, from which `tests/x2_unit.mjs` recomputes
241every count. They are static: "could run" means a browser entry and nothing in the manifest
242or the runtime census that rules it out (384 of the 849 also contribute views or other
243parts that won't appear here and 32 declare proposed APIs; 52 of the 893 depend on another
244extension), and it holds where level 2 runs (Chrome or Edge, a site with its sandbox). Only the top
245500's 89 were actually run (the runtime census above); the other 804 with a browser entry
246have not been run. An earlier extrapolation from 2,000 manifests (about 950, 4.9%) is
247replaced by these counts. `node tests/catalog_census.mjs` repeats it (a stopped run resumes;
248`--recount` classifies again without the network; `--ranks 1-20,10001-10020` tries it on a
249few).
250
251Tests (each starts its own loopback server; nothing goes to production):
252
253| Suite | What it proves |
254|---|---|
255| `x2_unit` | protocol validators, escaped markdown on a hostile corpus, conversions, keybindings and reserved chords, globs, headers, manifests, the RPC allowlist, the decoration whitelist, URL display, classification, texts, the package reader, the shipped census |
256| `x2_headers` | the sandbox documents' exact headers, 404 for anything else, Code never serves `/x2/`, the vendor files' headers and SRI, a missing vendor file not cached (also against production); the generated nginx snippets, and the sandbox vhost naming x2.utopiaia.com |
257| `x2_deploy` | the deploy scripts against a folder that plays the server (fake `git`, `ssh` and `rsync`): only the manifest's files go up and nothing else may be there, a stray or corrupt file stops it, main must protect `vendor/x2/` first, the sandbox must be another site and the one `headers.json` and `config.js` name (by default it deploys x2.utopiaia.com) |
258| `x2_smoke` | synthetic extensions end to end: commands, formatting, hovers, symbols, diagnostics, decorations, dialogs, the gates, the firewall, tampering, `?noext`/`?noext2`/kill switch |
259| `x2_bytes` | the default path and the level 1 states against main before level 2 (above) |
260| `x2_canary` | the canary and the drill (above), with positive controls |
261| `x2_manager` | sort-lines and Prettier installed, run, configured and uninstalled through the panel, Open VSX mocked from their pinned packages |
262| `x2_commands` | sort-lines in Code's palette, F1, F9 and the context menu; Cmd+S; reserved chords and conflicts; Code's own shortcuts unchanged; hostile titles stay text |
263| `x2_format` | Prettier: Format Document, Shift+Alt+F, undo, save, settings, the built-in formatter back, a race with an agent write |
264| `x2_ux` | what the panel says before installing (also where level 2 cannot run, and with the filter on first), Install on a code-only result, sizes, phones (390 and 360 px, a long address), keyboard access to notifications, pickers and dialogs, blocking and unblocking requests, tabs opened before the sandbox, Spanish texts, contrast, 25 of Code's elements styled identically with and without level 2 |
265| `x2_live`, `x2_lifecycle` | the real Open VSX: install, update, turn off and on, disable, reload and uninstall, with pinned versions and SHA-256 |
266
267`tests/run-modes.sh` runs every Code suite in `tests/suites.txt` twice, as is and in
268**extension mode** (`tests/lib/x2-mode.mjs` installs two code extensions that run in the
269sandbox while the suite works, then checks the sandbox ran wherever the IDE opened, with
270no level 2 error and nothing but its two documents asked from the sandbox site), plus the
271level 2 suites once. A suite that never opens the IDE cannot exercise extension mode: it
272shows *PASS, no IDE* and is listed at the end, not counted as covered (`stop_ide` is the
273IDE variant of `stop`). The suites that need a live model, a GPU, a local Bridge, the
274internet or production are listed there with the reason; the Bridge ones need its fixed
275ports (8765, and Code on 8799), so they have not run in extension mode. The runtime census
276is `node tests/x2_census.mjs` (manual).
277
278## Run locally
279
280```bash
281python3 server/serve.py 8645 # → http://localhost:8645
282```
283
284Chrome/Edge recommended (WebGPU + File System Access). The **Basic** mode needs no
285download; models are fetched from the CDN/HF the first time and cached afterwards.
286
287Test hook: `?test-opfs` uses the browser's OPFS storage as the project (native folder
288pickers require a human gesture, which headless tests can't provide).
289
290## Architecture
291
292```
293web/
294 index.html IDE shell: tree · Monaco · agent chat
295 js/main.js boot, model selection, WebGPU detection
296 js/agent.js agentic loop: model → tool-call JSON → result → model
297 js/ide.js Monaco, tabs, file tree, HTML preview
298 js/tools/code.js code.tree / read / search / edit / write (the only thing touching your files)
299 js/bridge.js optional local Bridge (real node/npm/python)
300 js/ext/ VS Code extensions: Open VSX, .vsix reader, themes, grammars, snippets
301 js/ext2/ level 2: loader, sandbox bridge, editor adapter (buildless)
302 js/providers/ onnx (transformers.js) · api (OpenAI/Anthropic/Ollama)
303sandbox/x2/ the extension sandbox's two documents and their headers (another site)
304vendor/vscode-ext2/ pinned build of the level 2 runtime (the only place npm runs)
305server/serve.py static server + CORS proxy (dev)
306```
307
308No framework, no build step for Code's own code (only the optional level 2 runtime is a
309prebuilt, verified vendor bundle). The agent talks to the tools with
310` ```tool {"tool":…,"args":…} ``` ` blocks — the same protocol across every provider.
311
312## Shares a core with Elffuss
313
314`db.js`, `context.js` (ACE-lite context eviction), `settings.js`, the providers and the
315WebGL splash come from the sibling repo **[elffuss](https://github.com/utopia-ia/elffuss)**.
316Fix something there → sync it here.
317
318## License
319
320[Apache-2.0](LICENSE).
321
322## Gestión de contexto
323
324El empaquetador de contexto (BM25 con IDF endógena contra la pregunta viva, sin heurísticas) está medido: recuerdo de hechos **15,1 % → 65,3 %** al mismo gasto de tokens, y **recuperar bien bate a no comprimir** (F1 28,09 contra 22,56 del contexto completo, con el 8 % de los tokens).
325
326Tablas completas, ablaciones y referencias en el **[core compartido](https://github.com/utopia-ia/elffuss#cómo-se-mide-el-gestor-de-contexto)** · la historia con lo que salió mal en la **[bitácora](https://bitacora.utopiaia.com/posts/16-beaten-by-doing-nothing.html)**.