Skip to content

Support loading extensions with command name conflicts #1061

@jc

Description

@jc

What do you want to change?

Add support for overriding command names, and automatically resolving command name conflicts.

Why?

Extensions are great but they tend to use common verbs/nouns for commands resulting in extensions not loading:

[Extension issues]
  user ~/projects/mitsuhiko-agent-stuff/pi-extensions/review.ts
    Command "/review" conflicts with /Users/james/projects/tmustier-pi-extensions/files-widget/index.ts
  auto (project) ~/projects/pi-mono/.pi/extensions/diff.ts
    Command "/diff" conflicts with /Users/james/projects/tmustier-pi-extensions/files-widget/index.ts

How? (optional)

Here are three cases we could support:

  1. Overriding individual commands: tmustier-pi-extensions/files-widget/index.ts review -> review-tui
  2. Prefixing all commands in an extension: tmustier-pi-extensions/files-widget/index.ts prefix files: -> files:review, files:diff, files:files.
  3. Automatically disambiguating based on extension name when there is a conflict: tmustier-pi-extensions/files-widget/index.ts -> files-widget:review, files-widget:diff

Locally to unblock myself, I wired it into a new top-level setting:

  "commandMappings": [
    {
      "extensionPath": "~/projects/mitsuhiko-agent-stuff/pi-extensions/review.ts",
      "map": {
        "review": "agent-review",
        "status": "agent-status"
      }
    },
    {
      "extensionPath": "~/projects/tmustier-pi-extensions/files-widget/index.ts",
      "prefix": "files:"
    }
  ]

But you could see this being pushed into the extension specification in extensions and packages.extensions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions