← Catalog

pi-typed-args

Typed input definitions for Pi slash commands and Agent Skills — parsing, completions, help, and forms from a single definition.

Extension

Install

Install with PiG

pig install npm:pi-typed-args

Install with Pi

pi install npm:pi-typed-args
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.

README

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

Pi Typed Args

Pi Typed Args is a TypeScript library for adding typed inputs to Pi slash commands and Agent Skills. A single argument definition drives parsing, validation, completion hints, generated help, live usage hints, and TUI input forms instead of hand-parsed raw strings.

Install

Run just setup in a local pi-tweaks checkout, then add its library to the package that contains your Pi extension:

npm install /path/to/pi-tweaks/packages/pi-typed-args

Or add it manually to your extension package manifest:

{
  "dependencies": {
    "pi-typed-args": "file:/path/to/pi-tweaks/packages/pi-typed-args"
  }
}

Then import it from your extension code:

import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { defineTypedCommand, registerTypedCommand } from "pi-typed-args";

const deploy = defineTypedCommand({
  name: "deploy",
  description: "Deploy a ref",
  args: {
    env: {
      type: "enum",
      values: ["dev", "staging", "prod"],
      position: 0,
      required: true,
      description: "Target environment",
    },
    ref: {
      type: "string",
      default: "main",
      description: "Git ref",
    },
    dryRun: {
      type: "boolean",
      description: "Preview only",
    },
  },
  async run({ env, ref, dryRun }, ctx) {
    ctx.ui.notify(`Deploy ${ref} to ${env}; dryRun=${String(dryRun)}`);
  },
});

export default function extension(pi: ExtensionAPI): void {
  registerTypedCommand(pi, deploy);
}

Users of your extension can then run:

/deploy staging --ref feature/login --dry-run
/deploy<Tab>       # open the argument form
/deploy --help     # show generated help

While users type a command, Pi shows a compact live helper above the editor by default with parsed values, defaults, and remaining arguments. Tab completes unambiguous partial flags and fixed choices—for example, /deploy --r<Tab> becomes /deploy --ref and /branch --layout sepa<Tab> becomes /branch --layout separate —or opens the form when there is nothing to complete. Inline validation waits until the user moves past an argument or submits the command, so value-taking flags do not error while their value is still being typed.

Commands can opt into visual-only ghost text on the same editor line. It appears after an exact command or subcommand invocation, remains through one trailing space, and disappears when the user types a second space or starts an argument:

const deploy = defineTypedCommand({
  name: "deploy",
  description: "Deploy a ref",
  ghostText: ({ ctx }) => `choose a target in ${ctx.cwd}`,
  args: {},
  run() {},
});

The ghost text is dimmed presentation; it is never added to the submitted editor value. Omitting ghostText leaves the editor unchanged.

If you compose the Pi UX bridge yourself, move the helper below the input editor with:

import { installTypedCommandUx } from "pi-typed-args";

installTypedCommandUx(pi, { helperPlacement: "belowEditor" });

Configuration

Use global config at ~/.pi/agent/pi-typed-args/config.json.

