Skip to content

Allowing Access to Additional Context in Custom Commands #1355

Open
@WetHat

Description

@WetHat

Problem Statement

Is your feature request related to a problem? Please describe.

It appears that custom commands currently (Copilot v2.8.7) have only access to {copilot-selection}. For simple commands such as creating summaries of selected text that is sufficient. However, if a command requires access to additional information from the vault context more context specifiers are required. See the specific use case below.

Use Case - Definition of Terms

Provide the definition of a selected term within the context of the active note. If the term has multiple meanings, choose the most relevant definition based on the context provided.

Example: Define the term 'variance' in the context of a note on TypeScript generics.

A prompt to do that would look like this:

</instruction>Define the term given by the text below within the context of {activeNote}.
If the term has multiple meanings, choose the most relevant definition based on the context provided
Format your response as "Term: Definition".
Return only the definition.</instruction>

<text>{copilot-selection}</text>

When run as a custom command, this is returned:

Image

Remarks:

  • Apparently the custom command did not understand the additional context specified via {activeNote}
  • The returned definition of 'variance' does not match the context. It's the definition for data sets.

Expected Behavior

Describe the solution you'd like

The custom command should take the additional context provided by {activeNote} and return this:

Variance: In the context of TypeScript generics, variance refers to how generic types relate to each other
based on the relationships of their type arguments.
Covariance means that if type $A$ is a subtype of type $B$, then a generic type `Container<A>` is
a subtype of `Container<B>`.
Contravariance is the opposite: if type $A$ is a subtype of type $B$, then `Processor<B>`
is a subtype of `Processor<A>`.
TypeScript automatically infers the variance of generic types, but in rare cases,
variance annotations (`in`, `out`, `in out`) can be used to manually specify variance.

The output above was generated by an "Ad-Hoc" prompt with {copilot-selection} replaced by {}. This time the definition of 'variance' is correct in the context of the note where it was used.

Workaround

Describe alternatives you've considered

The obvious way to work around the limitation of custom commands is to use a custom prompt or an ad-hoc prompt instead. While this gives the correct response, it is less convenient.

Suggestion

Additional context

It seems logical to allow the same level of access to additional context as it is provided in ad-hoc or custom prompts:

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions