跳转到内容

Write a plugin

此内容尚不支持你的语言。

A Ferris IDEA plugin is one WebAssembly module, a .wasm file of at most 16 MiB. Ferris IDEA calls it with JSON and reads JSON back; the plugin never touches the window, the files or the network on its own. Any language that compiles to a WebAssembly module without system imports will do. The plugin interface: Works. There is no SDK or template crate yet; the samples below are the reference.

Export Signature Purpose
memory memory the plugin’s memory, which Ferris IDEA reads and writes
ferris_idea_alloc (len: i32) -> i32 reserves len bytes and returns where; Ferris IDEA writes its input there
ferris_idea_manifest () -> i64 returns the manifest, a UTF-8 JSON text
ferris_idea_run (action_ptr, action_len, input_ptr, input_len: i32) -> i64 runs the action whose id is at action_ptr, on the input at input_ptr, and returns the output

A returned i64 is a pointer in the high 32 bits and a length in the low 32 bits of a UTF-8 text in the plugin’s memory. A negative value means the call failed. The module may import nothing but the host functions described below.

{
"name": "Line Count",
"version": "1.0",
"description": "Status bar sample: lines of the file",
"author": "Your Name",
"actions": [
{ "id": "lines", "title": "Lines", "kind": "status" }
],
"permissions": []
}
  • name, version, description and author are shown when someone installs the plugin. The author is not verified.

  • actions lists what the plugin offers. id is stable within the plugin, title is shown, and kind says how Ferris IDEA uses it (below). An inspect action may restrict itself to file extensions with "files": ["rs", "md"].

  • permissions asks for project-read, suggest-commands or profile-network; the user decides at installation (what they allow).

  • file_types declares file types for highlighting, without code:

    "file_types": [
    { "name": "Ini", "extensions": ["ini", "cfg"], "line_comment": ";",
    "keywords": ["true", "false"], "case_sensitive": false }
    ]

    block_comment takes the opening and closing text, ["/*", "*/"]. A declared type never replaces a language Ferris IDEA knows.

Offsets are counted in characters, lines and columns from 0.

kind When it runs Input Output
replace (default) the user runs it as a command the selection, or the whole text text that replaces it
message the user runs it the selection, or the whole text text shown as a message
edit the user runs it {path, language, text, selection_start, selection_end, line, column} {edits: [{start, end, text}], select: [start, end], message, open: {path, line}}, applied as one undo step
inspect on opening and 600 ms after typing stops {path, language, text} {findings: [{start, end, message, level, fix: {title, edits}}]}; level is error, warning (default) or weak; at most 500
complete with the completion list {path, language, text, offset, prefix} {items: [{label, insert, detail}]}, at most 200
status 300 ms after the caret or text changes as edit {text, tooltip}; the text is cut to 40 characters
panel when the Plugins tool window shows or refreshes {project, active} {rows: [{text, path, line}]}, at most 1,000
run-config when run configurations are listed; needs suggest-commands {project, active} {configs: [{name, program, args, cwd, env}]}, at most 50
connector when a connection of the plugin’s database system is used; needs profile-network a connector request a connector answer

An edit is refused if the text changed while the plugin ran. A run-config may not name a shell (sh, bash, cmd, powershell and others), set DYLD_ or LD_ variables, or use a working folder outside the project, and every run asks the user first.

With the project-read permission granted, the host module ferris-idea gives two functions:

  • list_files() returns the project’s own source files, at most 50,000.
  • read_file(ptr, len) returns the text of the project-relative path at ptr.

They answer -1 without the permission, -2 for a file that does not exist or may not be read, -3 for a file over 4 MiB, -4 when the plugin’s memory runs out, and -5 for a file whose name commonly holds secrets. Version control data, .idea, .ferris-idea, ignored files and symbolic links are never given. Database connectors get net_connect, net_connect_tls, net_connect_starttls, net_send, net_recv and net_close, for the one host and port the user granted.

Each call gets 64 MiB of memory, 4 MiB of input and output, and an instruction budget; extensions that run while the user types (inspect, complete, status) get a fifth of it. A plugin that exceeds the budget is stopped with stopped: it ran too long. There is no clock, no file writing and no general network access.

The repository’s tests/plugins/ holds five plugins in WebAssembly text format, each with its built .wasm: a status bar item (status.wat, the manifest above), a completion contributor (complete.wat), a file type (filetype.wat), a tool window section (panel.wat) and a run configuration type (runconfig.wat). They show the exports, the memory handling and the JSON in full.

Put the .wasm file into a project and ask Ferris IDEA what it would install, without installing:

Terminal window
ferris-idea call ~/Projects/my-plugin inspect_plugin_file '{"path":"status.wasm"}'
{
"headline": "Install Line Count 1.0",
"review": {
"kind": "install",
"contributions": ["status bar"],
"permissions": []
}
}

Once installed, run_plugin_action runs one action in the sandbox and prints its output; nothing is written:

Terminal window
ferris-idea call ~/Projects/my-plugin run_plugin_action '{"action":"Plugin.line-count.lines","path":"notes.txt"}'
{ "kind": "status", "result": { "text": "Lines: 4", "tooltip": "Lines of the file (status sample)" } }

The action id is Plugin.<file name>.<action id>, as plugins lists it. Tested with v1.6.0 on 2026-12-04.

Hand out the .wasm file. The package format .idcplugin is reserved for later and not available yet; there is no marketplace and no signing.

  • inspect_plugin_filereadsInspect a plugin module (.wasm) of the workspace without installing it: its manifest, what it contributes, the permissions it asks for and whether they are granted, and what installing it would do against the installed plugins (install, update, reinstall or downgrade with the installed version, or replace with from_name and from when a different plugin — another manifest name — is installed under the same file name; grants carry over only to the same plugin, so granted is false for install and replace).
  • plugin_file_typereadsThe plugin file type of a workspace file: the plugin and file type that highlight it (none when Ferris IDEA has a language of its own for the file), its line comment, and the highlighted runs with 0-based line, column, character range and kind (comment, string, number, keyword).
  • plugin_inspectionsreadsRun the inspections installed plugins offer for a workspace file: each plugin inspect action whose files match, in the plugin's sandbox with the inspection budget; findings with action, 0-based line and column, character range, message, level and quick fix (edits in characters), and the errors of plugins that failed.
  • pluginsreadsInstalled plugins (sandboxed WebAssembly modules): name, version, description, file, actions, extensions, file_types, requested and granted permissions, files that failed to load, and disabled ones.
  • run_plugin_actionreadsRun a plugin action in its sandbox (no network or clock, limited memory) and return its output: replacement text or message for input; for edit on path with a selection, its edits and the edited text; complete items at offset; status text; panel rows.