omp packages

@zigai/pi-mention-anything0.2.0

Define arbitrary mention sources and triggers for Pi.

zigai Published 8 days ago MIT ~1.7K downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

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.

Option Type Default Description
mentions MentionDefinition[] [] 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