Script extensions

Stub. Final API may shift slightly as the SDK lands.

Apps may register macros at install time. Macros expand client-side inside @yapture/nlp before core parsing runs, so they can only inject tokens — never remove them.

Signature

interface ScriptMacro {
  pattern: string | RegExp;
  expand(input: string, ctx: { user: User; app: AppManifest }): string;
}

Examples

yapture.script.registerMacro({
  pattern: '#workout',
  expand: () => '#~workout',
});

yapture.script.registerMacro({
  pattern: /^PR:(\d+)/,
  expand: (m) => `#^pr:#*{value:${m[1]}}`,
});

Conflict resolution

Two apps registering the same pattern is a hard error at install time — the second app’s install fails with an actionable message. Users pick which app owns a macro.