# Add Moard to this project

Implement a small, optional Moard Actions integration. Inspect this project and
follow its existing conventions. Reuse actual buttons, command handlers,
permission checks and state. Keep the normal app usable when Moard is absent.
Do not redesign its interface or create a second command system.

## Find the supplied SDK

This is a source preview, not a published npm package. Find the supplied
`sdk/actions` folder or existing local `@moard/actions` dependency. Read its
README, package exports and TypeScript declarations. Use the project's package
manager and lockfile. Install from that local folder only when dependency changes
are authorized. If it is missing, report what is needed; do not fetch a similarly
named package or invent a public download URL.

Identify the stack and start with a small useful set of commands. Websites and
Windows Node/Electron have SDK adapters. Other native stacks have a pipe protocol
and Python reference transport, not a ready-made framework adapter. Report that
boundary rather than substituting an unsupported package or remote server.

## Websites

Import from `@moard/actions/web`, never the Node entry point. For real HTML
buttons, keep the existing handler and add a stable lowercase command ID.
Keep their normal disabled, `aria-disabled` and `aria-pressed` states accurate.
`data-moard-label` can supply a concise stable name when visible text changes.

```html
<button data-moard-command="clip.split" onclick="editor.split()">Split clip</button>
```

```js
import { connectButtons } from '@moard/actions/web';
const moard = connectButtons({ appId: 'com.example.editor' });
window.addEventListener('pagehide', () => moard.dispose(), { once: true });
```

Replace the example appId and handler with this project's stable ID and existing
handler. Bind once per application lifetime. Use normal framework cleanup;
handle remounts and page restoration without duplicate clients. The adapter reads
opted-in buttons, state and click handlers. Custom controls and closed shadow
roots use the command-source interface below. Do not add global click interception.

## Windows Node/Electron and custom command sources

Use `createMoard` from `@moard/actions` in the trusted Windows Node/Electron
process with the real owning window handle. Electron renderers use their existing
restricted main-process bridge. Websites use `@moard/actions/web` and omit
`window`. Keep Node APIs out of browser bundles.

```js
const moard = createMoard({
  appId: 'com.example.editor',
  window: editorWindow.getNativeWindowHandle(),
  source: {
    getSnapshot: () => ({
      context: 'timeline',
      actions: {
        'clip.split': {
          label: 'Split clip',
          enabled: editor.canSplit(),
          run: () => editor.split(),
        },
      },
    }),
    subscribe: changed => editor.onCommandStateChanged(changed),
  },
});
editorWindow.once('closed', () => moard.dispose());
```

The editor methods above stand for the app's own methods, not SDK APIs. Map the
actual registry. `getSnapshot()` synchronously returns `{ context?, sensitive?,
actions }`. Actions have `label`, `run`, optional `description`, `enabled`
(default true), `voice` (default false), and optional `kind: 'toggle'` with boolean
`active`. `subscribe(changed)` returns an unsubscribe function and uses existing
state-change events; do not add polling. Dispose at normal teardown. React can
use a stable source with `useMoard(createMoard, { appId, source })` from
`@moard/actions/react`. Keep one source, without separate register/publish lists.

## Behavior and privacy

- IDs are stable lowercase command names, never document names or private data.
  Use concise human labels. Read SDK limits: up to 256 definitions and 64 actions
  per snapshot. The preview supports zero-argument presses and toggles.
- Reuse actual availability and handler checks. Omit unavailable commands or set
  `enabled: false`. Do not advertise closed panels or another user's controls.
  An empty actions object is valid. Toggles use `kind: 'toggle'` and `active`, or
  a button's existing boolean `aria-pressed`.
- Voice is optional: `voice: true` or `data-moard-voice="true"`. Opt in suitable
  commands and preserve normal confirmations. Moard's Talk access, context consent
  and protected-control checks still apply.
- Publish command names and availability, not document contents, selected text,
  credentials, transcripts, screenshots or executable arguments. Sources set
  `sensitive: true` during private flows. Websites can mark a present private flow
  `data-moard-sensitive="true"`; password focus also suppresses offers.
- The SDK owns publication, reconnection and request deduplication. Do not queue
  effects for later or treat dispatch as completed work. Keep app permissions and
  handler checks. Do not change Harbor or controller code to integrate an app.

## Connection and review

This local connection needs no developer API key or hosted server. People approve
the app in Harbor. Websites also need the matching Chrome/Edge companion,
registered local host and browser site permission; read the SDK README for
manual preview setup. Editing code does not grant permission or install those
components. Do not silently register a host, change browser permissions, enable
a microphone, deploy, publish or send user data as part of the integration.

Approved commands become available in Harbor's button picker and to Auto;
eligible voice commands can enter Talk. This does not automatically insert
buttons into saved layouts. Saved names do not authorize disconnected commands.

Run the project's relevant existing checks for changed code. Cover actual
availability and cleanup where needed with its normal tools; do not invent a
Moard certification suite. Report changed files, exposed commands, checks run
and remaining SDK/companion/installed-Moard setup. Separate code checks from an
actual installed Moard, phone or voice trial. Leave a focused change ready for
review under the project's commit/merge policy. Code integration does not itself
authorize merging or releasing it.