OptionDefaultPurpose
helperPlacement"aboveEditor"Place the live helper above or below the input editor.
appearance.form.colors.title"accent"Color the dense form title.
appearance.form.colors.focusedLabel"accent"Color the focused field label.
appearance.form.colors.focusedValue"accent"Color the focused field value.
appearance.form.colors.unsetValue"muted"Color unset field values.
appearance.form.colors.description"dim"Color field descriptions.
appearance.form.colors.instructions"dim"Color form instructions.
appearance.form.colors.issue"warning"Color validation issues.
appearance.form.colors.editorBorder"accent"Color the form editor border.
appearance.form.colors.selectedOption"accent"Color selected checkbox and radio options.
appearance.form.symbols.focusedField"›"Mark the focused field.
appearance.form.symbols.selectedCheckbox"■"Mark selected checkboxes.
appearance.form.symbols.unselectedCheckbox"□"Mark unselected checkboxes.
appearance.form.symbols.selectedRadio"●"Mark selected radio options.
appearance.form.symbols.unselectedRadio"○"Mark unselected radio options.
appearance.form.layout.leftPadding1Set dense form left padding.
appearance.form.layout.fieldGap1Set the gap between field labels and values.
appearance.form.layout.minNameWidth12Set the minimum field-name column width.
appearance.form.layout.maxNameWidth24Set the maximum field-name column width.
appearance.form.layout.minValueWidth12Set the minimum field-value column width.
appearance.form.layout.maxValueWidth32Set the maximum field-value column width.
appearance.form.layout.descriptions"inline"Show descriptions inline, focused, or hidden.
appearance.form.layout.instructions"full"Show full, short, or hidden instructions.
appearance.inlineHelp.layout"compact"Use the compact live-helper layout.
appearance.inlineHelp.choiceDisplay"contextual"Show fixed choices contextually or inside tokens.
appearance.inlineHelp.order"active-required-available"Order active, required, and available tokens.
appearance.inlineHelp.metadata.typesfalseShow type metadata in the live helper.
appearance.inlineHelp.metadata.defaultstrueShow default values in the live helper.
appearance.inlineHelp.metadata.requiredfalseShow required markers in the live helper.
appearance.inlineHelp.metadata.aliasesfalseShow aliases in the live helper.
appearance.inlineHelp.metadata.descriptionsfalseShow descriptions in the live helper.
appearance.inlineHelp.metadata.enumValuestrueShow enum values in the live helper.
appearance.inlineHelp.colors.active"accent"Color active argument tokens.
appearance.inlineHelp.colors.required"warning"Color required argument tokens.
appearance.inlineHelp.colors.available"dim"Color available argument tokens.
appearance.inlineHelp.colors.type"syntaxType"Color type hints.
appearance.inlineHelp.colors.metadata"muted"Color metadata tokens.
appearance.inlineHelp.colors.issue"error"Color live-helper issues.
appearance.inlineHelp.format.tokenPrefix"["Prefix each live-helper token.
appearance.inlineHelp.format.tokenSuffix"]"Suffix each live-helper token.
appearance.inlineHelp.format.groupSeparator" "Separate token groups.
appearance.inlineHelp.format.itemSeparator" "Separate items within token groups.
appearance.inlineHelp.format.typeSeparator":"Separate names from type hints.
appearance.inlineHelp.format.valueSeparator"="Separate names from values.
appearance.detailedHelp.metadata.typestrueShow types in generated help.
appearance.detailedHelp.metadata.defaultstrueShow defaults in generated help.
appearance.detailedHelp.metadata.requiredtrueShow required markers in generated help.
appearance.detailedHelp.metadata.aliasesfalseShow aliases in generated help.
appearance.detailedHelp.metadata.descriptionstrueShow descriptions in generated help.
appearance.detailedHelp.metadata.enumValuestrueShow enum values in generated help.
appearance.detailedHelp.order"definition"Order arguments by definition or required-first.
{
  "$schema": "./config.schema.json",
  "helperPlacement": "aboveEditor",
  "appearance": {
    "form": {
      "colors": {
        "title": "accent",
        "focusedLabel": "accent",
        "focusedValue": "accent",
        "unsetValue": "muted",
        "description": "dim",
        "instructions": "dim",
        "issue": "warning",
        "editorBorder": "accent",
        "selectedOption": "accent"
      },
      "symbols": {
        "focusedField": "›",
        "selectedCheckbox": "■",
        "unselectedCheckbox": "□",
        "selectedRadio": "●",
        "unselectedRadio": "○"
      },
      "layout": {
        "leftPadding": 1,
        "fieldGap": 1,
        "minNameWidth": 12,
        "maxNameWidth": 24,
        "minValueWidth": 12,
        "maxValueWidth": 32,
        "descriptions": "inline",
        "instructions": "full"
      }
    },
    "inlineHelp": {
      "layout": "compact",
      "choiceDisplay": "contextual",
      "order": "active-required-available",
      "metadata": {
        "types": false,
        "defaults": true,
        "required": false,
        "aliases": false,
        "descriptions": false,
        "enumValues": true
      },
      "colors": {
        "active": "accent",
        "required": "warning",
        "available": "dim",
        "type": "syntaxType",
        "metadata": "muted",
        "issue": "error"
      },
      "format": {
        "tokenPrefix": "[",
        "tokenSuffix": "]",
        "groupSeparator": "  ",
        "itemSeparator": " ",
        "typeSeparator": ":",
        "valueSeparator": "="
      }
    },
    "detailedHelp": {
      "metadata": {
        "types": true,
        "defaults": true,
        "required": true,
        "aliases": false,
        "descriptions": true,
        "enumValues": true
      },
      "order": "definition"
    }
  }
}

Supported argument types

TypeWhat it is forCommon options
stringText, paths, names, refs, freeform valuesminLength, maxLength, pattern, default, position, rest
numberNumeric valuesinteger, min, max, default
booleanFlags and toggles--flag, --flag true, --no-flag, default
enumOne value from a fixed setvalues, optionDescriptions, default, position
multi-enumReadonly multiple values from a fixed setrepeated flags, comma-separated values, no commas in values
string-listReadonly freeform string valuesrepeated flags, comma-separated values, minItems, maxItems
key-valueReadonly string recordrepeated key=value entries, minItems, maxItems
group()Nested handler objects with flat CLI flagsgroup({ host, port }) becomes flags like --database-host

All argument definitions can also use common metadata such as description, title, required, flag, aliases, placeholder, occurrence, complete, completionTimeoutMs, and ui.

Commands may define CLI-style subcommands; each branch owns its arguments, refinement, form metadata, aliases, and typed handler while inheriting shared root flags. The helper, completion engine, generated help, parser, serializer, and expanded form all switch to the selected branch.

Documentation

License

MIT