MCPcopy Index your code
hub / github.com/arlyon/litehouse

github.com/arlyon/litehouse @v0.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.1 ↗ · + Follow
389 symbols 799 edges 100 files 40 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

litehouse

An experimental replacement for home-assistant using webassembly and wit components. Using wit bindgen, plugins can be written in any language that can compile to webassembly.

The result is a lightweight core for home automation that can be extended with plugins written in any language. In addition, plugins may depend on other plugins, allowing for a modular architecture, though there is not a reference implementation for that yet.

Building

Plugins can be written in any language and compiled to webassembly. Currently, wit bindgen supports a few guest languages namely rust, c/c++, java, and tinygo. The reference plugins and server are rust-based. Building the server is as simple as running cargo install in the server directory.

cargo install --git https://github.com/arlyon/litehouse litehouse

You can use litehouse to search for, build, fetch, and publish plugins. The fetch command reads the imports from your settings and fetches matches plugins from the registry. The build command compiles a local plugin to a given path.

litehouse build weather
litehouse search weather
litehouse fetch

The weather plugin weighs in at about 200KB, and the tasmota at 300KB.

Running

The server can be run with the litehouse run command. It will read the plugin instances from your local settings.json file, and instantiate one for each of them. The server will then call the update function on each of them at the interval specified in the plugin's subscribe function.

First, let's set up a settings file, and a schema file.

litehouse init && litehouse generate

Next, we should add some plugins to the import field in settings.json.

{
  "$schema": "schema.json",
- "plugins": {}
+ "plugins": {},
+ "imports": ["weather", "tasmota", "samsung"]
}

From there, we can fetch the plugins from the registry, and re-run the generate command to update the schema file.

litehouse fetch
litehouse generate

Finally, we can validate the settings file and run the server. Editors with a jsonschema language server will provide validation and autocompletion for the settings file as you type.

litehouse validate
litehouse run

Protocol

The basic protocol is defined in crates/plugin-macro/wit/plugin.wit, the core of which being the 'runner' interface. This is the interface the server uses to run your plugin. For now, it will simply call the update function at an interval specified by the plugin in the subscribe function. In the future, you will be able to subscibe to events from other plugins, and the server will call your update function when those events occur.

The module also provides an update global, which your plugin can use to send events to the server at any time.

Capabilities

The server provides native implementations for a number of capabilities, the primary one (used in both reference plugins) being wasi:http/outgoing-handler. Plugins may use this to make http requests, which are served using the server's native http client, meaning plugins do not need to bundle heavy dependencies. Other capabilities, such as filesystem, clocks, random numbers, and more are also available but not exposed to plugins yet.

Plugins are completely sandboxed by default, so to allow them to access outside the sandbox, you must award them capabilities by adding them to the capabilities field in your settings file.

{
  "capabilities": [
    "http-client:api.open-meteo.com",
    "http-server:0.0.0.0:8000",
    // (not implemented yet)
    "folder:example",
  ],
}

Extension points exported contracts — how you extend this code

PartitionIOScheme (Interface)
Load orderable partitions from some source. [3 implementers]
crates/registry/src/io/mod.rs
InputProps (Interface)
(no doc)
site/components/ui/input.tsx
Entry (Interface)
(no doc)
crates/registry-js/index.d.ts
IndexIOScheme (Interface)
Load an index from some source. [3 implementers]
crates/registry/src/io/mod.rs
SheetContentProps (Interface)
(no doc)
site/components/ui/sheet.tsx
PartitioningScheme (Interface)
A partitioning scheme for the registry. Accepts lowercase a-z, hyphens, and underscores. [1 implementers]
crates/registry/src/partition_scheme.rs
ButtonProps (Interface)
(no doc)
site/components/ui/button.tsx
GetCache (Interface)
(no doc) [2 implementers]
crates/registry/src/lib.rs

Core symbols most depended-on inside this repo

cn
called by 38
site/lib/utils.ts
create
called by 15
crates/litehouse/src/runtime.rs
fetch
called by 13
crates/litehouse/src/cmd/packages.rs
read
called by 12
crates/opendal-fs-cache/src/lib.rs
write
called by 12
crates/opendal-fs-cache/src/lib.rs
file_name
called by 10
crates/litehouse-config/src/import.rs
get
called by 8
crates/registry/src/lib.rs
open
called by 8
crates/registry/src/io/s3.rs

Shape

Function 146
Method 145
Class 66
Enum 20
Interface 12

Languages

Rust75%
TypeScript25%

Modules by API surface

crates/registry/src/lib.rs26 symbols
plugins/samsung/src/lib.rs21 symbols
crates/litehouse-config/src/lib.rs21 symbols
crates/registry/src/registry.rs17 symbols
crates/registry/src/partition.rs17 symbols
crates/litehouse-config/src/import.rs17 symbols
crates/registry/src/partition_scheme.rs16 symbols
crates/opendal-fs-cache/src/lib.rs16 symbols
crates/litehouse/src/runtime.rs15 symbols
plugins/tasmota/src/lib.rs12 symbols
crates/litehouse/src/store.rs11 symbols
plugins/weather/src/lib.rs7 symbols

For agents

$ claude mcp add litehouse \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact