Elffuss BraidHub

utopia-ia/elffuss-code public

Changeset: fc9a8dba96f6
fc9a8dba96f6 run-modes: say when extension mode was never exercised; add stop_ide KikoCis,
bridge/
sandbox/
server/
tests/
vendor/
web/
.gitignore616 B
LICENSE11.1 KiB
NOTICE1.9 KiB
README.md17.7 KiB
deploy-sandbox.shexecutable2.7 KiB
deploy-vendor.shexecutable2.9 KiB
deploy.shexecutable5.1 KiB
sync-core.shexecutable3.9 KiB

README.md

🧑‍💻 Elffuss Code — a VS Code-style IDE with an AI soul, 100% in your browser

Open a local folder and a full web IDE unfolds around it — real Monaco (the VS Code editor), a file tree, tabs — with an AI agent that reads, searches and edits your project for real. Everything runs in your browser: your code never leaves your machine.

▶️ Live demo · ✳️ Elffuss Claw (sibling project) · 🧬 Shared core · License: Apache-2.0

<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">

In the demo above, a small model running entirely in the browser reads calc.py, finds a real bug and fixes it with a minimal edit — using genuine tool-calling, not autocomplete.


Why it's different

  • Your code stays on your machine. No upload, no account, no server round-trip. The folder is opened locally via the File System Access API.
  • The model runs on your GPU via WebGPU — nothing is sent to a cloud API by default.
  • Real tool-calling, not autocomplete. The agent reads files, greps the project and makes minimal, surgical edits — and you watch each tool call happen.
  • Real editor. Monaco (the actual VS Code editor core), file tree, tabs, Ctrl+S.
  • Zero install, zero build. Vanilla ES modules. Open the URL and you're in.

How it works

  1. Landing → "📁 Open code folder" (File System Access — Chrome/Edge).
  2. IDE → file tree (left) · Monaco with tabs and Ctrl+S (center) · AI chat (right).
  3. The agent works only inside your project, through a small set of tools:
    • code.tree — list the project
    • code.read — read a file (paginated, 100 lines at a time, can center on a line)
    • code.search — grep across the project, with line numbers
    • code.edit / code.write — make edits (the editor refreshes instantly)
  4. Local brain by default: Gemma-4 (E4B on desktop, E2B on mobile) via LiteRT-LM on WebGPU, with an ONNX / transformers.js fallback (Qwen2.5-0.5B q4) when WebGPU isn't available. External providers (OpenAI, Anthropic, Ollama) are opt-in in ⚙️ — keys stay in your browser and calls go straight to the provider.
  5. Optional real terminal. A tiny local Bridge (opt-in) lets the agent run real node / npm / python and read the output — still on your machine, nothing hosted.

VS Code extensions: themes, grammars, snippets

The Extensions button in the activity bar (also View → Extensions…, or /extensions in the chat on small screens) searches Open VSX and installs the declarative part of VS Code extensions: color themes (with a Color Theme picker), TextMate grammars, snippets and language configurations (comments, brackets, indentation). You can also install a .vsix file.

  • No extension code runs unless you turn it on for one extension (level 2, below, not available on code.elffuss.com yet). Otherwise main/browser are ignored; the panel says what each extension applies and what would need an extension host (commands, views, debuggers…).
  • Your project stays in the browser. Open VSX only sees what you search for and install.
  • Packages are checked against the SHA-256 that Open VSX publishes and kept in IndexedDB.
  • Grammars run on the same engine as VS Code (vscode-textmate + Oniguruma), loaded only when a file needs one: the engine is vendored in web/js/ext/vendor/ (unchanged, MIT) and the Oniguruma WebAssembly comes from jsDelivr with an integrity check. Without extensions, nothing extra loads.
  • What a package brings is treated as untrusted data: grammars and themes are cleaned of names that would reach Object.prototype, snippet details are plain text (no remote images), regular expressions that repeat a repetition are dropped, and firstLine patterns run in a Worker with a time limit. The panel lists anything it had to skip.
  • ?noext starts with every extension paused (to rescue a tab from a bad grammar).

Extensions that run code (level 2)

Web extensions (a browser entry, never Node) can run their code in a sealed sandbox: a headless VS Code (@codingame/monaco-vscode-api 37.3.11, VS Code 1.138.0) inside an invisible iframe on another site, with no network host in any CSP. Code's own editor stays Monaco 0.52; it only talks to the sandbox through one validated message channel and renders what extensions return as plain text or escaped markdown.

In the Extensions panel, before you install anything, each result says what will work: the declarative parts, "Runs in Code's sandbox" (with its commands, keybindings and settings), "Needs Node: not available in the browser", the parts that won't appear here (views, webviews, debugger…) and "Tested in Code" from the runtime census below. The Works in Code chip hides what cannot work (it reads each result's manifest, which Open VSX then sees; the panel says so). Install and run its code… first shows what the extension will see, that it has no internet and cannot save, and the download sizes; nothing is fetched until you accept. Installed extensions with code get: run or turn off their code (no reload), state, their commands with Run buttons (the way in on a phone), settings as JSON checked against what they declare, the formatter per language (theirs or the built-in one), keybindings that were not bound and why, a log, and the number of calls the sandbox refused. Their commands also appear in Code's palette (>), in F1 and in the editor's context menu.

What keeps your data in your browser, and what enforces it:

  • No network at all. The sandbox's CSPs name no host, not even its own; it refuses to start if a self-test request is not blocked; WebRTC and window.open are removed and navigation is cancelled in both of its documents. Extension files are fetched and checked by Code's page at install time (the SHA-256 that Open VSX publishes is required) and handed over as blobs, so the sandbox never talks to Open VSX.
  • No access to Code's storage. The sandbox is a different site: separate IndexedDB, OPFS, localStorage, cookies and process.
  • One checked channel. Every message from the sandbox is validated by type, shape and size; repeated violations tear the sandbox down. Inside the sandbox an RPC firewall (web/js/ext2/rpc-allowlist.json) refuses the extension host's calls that are not on the list: webviews, terminal, debug, SCM, tasks, sign-in, language models, chat, tunnels, notebooks, saving and more.
  • Text stays text. Hovers, completion details, signatures, diagnostics, notifications, dialogs and pickers are drawn with textContent or as markdown in which every punctuation character is escaped: no remote image, link or HTML. Decoration styles go through a whitelist (no url(), no fontFamily); gutter icons are not shown.
  • Every address asks first and shows the full URL (control and bidi characters made visible, the host in Unicode and punycode): openExternal, also when a completion or a code action runs it, and Cmd+click in the editor while extensions run. Links inside what extensions show are plain text. Clipboard writes need a recent click or key.
  • Open documents only, no saving. Extensions see the files you have open, as file:///<project path>; their edits go to the active document as one undo step and stay unsaved until you save with Cmd+S as always. An edit computed on text that changed in the meantime (the agent wrote the file, you typed) is discarded and the status bar says so. The agent's tools are unchanged.
  • Off means off. VS Code cannot unload an extension that already started, so turning one's code off (or disabling, updating or uninstalling it) while others run rebuilds the sandbox with the others; with none left, the sandbox goes away. No reload either way.
  • Two gates in Code. The HTML preview of a file an extension wrote into asks first (the preview runs scripts with network). While extensions run, the agent's web requests and local runtimes (node, npm, python… through the Bridge) ask first, showing the full URL or command.

Proof: node tests/x2_canary.mjs runs an extension that tries every channel it has (30 from the worker, plus poisoned hovers, completions, signatures, diagnostics, decorations, notifications, pickers, a code action and a completion that open addresses, forged RPC frames) with Chromium resolving *.test to a beacon and recording a NetLog; it also runs attack code directly inside both sandbox documents. The beacon must see 0 requests, 0 connections and 0 UDP packets; accepting one address must produce exactly one visit, to the address the dialog showed; and positive controls show the setup does catch leaks.

  • Nothing of level 2 loads until you turn an extension's code on. tests/x2_bytes.mjs compares Code with the level 1 tip request by request, uncompressed: with no extension it asks for exactly the same files and 817 bytes more (two one-line hooks in main.js and ide.js); with level 1 extensions only, the same files and 4.4 KB more (the hooks in js/ext/host.js and store.js that decide when to load js/ext2/host2.js); with the Extensions panel open and a search done, the same files and 18 KB more (what the panel now tells everyone: what will work, the Works in Code filter, how extensions are isolated). In none of these is anything fetched from vendor/x2/, js/ext2/ or the sandbox site. Once code is on, the runtime is 2.6 MB gzip (from the manifest), fetched once and then served from the HTTP cache. ?noext pauses every extension, ?noext2 only their code, "enabled": false in the manifest is a global kill switch, and the panel can turn all extension code off.
  • The runtime is verified at load: SRI on each .gz, then the sha256 of the inflated bytes against the committed web/js/ext2/vendor-manifest.json. It is built by a pinned, reproducible script and deployed separately; see vendor/vscode-ext2/README.md.
  • What doesn't work: Node-only extensions (most of the catalog), anything that needs the full VS Code interface (views, webviews, custom editors, notebooks, terminal, debugger, source control, status bar), the network or the whole project, extensions that replace typing (Vim, Emacs), createQuickPick and createInputBox, gutter icons, and Firefox and Safari in this version.
  • Not available on code.elffuss.com yet: the sandbox needs its own domain first (sandbox/x2/nginx.conf.example, then deploy-sandbox.sh, deploy-vendor.sh and deploy.sh, in that order). Locally, open Code on http://127.0.0.1:<port> with tests/lib/x2-server.mjs, which serves the sandbox on localhost:<port> (a different site).

What actually runs (runtime census, 2026-10-11). Of the 500 most downloaded extensions on Open VSX, 89 have a browser entry. tests/x2_census.mjs installed each one from its verified package (the web build, when the publisher ships one) and started it alone in the real sandbox with a beacon listening:

ResultExtensions
Too large to install (over 32 MiB per file or 64 MiB per extension)8
Start49
…and register a command, a language feature or diagnostics33
…and register language features (completion, hover, formatting…)12
Fail while starting (Node modules or globals in their browser build, services Code doesn't have, blocked network requests)22
Never start (nothing in Code triggers them: previews, custom editors, sign-in)9
Refused: Vim replaces typing1
Requests that reached the beacon0

The census ran again with the finished sandbox (the RPC firewall on, and notifications, dialogs and pickers answered the way a hurried user would: closed or cancelled) and gave the same counts. 8 of the 89 asked the user something while starting (7 notifications and 1 picker); one that failed already, GitHub Pull Requests, now stops at the firewall's refusal of sign-in. Some extensions that start still need things Code doesn't have (webviews, the network, a workspace), so the census is an upper bound; per-extension results are in web/js/ext2/tested.json and feed the panel's "Tested in Code" lines.

Across the whole catalog (19,335 extensions on 2026-10-11) only a static sample has been read: 2,000 manifests put the share with a browser entry at about 5%, roughly 470 to 1,430 extensions. That is an extrapolation, not a count; none of them was run. tests/catalog_census.mjs reads every extension's package.json once (no .vsix, nothing runs) and classifies it with the panel's own rules, for exact counts. It is manual, about 40,000 requests to Open VSX at 4 at a time, and has not been run on the whole catalog yet; --ranks 1-20,19301-19320 tries it on a few.

Tests (each starts its own loopback server; nothing goes to production):

SuiteWhat it proves
x2_unitprotocol 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
x2_headersthe sandbox documents' exact headers, 404 for anything else, Code never serves /x2/, the vendor files' headers and SRI (also against a deployment)
x2_smokesynthetic extensions end to end: commands, formatting, hovers, symbols, diagnostics, decorations, dialogs, the gates, the firewall, tampering, ?noext/?noext2/kill switch
x2_bytesthe default path and the level 1 states against the level 1 tip (above)
x2_canarythe canary and the drill (above), with positive controls
x2_managersort-lines and Prettier installed, run, configured and uninstalled through the panel, Open VSX mocked from their pinned packages
x2_commandssort-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
x2_formatPrettier: Format Document, Shift+Alt+F, undo, save, settings, the built-in formatter back, a race with an agent write
x2_uxwhat the panel says before installing, the filter, sizes, a 390 px phone, dialog roles and keys, 25 of Code's elements styled identically with and without level 2
x2_live, x2_lifecyclethe real Open VSX: install, update, turn off and on, disable, reload and uninstall, with pinned versions and SHA-256

tests/run-modes.sh runs every Code suite in tests/suites.txt twice, as is and in extension mode (tests/lib/x2-mode.mjs installs two code extensions that run in the sandbox while the suite works, then checks the sandbox ran wherever the IDE opened, with no level 2 error and nothing but its two documents asked from the sandbox site), plus the level 2 suites once. The suites that need a live model, a GPU, a local Bridge, the internet or production are listed there with the reason. The runtime census is node tests/x2_census.mjs (manual).

Run locally

python3 server/serve.py 8645     # → http://localhost:8645

Chrome/Edge recommended (WebGPU + File System Access). The Basic mode needs no download; models are fetched from the CDN/HF the first time and cached afterwards.

Test hook: ?test-opfs uses the browser's OPFS storage as the project (native folder pickers require a human gesture, which headless tests can't provide).

Architecture

web/
  index.html            IDE shell: tree · Monaco · agent chat
  js/main.js            boot, model selection, WebGPU detection
  js/agent.js           agentic loop: model → tool-call JSON → result → model
  js/ide.js             Monaco, tabs, file tree, HTML preview
  js/tools/code.js      code.tree / read / search / edit / write  (the only thing touching your files)
  js/bridge.js          optional local Bridge (real node/npm/python)
  js/ext/               VS Code extensions: Open VSX, .vsix reader, themes, grammars, snippets
  js/ext2/              level 2: loader, sandbox bridge, editor adapter (buildless)
  js/providers/         onnx (transformers.js) · api (OpenAI/Anthropic/Ollama)
sandbox/x2/             the extension sandbox's two documents and their headers (another site)
vendor/vscode-ext2/     pinned build of the level 2 runtime (the only place npm runs)
server/serve.py         static server + CORS proxy (dev)

No framework, no build step for Code's own code (only the optional level 2 runtime is a prebuilt, verified vendor bundle). The agent talks to the tools with ```tool {"tool":…,"args":…} ``` blocks — the same protocol across every provider.

Shares a core with Elffuss

db.js, context.js (ACE-lite context eviction), settings.js, the providers and the WebGL splash come from the sibling repo elffuss. Fix something there → sync it here.

License

Apache-2.0.

Gestión de contexto

El 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).

Tablas completas, ablaciones y referencias en el core compartido · la historia con lo que salió mal en la bitácora.