feat(plugins): trek-plugin-sdk package — types, mock host, scaffolder, validator (M6)

The author-facing SDK, a standalone dependency-free package (not wired into the
app workspaces, so it can't affect the app build).

- definePlugin + the full plugin type surface (PluginContext, PluginRoute,
  PluginJob, PhotoProvider, CalendarSource) mirroring what the isolated runtime
  injects; PLUGIN_API_VERSION.
- createMockHost (trek-plugin-sdk/testing): a PluginContext that enforces the
  SAME permission model + membership checks, so authors can unit-test that their
  plugin degrades gracefully — no running TREK needed.
- validateManifest: the exact rules the registry CI runs, so a local pass
  predicts a CI pass.
- CLIs: create-trek-plugin (scaffolds a working plugin + README + starter iframe)
  and trek-plugin validate (manifest + README sanity).

Consolidating the server loader to import this shared validator is a follow-up.
This commit is contained in:
mauriceboe
2026-07-03 17:44:55 +02:00
committed by Maurice
parent f61e144e11
commit af73943be8
12 changed files with 2146 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env node
/** `trek-plugin <command>` dispatcher (#plugins, M6). Commands: validate. */
import { validatePluginDir } from './validate.js';
const [cmd, ...rest] = process.argv.slice(2);
if (cmd === 'validate') {
const r = validatePluginDir(rest[0] || '.');
for (const w of r.warnings) console.warn('warning: ' + w);
if (r.ok) {
console.log('✓ plugin is valid');
} else {
for (const e of r.errors) console.error('error: ' + e);
process.exit(1);
}
} else {
console.error('usage: trek-plugin validate [dir]');
process.exit(2);
}