Extensions (interface v0)¶
Unstable. Derived only from what the first extension, deciwa, needs; it
changes with the next extension. No marketplace, no sandbox: an extension runs
with full Node access in the main process, so monsterbrain loads only folders
named in its settings (Settings → Extensions, stored in settings.json).
"extensions": [
{ "path": "/home/daniel/workspace/deciwa/packages/monsterbrain", "options": { "enginePath": "…" } }
]
options is handed to the extension as is; "enabled": false keeps an entry
without loading it. Changes apply after a restart (Restart to apply).
Manifest¶
The extension folder has a package.json with a monsterbrain field:
"monsterbrain": {
"id": "deciwa", "name": "deciwa", "api": 0,
"main": "dist/main.cjs",
"view": "dist/view.js",
"frame": "dist/frame.js"
}
Part |
Runs in |
Loaded |
|---|---|---|
|
main process (Node, CommonJS) |
|
|
the window |
as a script from |
|
rendered HTML pages (sandboxed frames) |
added to the page when monsterbrain shows it ( |
api must match the interface version (EXTENSION_API in
src/shared/extensions.ts); monsterbrain refuses other versions.
Extension points¶
Point |
Main process ( |
Window ( |
|---|---|---|
background process |
|
– |
calls and events |
|
|
view injection |
– |
|
panel section |
– |
|
toolbar |
– |
|
decorations |
|
shown in the tree, the change view and search results |
commands |
– |
|
MCP tools |
|
– |
agent actions |
|
– |
concepts |
|
– |
Also on ctx: root(), open(path, {tab, highlight, newTab}), state(),
log(), options, path.
Views¶
mountView(v) gets every rendered Markdown view and every code view (source with line numbers):
Field |
|
|---|---|
|
file path relative to the open folder |
|
the file kind: |
|
|
|
the Git revision of the |
|
|
|
the content. |
|
the element the content scrolls in ( |
A view is mounted again when its content changes. Keys an extension handles
itself should call preventDefault(); monsterbrain then ignores them.
HTML pages¶
HTML files are shown in a frame with sandbox="allow-scripts allow-popups".
monsterbrain marks every start tag with data-line (the line it starts on, 0-based)
and adds a bridge before the frame scripts:
window.mbx.path (the page’s path), window.mbx.call(id, method, …args) and
window.mbx.on(id, event, cb) – relayed by the window to the extension’s
main part. Any script of the page can send such calls, so they reach only
handlers registered with ctx.handle(method, fn, { frames: true }). Only pages of the working tree get the scripts, not the old side
of a diff.