How sogocze/jails works
Purpose and Entry Points
Jails is an experimental Language Server Protocol (LSP) implementation for Jai. Its native server starts in server/main.jai; build orchestration and release/VS Code development modes are defined in build.jai. The optional editor client is a VS Code extension rooted at vscode_extension/src/extension.ts.
LSP Transport and Dispatch
server/lsp_interface.jai defines the LSP-facing interface and request/notification handling. server/rpc.jai implements the JSON-RPC transport boundary between an editor client and the native server. server/main.jai owns process startup and connects transport, workspace/program state, and language-feature handlers.
Workspace and Program Model
server/program.jai is the central workspace/program representation: it loads configured roots, resolves project structure, and supplies semantic context to requests. server/memory_files.jai maintains editor-open/in-memory document content, separating unsaved buffers from on-disk source. Project behavior is configured through root-level jails.json.
Parsing and Symbol Intelligence
Jails depends on the parser submodule at modules/jai_parser to parse Jai source and underpin symbol-aware features. Symbol extraction and lookup are concentrated in server/symbols.jai, serving requests over workspace and parsed-file state. The server also consumes modules/jaison for JSON handling and modules/unicode_utils for text/unicode support.
Interactive Editor Features
Feature-specific handlers are separated by LSP capability:
• completion: server/completition.jai
• definition navigation: server/goto.jai
• hover information: server/hover.jai
• call signatures: server/signature_help.jai
These handlers receive LSP positions/documents, consult program, parser, and symbol state, then return protocol-shaped responses through the LSP/RPC layer.
Compiler Diagnostics Boundary
server/diagnostics.jai invokes the external Jai compiler to produce editor diagnostics, rather than attempting to duplicate compiler validation. The server discovers Jai via platform commands or a supplied Jai-installation path; diagnostics use configured build_root and optional intermediate_path. metaprogram/jails_diagnostics.jai supports diagnostic-build integration, including a JAILS_DIAGNOSTICS_BUILD mode for custom build programs.
Editor Distribution and Runtime
The primary runtime is a compiled Jai executable. build.jai produces the server binary. The VS Code extension (vscode_extension/src/extension.ts, vscode_extension/package.json) launches/connects to that server and supplies Jai language registration via vscode_extension/syntaxes/jai.tmLanguage.json. Deployment therefore requires a compatible Jails binary and an accessible Jai compiler for compiler-backed diagnostics.
Main entry points: lsp_interface.jai LSP dispatch · symbols.jai Symbol intelligence · program.jai Workspace program · diagnostics.jai Diagnostics handler
Components 20
Build & Distribution
- Build orchestration · Builds the native server and supports release and VS Code development modes.
build.jai - Jails server binary
Native LSP Server
- Server startup · Wires transport, workspace state, and feature handlers.
server/main.jai - JSON-RPC transport · Connects editor messages to the native server.
server/rpc.jai - LSP dispatch · Handles LSP requests and notifications.
server/lsp_interface.jai - Workspace program · Loads roots, resolves projects, and supplies semantic context.
server/program.jai - Open document buffers · Keeps unsaved editor content separate from disk source.
server/memory_files.jai - Project configuration
jails.json
Language Intelligence
- Jai parser · Parses Jai source for symbol-aware features.
modules/jai_parser - Symbol intelligence
server/symbols.jai - Completion
server/completition.jai - Definition navigation
server/goto.jai - Hover information
server/hover.jai - Call signatures
server/signature_help.jai
Compiler Diagnostics
- Diagnostics handler · Invokes Jai rather than duplicating compiler validation.
server/diagnostics.jai - Diagnostics build support · Supports custom build programs and JAILS_DIAGNOSTICS_BUILD mode.
metaprogram/jails_diagnostics.jai - Jai compiler · Discovered through platform commands or a supplied installation path.
VS Code Client
- VS Code extension · Launches or connects to the Jails server.
vscode_extension/src/extension.ts - Extension manifest
vscode_extension/package.json - Jai language grammar
vscode_extension/syntaxes/jai.tmLanguage.json
Connections 24
- Build orchestration → Jails server binary: builds
- Extension manifest → VS Code extension: declares
- Jai language grammar → VS Code extension: language registration
- VS Code extension → Jails server binary: launches/connects
- Jails server binary → Server startup: runs
- Server startup → JSON-RPC transport: owns
- JSON-RPC transport → LSP dispatch: JSON-RPC messages
- LSP dispatch → Workspace program: request context
- Workspace program → Project configuration: loads
- Workspace program → Open document buffers: uses open buffers
- Workspace program → Jai parser: parses source
- Symbol intelligence → Workspace program: workspace state
- Symbol intelligence → Jai parser: parsed source
- LSP dispatch → Completion: completion requests
- LSP dispatch → Definition navigation: definition requests
- LSP dispatch → Hover information: hover requests
- LSP dispatch → Call signatures: signature requests
- Completion → Symbol intelligence: symbol lookup
- Definition navigation → Symbol intelligence: symbol lookup
- Hover information → Symbol intelligence: symbol lookup
- Call signatures → Symbol intelligence: symbol lookup
- LSP dispatch → Diagnostics handler: diagnostic requests
- Diagnostics handler → Jai compiler: invokes
- Diagnostics build support → Diagnostics handler: custom build integration