npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@silexlabs/grapesjs-ai-capabilities

v0.0.3

Published

Discovery and metadata layer for GrapesJS commands, enabling MCP tool exposure and external integrations

Readme

GrapesJS AI Capabilities

Discovery and metadata layer for GrapesJS commands. Sits between plugins that expose capabilities and builders that consume them (MCP servers, AI agents, chat interfaces, etc.).

This code is part of a bigger project: about Silex v3

SLM-first philosophy

This plugin is designed for small language models (SLMs) — models that are cheap to run, can run locally, and have a small context window. We believe local-first AI is better for carbon footprint, privacy, and cost.

The strategy: keep capability descriptions minimal. An SLM discovers available tools through short descriptions, then learns the details from error messages when it gets parameters wrong. This means:

  • Descriptions are terse (e.g. "List CSS variables", "Set CSS variable")
  • Input schemas list only the required parameters with their types
  • Error messages are actionable (e.g. "Required: name, value, type (color|size|typo)")
  • No verbose system prompts needed — the tool list itself fits in a small context

This approach works because SLMs are iterative: they try, fail, read the error, and try again. A 500-token tool description wastes context; a 5-word description plus a clear error on misuse teaches faster.

Use case 1: Expose capabilities to AI

You're a plugin author and want your GrapesJS commands to be discoverable by AI tools.

Listen for the ai-capabilities:ready event during your plugin init. No import needed — if the ai-capabilities plugin isn't loaded, the event never fires and nothing happens:

// In your plugin's init function
export default (editor, opts) => {
  // ... your plugin setup ...

  editor.on('ai-capabilities:ready', (addCapability) => {
    addCapability({
      id: 'css-var:set',
      command: 'css-var:set',
      description: 'Set CSS variable',
      inputSchema: {
        type: 'object',
        required: ['name', 'value', 'type'],
        properties: {
          name: { type: 'string' },
          value: { type: 'string' },
          type: { type: 'string', enum: ['color', 'size', 'typo'] },
        },
      },
      tags: ['css'],
    })
  })
}

Keep descriptions short. Put the detail in inputSchema and in your command's error messages.

Use case 2: Implement an MCP server (or other AI integration)

You're a builder and want to expose GrapesJS capabilities as MCP tools, API endpoints, or chat actions.

Import the query functions to read the registry and map capabilities to your integration:

import { getAllCapabilities } from '@silexlabs/grapesjs-ai-capabilities'

// Get all registered capabilities as MCP tool definitions
const capabilities = getAllCapabilities()

for (const cap of capabilities) {
  mcpServer.addTool({
    name: cap.id,
    description: cap.description,
    inputSchema: cap.inputSchema,
    execute: (params) => editor.runCommand(cap.command, params),
  })
}

Execution always goes through editor.runCommand() — this plugin does not implement run().

API reference

The plugin keeps a single global registry. Query functions don't need the editor.

addCapability(def, options?)

Register a capability. Returns the capability object. Throws on validation errors.

Pass { replace: true } as third argument to overwrite an existing capability.

getCapability(id)

Returns the capability object. Throws if not found.

getAllCapabilities(filter?)

Returns an array of capabilities. Optional filter: { tags: ['css'] }.

removeCapability(id)

Returns true if removed, false if not found.

hasCapability(id)

Returns true or false.

clearCapabilities()

Clears the registry. Useful for tests.

Event: ai-capabilities:ready

Fired on editor.on('load'). The callback receives the addCapability function.

Install

npm i @silexlabs/grapesjs-ai-capabilities

License

GPL-3.0