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

@gonk/extension-spec

v0.3.1

Published

Declarative extension spec — slash commands, settings TUIs, presets, and tools as data. Host-agnostic.

Downloads

533

Readme

@gonk/extension-spec

Declarative extension definition — slash commands, settings, presets, and tools as pure data. Host-agnostic.

Shape

interface ExtensionSpec {
  id: string;
  description: string;
  tools?: ToolDefinition[];
  command?: SlashCommandSpec;   // single slash command with subcommands
  settings?: SettingsSpec;      // drives set subcommand + TUI
  presets?: PresetsSpec;        // drives preset subcommand
  hooks?: Record<string, HookHandler>;
}

The spec is data. A runtime (e.g. @gonk/extension-spec-pi) consumes it and wires everything up.

Slash commands

A spec declares one command with named subcommands. The runtime auto-injects set, preset, and config subcommands when the corresponding spec sections are present. User-defined verbs in subcommands override or extend those.

noArgs controls what happens when the command is invoked bare: "tui" (default), "status", "help", or a custom handler function.

Settings

interface SettingsSpec {
  scopeKeyPrefix: string;   // prepended by the set subcommand
  sections: SettingsSection[];
  defaultSetTier?: ScopeName;
}

Each item has a type discriminant (string | number | boolean | enum | text | model | provider | voice | custom) that drives both TUI rendering and set parsing.

keyedBy — the indirection primitive

A setting item can declare keyedBy to store its value in a Record keyed by another setting's resolved value:

{
  key: "voice.tts.voice-by-model",
  label: "Voice",
  type: { kind: "voice" },
  keyedBy: {
    source: "voice.tts.model",   // index into the map
    mapKey: "voice.tts.voice-by-model",
  },
}

Read: scope.get(mapKey)?.[scope.get(source)]. Write: merges { [sourceValue]: newValue } into the map. The TUI renders a [for: <sourceValue>] hint. Without keyedBy, the value lives at key directly.

Presets

PresetsSpec lists fields (scope key → preset field name). The auto-generated preset save/apply/list/delete subcommands snapshot and restore those keys at configurable tiers.

Conditional verbs

SubcommandSpec accepts an optional requires?: () => boolean predicate:

{
  name: "listen",
  requires: () => Boolean(scope.get("voice.stt.providers")),
  handler: async (ctx) => { /* ... */ },
}

Filtered at handler-build time by buildCommandHandler (used by both @gonk/extension-spec-pi and @gonk/extension-spec-cli). Verbs whose predicate returns false are dropped from the verb table — they are not routed, not shown in help, and not passed to the TUI. Use this to hide subcommands that depend on optional configuration (e.g., mic capture requires a configured STT provider).

Entry points

import type { ExtensionSpec, SettingsItem, KeyedByConfig } from "@gonk/extension-spec";
import type { SlashCommandSpec, SubcommandContext } from "@gonk/extension-spec/types";

The package is types-only at runtime — no side effects, no I/O.