Skip to content

Conversation

@juliasilge
Copy link
Collaborator

Addresses the last bit of #846, with a new public API that this extension returns for other extensions to use, to get information about the Quarto CLI being used. This is particularly useful for extensions like Quarto Wizard that need to know the path to the Quarto binary, especially when Quarto is bundled in Positron or installed in a Python virtual environment, etc.

The new API exposes three methods:

  • getQuartoPath()
  • getQuartoVersion()
  • isQuartoAvailable()

Other extensions can access this API via vscode.extensions.getExtension('quarto.quarto').exports after copying the interface definition into their own codebase. Since your extension cannot import types from the Quarto extension directly, copy this interface definition into your own codebase:

// Copy this interface into your extension
interface QuartoExtensionApi {
  getQuartoPath(): string | undefined;
  getQuartoVersion(): string | undefined;
  isQuartoAvailable(): boolean;
}

// Then use it like this:
async function getQuartoPathFromExtension(): Promise<string | undefined> {
  const quartoExt = vscode.extensions.getExtension('quarto.quarto');
  if (!quartoExt) {
    return undefined;
  }
  if (!quartoExt.isActive) {
    await quartoExt.activate();
  }
  const api = quartoExt.exports as QuartoExtensionApi;
  return api.getQuartoPath();
}

This is documented in api.ts for now. Eventually we might want to add this documentation elsewhere, but for now, let's see if this works for @mcanouil and then we can evaluate where else we should surface this info.

@juliasilge
Copy link
Collaborator Author

@mcanouil can you get the .vsix from here and see if this will work for you in Quarto Wizard, or if you have any feedback?

@mcanouil
Copy link
Contributor

mcanouil commented Jan 3, 2026

I'll take a look as I'm working on the next release of Quarto Wizard (which turns out to be quite major).

@mcanouil
Copy link
Contributor

mcanouil commented Jan 3, 2026

FYI, as I reworked the internals of Quarto Wizard to handle natively all the extensions management, having the Quarto Path became less important, but the getQuartoVersion() is great as it will allow to validate extension requirement. without having to make any calls to Quarto CLI directly.

@mcanouil
Copy link
Contributor

mcanouil commented Jan 3, 2026

It works
Modal showing the result of the three exposed functions: availability, version, and path

For reference, using the current released extension:
modal showing that the Quarto API is not available

@juliasilge
Copy link
Collaborator Author

That's great news! We'll get @vezwork to review this next week and then we can get a new version of the extension released.

@juliasilge juliasilge requested a review from vezwork January 3, 2026 23:38
Copy link
Collaborator

@vezwork vezwork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful! Great comments in apps/vscode/src/api.ts, thanks so much. Excited about this because it lays some groundwork for exposing internal extension functionality for testing! And you've already set up a test. Great job.

@juliasilge juliasilge merged commit 569fded into main Jan 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants