Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing Access to Additional Context in Custom Commands #1355

Open
WetHat opened this issue Mar 12, 2025 · 2 comments
Open

Allowing Access to Additional Context in Custom Commands #1355

WetHat opened this issue Mar 12, 2025 · 2 comments

Comments

@WetHat
Copy link

WetHat commented Mar 12, 2025

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

@logancyang
Copy link
Owner

cc @zeroliu wdyt?

@zeroliu
Copy link
Collaborator

zeroliu commented Mar 16, 2025

Yeah, that aligns with what we discussed last time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants