Skip to content
pencode-labsPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

64 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pencode

Pencode logo

A code editor written in Go, with an Onix-powered desktop interface and a shared backend for local, SSH, and WebSocket workspaces.

English · 简体中文

Homepage · Downloads

Pencode running on Linux with Go source code, the project tree and the integrated terminal

Pencode brings editing, language tools, a terminal, Git, and native process extensions into one workbench. Its client/server design keeps the interface on your machine while file operations and development tools run where your project lives.

Status: early development. Pencode is being extracted from the Onix repository into a standalone project. The source includes the features below and uses Onix's public HTML APIs. Read development setup before building.

UI languages: change Settings → Appearance → Display language for Chinese, English, Japanese, Korean, German, French or Spanish. Extensions can add JSON language packs; see the language pack guide. Missing translations fall back to English.

Features · Development setup · Architecture · Extensions · Contributing

Features

Area Implemented capabilities
Editing Untitled tabs (Ctrl+N, or ⌘N on macOS), undo/redo, find and replace, quick file opening, soft wrapping, and a piece-tree text buffer
Language tools Incremental syntax highlighting; LSP completion, diagnostics, navigation, rename, formatting, and code actions, depending on the language server
Terminal Multiple shell sessions, Linux/macOS PTY, Windows ConPTY, Unicode, true color, and scrollback
Debugger DAP launchers for Go, PHP, Python, Dart, C#, C, C++, Objective-C, Objective-C++, Rust, Zig, and Swift, with breakpoints, stepping, call stacks, variables, and expression evaluation in local and SSH workspaces
Local history Right-click a file or folder in the explorer to view its history in Source Control. Click a version to compare it with the current file, including unsaved edits, or right-click it to restore. Changes written directly by external tools do not create entries. By default the workspace host records saves up to 256 KiB, merges saves from the same source within 10 seconds, and keeps the latest 50 entries per file. File and folder moves carry existing history to the new path. The host’s settings.json supports workbench.localHistory.enabled, maxFileSize (KiB), maxFileEntries, mergeWindow (seconds), and exclude (for example, "workbench.localHistory.exclude": {"**/dist/**": true}). All five keys use the workbench.localHistory. prefix.
Git Staging, commits, branch and history views, file comparisons, and a three-way merge editor
Remote work System OpenSSH or token-authenticated WebSocket connections, with file operations, terminals, language servers, and extensions running on the workspace host
Customization System fonts, VS Code JSON/JSONC color themes, file icon themes, and syntax capture mappings
Extensions Executable extensions for custom editors, language servers, fonts, themes, icons, actions, dialogs, menus, and panels

The extension manager currently installs from local directories; there is no online catalog. Pencode does not run VS Code extensions. Theme compatibility is limited to the fields implemented by Pencode.

At startup, the editor, standalone server, and extension installer import manual HTTP/HTTPS system proxies from Windows Internet settings (including machine policy), macOS network settings, or Linux GNOME settings. Extensions and tools inherit them through environment variables. Existing HTTP_PROXY, HTTPS_PROXY, or ALL_PROXY variables (including lowercase forms) take precedence, and explicit NO_PROXY settings are preserved. Restart the relevant process after changing system proxies. PAC/WPAD scripts are not evaluated; child processes interpret bypass rules according to their own NO_PROXY support.

File changes use native FSEvents on macOS, recursive ReadDirectoryChangesW on Windows, and inotify on Linux. A unified file service distributes changes to the editor and extensions, with bounded history and explicit resynchronization after overflow.

Development setup

Requirements and current limitations

  • Go 1.27.0 or newer.
  • An Onix checkout next to this repository, named onix. The current go.mod uses replace github.com/onix-engine/onix => ../onix.
  • The native development libraries required by Onix for desktop builds; see docs/desktop-builds.md in the Onix checkout.
  • System git for source control and OpenSSH ssh for SSH connections. Manage workspace tools in Settings → Language Servers and Settings → Debuggers (DAP). Pencode detects tools on the workspace host and applies semantic highlighting from the active language server. Language server setup · Debugger setup
  • Text fonts installed on the GUI host. Pencode bundles Symbols Nerd Font Mono as a fallback for shell prompt icons.
  • Image paste on Linux requires wl-paste (from wl-clipboard) on Wayland or xclip on X11. Windows and macOS use native clipboard APIs.

Expected layout:

workspace/
├── onix/
└── pencode/

With Onix in place, clone Pencode beside it and resolve dependencies:

git clone --recurse-submodules git@github.com:pencode-labs/pencode.git
cd pencode
go mod tidy

Use an Onix checkout that provides github.com/onix-engine/onix/html/parse and github.com/onix-engine/onix/scene/node. Build Pencode from the repository root.

go build ./...

Unpackaged Go builds use rg from PATH for search. The Makefile and release builds download ripgrep 16.0.0 for each build target, verify its SHA-256, and embed it in the desktop or server executable. The verified downloads are cached in the Git-ignored internal/ripgrep/bundle/ directory.

To compile and install pencode-server and reinstall the bundled extensions before starting Pencode, run:

make run

This builds and installs pencode-server into ~/.pencode/pencode-server (%USERPROFILE%/.pencode/pencode-server.exe on Windows). It builds each checked-out extension in its own Go module, using its own go.mod and go.sum with Go workspaces disabled. Extensions are installed in ~/.pencode/extensions/<extension-id>/ on the local host. After each successful build, the previous installation with that ID is deleted and replaced, including its resources and manifest. Windows executables and installed manifest entries use .exe; Linux and macOS use the native executable name. Source manifests are unchanged.

Use make install-extensions to install without launching the app, or make install-extensions EXTENSIONS_DIR="/path/to/extensions" to stage packages in another directory. Remote workspaces need their extensions installed on the remote host.

Use make install-server to compile and install only the local server. For offline SSH bootstrap, run go run ./cmd/pencode-build-servers from the repository root to build Linux/macOS amd64 and arm64 servers into resources/servers/<os>-<arch>/pencode-server.

Build a native desktop installer for the current host with make release VERSION=v0.1.0 (default version: dev; override the output directory with DIST_DIR). This uses Onix's release pipeline to compile module plans and resources into catalog.bin and .dat packages, then builds with onix_release. Outputs are dist/pencode-<version>-windows-<arch>.exe, dist/pencode-<version>-darwin-<arch>.pkg, and dist/pencode-<version>-linux-<arch>.deb, each with a .sha256 sidecar. Windows uses Inno Setup 7 (ISCC can point to the compiler), shows the installation directory page, defaults to %LOCALAPPDATA%\Programs\Pencode, and registers shortcuts, an uninstaller and an Open with entry for supported text and source files. File associations are registered for the current user and removed on uninstall; existing default apps are preserved. macOS uses productbuild to install Pencode.app into /Applications. Debian/Ubuntu use dpkg-deb to install into /opt/pencode, with a pencode command and application menu entry. The desktop executable is named Pencode (Pencode.exe on Windows). All installers include the license, icon notices and both READMEs. Extensions are installed separately; offline SSH server binaries are not included.

Launch with pencode [--] <file-or-directory> ... to open local files or folders. Each file opens as an editable, pinned tab using its parent directory as the workspace. Multiple files in the same directory share a workspace. Local paths cannot be combined with remote connection options. You can also drop files or folders onto the launcher or editor; existing unsaved tabs are retained. Dropping local files into a remote session opens a separate local window. Native installers register Pencode in Windows, macOS and Linux Open With menus without changing existing default apps. Finder document events work both when launching Pencode and while it is running.

Pushing a v* tag triggers the release workflow, which builds Linux, Windows and macOS for both amd64 and arm64, verifies checksums, and uploads six native installers, six standalone servers and SHA256SUMS to the GitHub Release. Server assets are named pencode-server-<version>-<os>-<arch> (with .exe on Windows), are built with CGO_ENABLED=0, and can be downloaded independently for remote hosts. Set the repository Actions variable ONIX_REF to the compatible Onix commit or tag before releasing; it defaults to main. Manual workflow runs and release-related changes on main build downloadable artifacts without publishing a release. Builds need the native libraries described by Onix; Windows uses MinGW-w64 (LLVM MinGW also supports arm64). macOS bundles receive ad-hoc signatures; Developer ID signing and notarization are not configured.

Settings → About provides a single button that changes from Check for updates to Download update, then Install and restart as the update progresses. Updates resolve GitHub tags to published releases, select the native installer for the current OS/architecture, and verify SHA-256 before staging it in a temporary directory. Restart follows the unsaved-file confirmation flow. After the editor exits, a helper runs the native installer and restarts Pencode; cancellation or installer failure also attempts to restart the installed editor. Windows updates keep the existing installation path. macOS opens Installer; Debian/Ubuntu use pkexec and apt-get with system authorization. Native installers manage package registration and uninstall metadata. Stable installations skip prereleases. Update detection requires an installed package containing pencode-version; existing archive distributions need one manual installation to switch to this flow.

For a direct WebSocket connection, start the server on the remote host:

pencode-server --listen 0.0.0.0:8080 --token 'your-secret-token'

In Remote management → Add, select WebSocket, enter ws://server-address:8080/ws and the same token (the display name is optional). Save, connect from the connection menu, and choose a remote project directory. Profiles and tokens are stored in the local user configuration directory under pencode/resources/connection.json with 0600 permissions. The client also supports wss:// endpoints served by a TLS reverse proxy.

--listen requires a nonempty token, checked through the HTTP Authorization: Bearer header. Without --listen, the server uses stdio. ws:// sends traffic in plaintext; use a TLS reverse proxy with wss:// across public networks.

Release builds can enable pprof mode in Settings → About (restart required). Development builds record by default. Recording captures CPU, Go heap, process/system memory, and available GPU metrics in ~/.pencode/profiles/. Set PENCODE_DEBUG=0 to disable recording or PENCODE_PROFILE_DIR to choose a directory. See profiling and pprof analysis for sampling, retention, and metric definitions (Chinese).

Verify individual packages

From the Pencode repository root:

go test -p 1 ./protocol ./peb ./lsp ./transport ./terminal

These checks cover individual packages, not full application or platform validation. Run go test -p 1 ./... to include the workbench and all other packages in the main module. Test the independent extension modules separately:

git submodule foreach 'go test ./...'

Workbench rendering tests use resources in workbench/testdata/ and do not require the Codex submodule. To also build and run the actual Codex extension in the host:

git submodule update --init extensions/codex
go test -p 1 -tags codex_integration ./workbench

Architecture

Desktop workbench (Onix)
        │
        │ CS v9: local process pipes, SSH stdin/stdout, or WebSocket
        ▼
Pencode server
        ├── Files, documents, indexing, and syntax parsing
        ├── Git and terminal processes
        ├── Language servers (LSP)
        └── Extension processes (peb v20)

The GUI owns interactive text buffers, undo history, layout, and rendering. The server owns filesystem access, indexing, syntax parsing, Git, PTYs, language servers, and extension processes. Local sessions start a child server; SSH sessions use the same protocol over an encrypted stream without opening a server port. WebSocket sessions use the same protocol at the token-authenticated /ws endpoint.

For remote workspaces, settings and extensions belong to the workspace host; system fonts come from the GUI host. Reconnection preserves unsaved GUI text and checks for external changes. It does not automatically replay saves, Git writes, or terminal input.

