New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@systemlabs/foundation-plugin-sdk

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@systemlabs/foundation-plugin-sdk

SDK for building custom plugins and modules for the Foundation ecosystem.

latest
Source
npmnpm
Version
0.3.1
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

@systemlabs/foundation-plugin-sdk

The public contract for building Foundation CLI plugins and modules.

This package contains zero runtime dependencies beyond AJV for schema validation. It is the only package you need to import when authoring a plugin — it defines all types, the manifest schema, and the validateManifest() helper.

npm install @systemlabs/foundation-plugin-sdk

What's in this package

ExportDescription
PluginDefinitionTop-level type you export from your plugin entry point
ModuleManifestFull manifest schema interface
validateManifest()Validates a manifest object against the JSON Schema
All hook typesOnRegisterHook, OnFinalizeHook, OnGenerateHook, etc.
ORMModelDefinitionProvider-agnostic model format for ORM integration
ORMRelationDefinitionRelation type (many-to-one, one-to-many, etc.)
FileEntry, ConfigPatchFile and config contribution types

Defining a plugin

import type { PluginDefinition } from '@systemlabs/foundation-plugin-sdk';

const plugin: PluginDefinition = {
  manifest: {
    id:          'my-plugin',
    name:        'My Plugin',
    version:     '1.0.0',
    category:    'addon',
    description: 'Does something useful.',
    runtime:     'node',
    provides:    ['my-plugin:client'],
    requires:    [],
    dependencies: [
      { name: 'some-package', version: '^2.0.0', dev: false }
    ],
    files: [
      { path: 'src/my-plugin/client.ts', template: 'client.ts.ejs' }
    ],
    configPatches: [],
    compatibility: {},
  },

  hooks: {
    onFinalize: async (ctx) => {
      ctx.logger.info('my-plugin installed — add YOUR_API_KEY to .env');
    },
  },
};

export default plugin;

Manifest fields

interface ModuleManifest {
  id:          string;                  // unique, kebab-case
  name:        string;                  // human-readable
  version:     string;                  // semver
  category:    ModuleCategory;          // see below
  description: string;
  runtime?:    'node' | 'python' | 'multi';
  provides?:   string[];               // capability tokens this module satisfies
  requires?:   string[];               // capability tokens this module needs
  dependencies:   PackageDependency[];
  files:          FileEntry[];
  configPatches:  ConfigPatch[];
  compatibility: {
    conflicts?:       string[];         // module IDs that cannot coexist
    compatibleWith?:  Record<string, string[]>;
    peerFrameworks?:  Record<string, string>;
  };
}

type ModuleCategory =
  | 'frontend' | 'backend' | 'database' | 'orm'
  | 'auth'     | 'ui'      | 'state'    | 'deployment'
  | 'addon'    | 'generate'| 'testing'  | 'tooling';

Lifecycle hooks

Your plugin can export any of these hooks from the hooks key:

HookFires when
onRegisterRegistry loads your plugin — register ORM providers here
onBeforeComposeBefore template rendering — inject dynamic template variables
onAfterTemplateAfter render, before file merge — post-process rendered files
onMergeDuring config merge — supply custom merge logic
onAfterComposeAfter all files are staged — cross-module wiring
beforeWriteBefore the file-write transaction commits
afterWriteAfter the file-write transaction commits
beforeInstallBefore the package manager runs
afterInstallAfter package installation completes
onFinalizeAfter full success — print post-install instructions
onRollbackOn any failure — clean up side-effects
onGenerateBefore generator writes files — extend generated output
onStartWhen foundation dev is invoked
onBuildWhen foundation build is invoked

Validating a manifest

import { validateManifest } from '@systemlabs/foundation-plugin-sdk';

const result = validateManifest(myManifest);
if (!result.valid) {
  console.error(result.errors);
}

ORM integration

If your plugin contributes a model to the active ORM, use the portable model format — the active ORM provider will translate it to provider-specific output automatically:

hooks: {
  onRegister: async (ctx) => {
    ctx.registry.orm.registerModel({
      id:   'my-plugin.Record',
      name: 'Record',
      fields: [
        { name: 'id',        type: 'uuid',   primaryKey: true, generated: true },
        { name: 'payload',   type: 'string', required: true },
        { name: 'createdAt', type: 'date',   generated: true },
      ],
      relations: [],
    }, 'my-plugin');
  },
}

Publishing a plugin to npm

Your plugin package must include foundation-plugin in its keywords array so foundation search can discover it:

{
  "name": "foundation-plugin-my-plugin",
  "keywords": ["foundation-plugin"]
}

Install it in any Foundation project with:

foundation add foundation-plugin-my-plugin

Part of the Foundation CLI ecosystem

PackageDescription
@systemlabs/foundation-cliUser-facing CLI — foundation create, add, generate, etc.
@systemlabs/foundation-coreEngine: dependency resolver, composition planner, file transaction
@systemlabs/foundation-modulesAll built-in modules (frontend, backend, database, auth, …)
@systemlabs/foundation-plugin-sdk← you are here — plugin contract, types, manifest schema
@systemlabs/foundation-testingTest utilities for module and plugin authors

License

MIT — see LICENSE

Keywords

cli

FAQs

Package last updated on 25 Mar 2026

Related posts