Skip to content

Vibe coding a plugin? Teach your agent Modlumi first. Works with Claude Code, Codex, Cursor and more.

PluginFiles

File dialogs, which need the "files.dialog" permission, and the plugin’s data folder.

A command’s run can await a dialog: the run finishes while the dialog is up and continues when the user answers. A panel’s or dialog’s button starts one without awaiting it, by calling an async function or with then; the rest runs when the user answers, and a failure then shows as the plugin’s message:

async function exportCsv() {
const file = await context.files.save({ name: "parts.csv" });
file?.writeText(toCsv(parts));
}
context.showDialog({ id: "parts", title: "Parts", draw(ui) {
if (ui.button("Export CSV")) exportCsv();
} });
context.registerCommand({
id: "export",
title: "Export CSV",
async run() {
const file = await context.files.save({ name: "faces.csv", filters: [{ name: "CSV", extensions: ["csv"] }] });
if (file) {
file.writeText("kind,count\nface,12\n");
}
},
});

readonly data: PluginDataFiles

open(options?): Promise<PluginFile | null>

Asks the user for a file to open, and resolves with it, or null when they cancel. The dialog shows after the plugin’s code for this frame; a command that awaits it finishes, and continues once the user answers. When another model opens first, the promise rejects with a ReferenceError, and the code that runs for it can’t reach the model open now.

FileDialogOptions

Promise<PluginFile | null>


save(options?): Promise<PluginFile | null>

Asks the user where to save, like open; the plugin may then write that file.

FileDialogOptions

Promise<PluginFile | null>