diff --git a/Assistant.md b/Assistant.md new file mode 100644 index 0000000..15ce2bb --- /dev/null +++ b/Assistant.md @@ -0,0 +1,485 @@ +# Assistant Guide + +This file is a concise, assistant-facing guide for working with `@anikitenko/fdo-sdk`. +It is intended for Mintlify or other docs surfaces that need one high-signal overview instead of many separate internal documents. + +## What This SDK Is + +`@anikitenko/fdo-sdk` is an SDK for building FDO desktop application plugins. + +The SDK spans two runtimes: + +- Backend/plugin runtime + - plugin class lifecycle + - handler registration + - storage + - logging + - host IPC +- Iframe UI runtime + - UI returned by `render()` + - browser DOM access + - host-injected helpers and UI libraries + - sandboxed iframe execution managed by FDO + +The most important rule is: plugin backend logic and plugin UI logic do not run in the same environment. + +## Core Mental Model + +Treat `render()` output as UI source for the FDO iframe render pipeline, not as arbitrary raw HTML inserted directly into the host page. + +That means: + +- `render()` must synchronously return a string +- `renderOnLoad()` may synchronously return: + - a string + - a function + - a `defineRenderOnLoad(...)` payload +- FDO serializes and transports these pieces separately +- UI code runs later inside a sandboxed iframe + +If you are generating UI with SDK DOM helpers and expect helper-generated styles to work, you must wrap the final helper output with `renderHTML(...)`. + +## Start Here + +Recommended order for understanding and building plugins: + +1. Read `README.md` +2. Read `docs/RENDER_RUNTIME_CONTRACT.md` +3. Read `docs/SAFE_PLUGIN_AUTHORING.md` +4. Read `docs/EXTENSION_POINTS.md` +5. Study `examples/fixtures/minimal-plugin.fixture.ts` +6. Then move to numbered examples in `examples/` + +## Minimal Plugin Shape + +Every plugin should provide: + +- `metadata` +- `init()` +- `render()` + +Typical shape: + +```ts +import { FDO_SDK, FDOInterface, PluginMetadata } from "@anikitenko/fdo-sdk"; + +export default class MyPlugin extends FDO_SDK implements FDOInterface { + private readonly _metadata: PluginMetadata = { + name: "My Plugin", + version: "1.0.0", + author: "Your Name", + description: "Plugin description", + icon: "cog", + }; + + get metadata(): PluginMetadata { + return this._metadata; + } + + init(): void { + this.info("plugin initialized"); + } + + render(): string { + return `