← Catalog

@zigai/pi-mention-anything

Define arbitrary mention sources and triggers for Pi.

Extension

Install

Install with PiG

pig install npm:@zigai/pi-mention-anything

Install with Pi

pi install npm:@zigai/pi-mention-anything
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.2.0 (README.md). PiG does not review it.

Pi Mention Anything

Custom mention pickers for Pi, from simple lists to chained selections. Available through settings and a TypeScript API.

Install

pi install npm:@zigai/pi-mention-anything

Selections become mentions in the editor and expand into context for the model. Chained selections open successive pickers.

Configuration

Global settings are stored in ~/.pi/agent/extension-settings/pi-mention-anything.json.

OptionTypeDefaultDescription
mentionsMentionDefinition[][]Mention sources enabled in Pi.

Defaults

{
  "$schema": "./schemas/pi-mention-anything.schema.json",
  "mentions": []
}

Advanced example

{
  "$schema": "./schemas/pi-mention-anything.schema.json",
  "mentions": [
    {
      "id": "environments",
      "trigger": "%",
      "completionSuffix": " ",
      "source": {
        "type": "static",
        "items": [
          {
            "name": "staging",
            "description": "Staging environment"
          },
          {
            "name": "production",
            "description": "Production environment"
          }
        ]
      },
      "initialSuggestions": {
        "strategy": "frecency",
        "pinned": []
      }
    },
    {
      "id": "tickets",
      "trigger": "ticket:",
      "completionSuffix": " ",
      "source": {
        "type": "command",
        "mode": "array",
        "command": "list-my-tickets",
        "args": [
          "--json"
        ],
        "cache": true,
        "refreshOnStartup": true,
        "cacheTtlMs": 300000
      },
      "initialSuggestions": {
        "strategy": "frecency",
        "pinned": []
      }
    }
  ]
}

TypeScript API

registerMention connects a provider to Pi’s pickers and context expansion:

import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { createListProvider, registerMention } from "@zigai/pi-mention-anything/api";

export default function (pi: ExtensionAPI): void {
  registerMention(pi, {
    id: "environments",
    configuration: () => ({ trigger: "%" }),
    provider: () => createListProvider(async () => [
      { id: "staging", label: "Staging", segment: "staging", selectable: true, navigable: false, replacement: "environment:staging" },
      { id: "production", label: "Production", segment: "production", selectable: true, navigable: false, replacement: "environment:production" },
    ]),
  });
}

Documentation

License

MIT