SilverBullet Documentation

repository·main·Indexed 26 days ago

https://github.com/silverbulletmd/silverbullet

A programmable, open-source, self-hosted personal knowledge database. SilverBullet functions as a Markdown editor with live preview, bi-directional linking, a built-in database and query language (SLIQ), and a Space Lua scripting environment. The project consists of a Rust-based server and a TypeScript client, featuring a CLI tool (`sb`) for executing Lua expressions, running SLIQ queries, and managing server logs and configurations.

Tokens
108.9K
Snippets
289
Records
767
Agent score
91%

What's inside SilverBullet

  1. Overview of SilverBullet features

    main

    SilverBullet is a programmable, private, browser-based, open-source, self-hosted personal knowledge database. It functions as a Markdown editor with live preview, wiki-style bi-directional linking, and a built-in database and query language.

    Key capabilities include:

    • Markdown Editing: Clean live-preview editor and outlining tools.
    • Task Management: Integrated task tracking.
    • Database & Queries: Use Objects and Integrated Query Language (SLIQ) to manage data.
    • Programmability: Use Space Lua (a Lua dialect) to dynamically generate content, create custom commands, page templates, or widgets.
  2. Overview of SilverBullet Plugs

    main
    SilverBullet is extended using Plugs, which are built on the PlugOS library. Plugs allow you to add functionality to SilverBullet using TypeScript. Each plug is compiled into a single .plug.js bundle and runs within its own isolated Web Worker sandbox for security and stability. Many of the core features considered "built-in" to SilverBullet are actually implemented as plugs.
  3. Overview of SilverBullet shared code

    main
    The @silverbulletmd/silverbullet package contains SilverBullet-specific code that is shared between the server and the client environments. Developers building extensions or working with the SilverBullet ecosystem can use this package to ensure consistency between client-side and server-side logic.
  4. Overview of the SilverBullet File System and RPC API

    main

    The SilverBullet server provides a file-access and RPC surface accessible via the HTTP API. This surface allows for managing space files and executing system-level tasks. Key capabilities include:

    • File Management: Listing, reading, writing, and deleting files within the space.
    • Shell Execution: Running shell commands through the server.
    • HTTP Proxying: Using the server as an HTTP proxy.
  5. Overview of SilverBullet

    main
    SilverBullet is a programmable, private, browser-based, open-source, self-hosted personal knowledge database. It functions as a Markdown editor with live preview, wiki-style bi-directional linking, a built-in database and query language (SLIQ), and a Space Lua scripting environment. Users can manage content as a collection of Markdown Pages (a 'Space').
  6. Explore Space Lua APIs

    main

    Space Lua is a scripting environment within SilverBullet. The available APIs are categorized into the Lua Standard Library, specific Space Lua APIs, and Syscall APIs. Detailed documentation for these APIs is indexed within the SilverBullet space itself under the following categories:

    • Lua Standard Library: Standard Lua functions available for scripting.
    • Space Lua APIs: APIs specifically designed for interacting with the SilverBullet space.
    • Syscall APIs: Low-level system calls used to extend functionality or interact with the host environment.

    To find the specific documentation for a function or API, search your SilverBullet space for pages tagged with api/lua, api/space-lua, or api/syscall respectively.

  7. Understand Synced Files architecture

    main

    SilverBullet uses a local IndexedDB copy of all [[Space]] files. This local copy is managed by the [[Sync]] engine to keep files in step with the [[Architecture/Server]], which enables full offline access to the workspace. The synchronization logic is distributed across the following components:

    • client/spaces/sync.ts
    • client/service_worker/sync_engine.ts
    • plugs/sync/sync.ts
  8. Identify what a SilverBullet library can provide

    main

    A library in SilverBullet can extend your space with several types of functionality:

    • Slash Commands: Custom commands like /today, /task, or /table.
    • Page Templates: Reusable structures for new pages.
    • Widgets: UI components for your space.
    • Maintenance Pages: Specialized pages for space upkeep (e.g., detecting broken links).
    • Plugs: Additional functionality implemented via compiled [[Plugs]].
  9. Understand the SilverBullet Plug Runtime Model

    main

    SilverBullet plugs are JavaScript bundles (*.plug.js) that export a {manifest, functionMapping} object. They are compiled from a *.plug.yaml manifest and referenced TypeScript files.

    Isolation & Execution:

    • Each plug runs in its own isolated Web Worker sandbox in the browser.
    • Plugs are isolated from the main thread and from other plugs.
    • Plugs cannot access the DOM directly; all interactions with the editor, space, and storage must occur via syscalls.

    Communication Flow:

    • Invoke (Main → Worker): The main thread sends an invoke message to the worker to run a specific function (e.g., when a command, event, or slash command fires).
    • Syscall (Worker → Main): The plug calls globalThis.syscall(name, ...args) to access editor APIs or storage. Developers should use the @silverbulletmd/silverbullet/syscalls package to generate these calls rather than calling globalThis.syscall directly.