Tyler Benfield

Tyler Benfield

Khepri

People that have known me longer know that I can come up with some lofty project ideas. It goes way back too. As a teenager learning to code I thought I could build J.A.R.V.I.S. Some of my wild ideas became reality, like Axe.NET, an API design I developed at Standpoint Technologies that provided similar benefits to GraphQL but before it was a public project. Other ideas weren't so lucky, like Zero Document Format (ZDF), an idea to replace PDFs by packaging HTML, CSS, JS and other resources into a compressed format for delivery using public key cryptography for signing and verifying authenticity. The latest of these wild thought experiments is codename Khepri, and it may be my most ambitious yet.

Khepri isn't a single project. It's a suite of experiments that attempt to bring modern web development into the browser.

What does it mean to bring web development into the browser? There are several code editors available that run within the browser, some even capable enough to be called IDEs. So isn't it already possible write code within the browser? The answer is a bit more complicated. The browser editors I am familiar with, while being able to add packages from NPM, compile TypeScript, and perform numerous other incredible tasks, are all locked into the configurations they support. They leave no room for custom build processes or extending functionality. Those that do provide customization seem to address it by launching the user into a shell connecting to a virtual machine on a server somewhere and saying "run whatever you want". This is still amazing and I still can't believe it is possible, but it has limitations. Once the user needs to connect to a server, they obviously lose the ability to work offline. It becomes more of a browser-based remote terminal than a browser-based coding environment.

Khepri addresses this problem with a core component called Scarab. Scarab is a Web Platform compatible build pipeline that aligns closely with modern, local build tools. The current focus is on providing a development server and production build command, but in the future Scarab may extend to running tests, formatting code, or performing other tasks against source code. Scarab is heavily influenced by Snowpack and shows clear similarities.

Scarab is the core of Khepri, but it is less than useful by itself. Scarab relies on plugins for compiling code, with some of the initial examples being esbuild and Svelte. It's also just a set of classes and functions that don't execute on their own. This is where Khepri:Deno, Khepri:CLI and the web interfaces come in. Since Deno is a JavaScript runtime that focuses on spec-compliance, Scarab runs on Deno almost by default. Khepri:CLI is just the compiled version of Khepri:Deno for those wanting to run Khepri locally. Web interfaces are also being developed, with the expectation that there will be some form of playground and possibly even a code editor. There are currently no plans for a Node.js wrapper for Scarab though there are no expected technical limitations preventing it.

Khepri provides security and privacy by default. Since all components of Khepri run locally in the browser, your code will never need to leave your machine. In fact, Khepri official projects are designed to be offline-first. In practice this means that your code will stay with you, on your machine, until you make the decision to share it. Additionally, running Khepri in the browser provides natural sandboxing with the security and privacy rules already built into broswers. Scarab even uses the interfaces provided by the experimental File System Access API, which will eventually allow executing build tasks against local files while restricting access to the directory that was explicitly granted. No more concern over post install scripts, compromised build tools, or other forms of malicious code executing in your local development environment.

So what will Khepri become? To be honest, I don't know. I'm taking a similar model to Pika that eventually became Snowpack and Skypack by exploring several paths that are rooted in a central idea. Some may succeed, many will fail. Regardless of the outcome, it is the most fun I've had on a project in a very long time.