Directory Responsibility
workbench/ Editor interface, document interaction, themes, and panels
client/, protocol/ Typed client services and CS wire protocol
server/ Workspace services and process ownership
transport/, remote/, connection/ Local transport, SSH, WebSocket, and connection lifecycle
terminal/, lsp/, peb/ Terminal emulator, LSP support, and extension protocol/SDK
extensions/ Extension host integration and example extension submodules
resources/ Application configuration, scenes, UI assets, and icons
cmd/ Standalone server and server artifact build helper

Extensions

Extensions are native executables or JavaScript bundles compiled from TypeScript, communicating with the server through peb v20, a binary protocol over stdin/stdout. Within each project, one process per extension serves its workbench actions and document views. Closing a view releases its session. Closing the project, closing the connection, or revoking the extension releases the process. Logs go to stderr. They run with the server user's permissions, including on remote workspace hosts.

Download prebuilt extension packages from their releases and extract them directly into the workspace server's ~/.pencode/extensions/ directory. See extension releases for the fixed package format, platform support and download links.

Extensions live under ~/.pencode/extensions/<extension-id>/ on the server host and include an executable and a resources/extension.json manifest. Use the extension manager's local-directory installation flow to register one.

Bundled extensions include the following; see each extension for its license and build instructions:

  • Codex Agent: editor chat, streaming replies, approvals, and project conversations through the Codex CLI.
  • Docker: container lists, start/stop/restart controls, and automatically refreshed logs from the title bar.
  • Office Viewer: a TypeScript extension for local read-only Word .docx, Excel .xlsx, and PowerPoint .pptx previews.
  • Markdown preview: read-only preview with native source editing and optional split layout.
  • Material file icons: a file icon theme.
  • Extension UI: actions, dialogs, menus, popups, and panels.

For an existing checkout, initialize the submodules with git submodule update --init --recursive. Go extensions have independent Go modules; TypeScript extensions have independent npm packages. Each directory includes build instructions. For example, build the Docker extension from the repository root with:

(cd extensions/docker && go build -o bin/docker .)

The current extension protocol is peb v20 (CS v26). Older extensions must be rebuilt with the current SDK.

The workspace host recognizes .js, .mjs, and .cjs entries and launches them with Node.js from its PATH, falling back to Bun. Runtime loading never invokes a package manager; compile TypeScript and bundle dependencies first. See the TypeScript SDK. make install-extensions uses npm (or Bun) with the lockfile, runs the package build, and installs its output directory, resources and package.json. The package metadata preserves ESM/CJS behavior for .js; JavaScript entries keep the same name on every platform.

Documentation

Document Contents Language
CS protocol Framing, requests, limits, and lifecycle Chinese
Extension protocol and SDK Contributions, editors, actions, and UI Chinese
LSP support Language server implementation and development Chinese
Debugger Go quick start, debug configurations, and architecture English
Historical implementation notes Editor behavior, themes, SSH, design decisions, and earlier verification records Chinese

The historical notes retain commands from the former Onix monorepo layout. Use this README for the current layout and build limitations. English translations of the technical guides are welcome.

Contributing

Issues and pull requests are welcome. Useful starting points include completing the standalone-module migration, improving build and platform documentation, fixing editor behavior, extending tests, and translating technical guides.

For bug reports, include your OS and architecture, Go version, Pencode and Onix revisions, reproduction steps, and relevant Output panel diagnostics. For SSH issues, include the remote OS and whether the issue also occurs locally. Remove credentials and private project data from logs.

Keep changes focused, run checks for the packages you touch, and describe what you verified and any limitations. Discuss substantial protocol or architecture changes in an issue before implementing them.

License and acknowledgments

Pencode is licensed under the MIT License.

Pencode builds on Onix, textmate-go, and other Go libraries. TextMate grammar notices are embedded in Onix’s syntax resources. Bundled third-party assets retain their own licenses, including Codicons, Lucide, Symbols Nerd Font Mono, and Material file icons. Preserve the corresponding notices when redistributing those assets.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages