ycode is a fork of Zed that can be scripted in
Lua. Its own code is a hook system, crates/lua_hooks. It lets
plugins written in Lua intercept and replace any Zed action, add new actions and draw
native gpui windows and dock panels. The rest of the editor is upstream Zed with a few
small patches.
ycode is part of the jbisfun workspace, which is managed with pull. Most features live in plugins, not in this repo.
Hook files are ~/.config/zed/hooks/*.lua and *.x.lua, plus one level of extension
subdirectories (hooks/<ext>/). .x.lua files use directives modelled on
Logos:
%hook editor
- Copy
%log
%orig
end
%end%hook ns/- Action: wrapns::Action(- *wraps the whole namespace). If a hook never calls%orig, the action is swallowed.%new - Name(args): a new action, shown in the command palette.%hookf point: wrap a hook point in the Rust code (e.g.client::authenticate, the automatic sign-in at startup).%ctor,%group/%init,%log.
The Lua API (ycode.*, gpui.*) covers dispatching actions, a settings layer, the KV
store, status-bar buttons, workspace folders, spawning processes and native UI elements
(gpui.open_window, gpui.register_panel). LuaSocket comes embedded. Plugins are
reloaded with ycode: reload hooks and never need a rebuild.
- crates/lua_hooks/README.md: directives and API
- crates/lua_hooks/UI.md: how Lua windows and panels should look
crates/lua_hooks/ycode-lua: REPL/runner for the live executor socket ($XDG_RUNTIME_DIR/ycode-lua.sock)
Each plugin is its own repo, symlinked into ~/.config/zed/hooks/<name>/:
- ycode-pull: pull's multi-repo Pull panel, sessions and jobs. It replaces Zed's git panel, which handles only one repo.
- ycode-hermes: Hermes Agent as the agent, over ACP
- ycode-idl: panel for the idl CLI
- ycode-manager: enable/disable plugins
- ycode-offline: turns off sign-in and the online features
Outside crates/lua_hooks, the patches are small and generic:
- gpui:
App::intercept_actions, a single slot that wraps every window and global action dispatch - zed:
lua_hooks::initruns after all other inits. Startup sign-in goes through theclient::authenticatehook point. The Lua C API is exported sorequirecan load C modules. - settings: a plugin settings layer (
SettingsStore::set_plugin_settings) - command palette:
%newactions appear in the palette, and actions can be hidden - workspace: Lua dock panels (
panel_index_for_id) - agent_ui:
agent::SyncAgentThreadsimports an ACP agent's existing sessions
The build is the same as upstream Zed (Linux, macOS, Windows):
cargo build -p zed # target/debug/zedycode is licensed like upstream Zed: GPL-3.0-or-later, with Apache-2.0 components where
marked. See LICENSE-GPL and LICENSE-APACHE.