FS
Plugin-scoped filesystem access backed by main-process permission checks and a per-plugin path allowlist. Requires filesystem:pick for open/save dialogs, filesystem:read for readFile, and filesystem:write for writeFile / writeBytes. User-selected paths from pick/save dialogs are added to the allowlist automatically; the plugin package directory is allowlisted on load. User-granted paths persist across app restarts and are restored when the plugin loads again.
hc.fs.pickDirectory(defaultPath?)
Available since v2.0.0
Signature:(defaultPath?: string) => Promise<string | null>
Opens a native directory picker. Returns the selected directory path, or null when canceled. Requires the filesystem:pick permission.
hc.fs.pickFile(options?)
Available since v2.0.0
Signature:(options?: PluginFsPickFileOptions) => Promise<string[]>
Opens a native file picker. Returns absolute paths for the selected files, or an empty array when the dialog is canceled. Requires the filesystem:pick permission.
const paths = await hc.fs.pickFile({
title: 'Choose a schema',
filters: [{ name: 'JSON', extensions: ['json'] }]
});hc.fs.readFile(path)
Available since v2.0.0
Signature:(path: string) => Promise<string>
Reads a UTF-8 text file from an allowlisted path. Requires the filesystem:read permission.
hc.fs.saveFile(content, options?)
Available since v2.0.0
Signature:(content: string, options?: PluginFsSaveFileOptions) => Promise<string | null>
Opens a native save dialog and writes content to the chosen path. Returns the saved path, or null when canceled. Requires the filesystem:pick and filesystem:write permissions.
hc.fs.writeBytes(path, bytes)
Available since v2.8.10
Signature:(path: string, bytes: Uint8Array) => Promise<string>
Writes binary bytes to an allowlisted path. Relative paths resolve under the plugin package directory. Returns the absolute path written. Requires the filesystem:write permission.
hc.fs.writeFile(path, content)
Available since v2.0.0
Signature:(path: string, content: string) => Promise<void>
Writes UTF-8 text to an allowlisted path. Requires the filesystem:write permission.
