ai-assistant: docs: Add provider auto-detection guide#880
Open
illume wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new documentation page intended to explain “provider auto-detection” for the AI Assistant, including the proposed provider list, architecture/flow, security properties, and test instructions.
Changes:
- Introduces
provider-auto-detection.mddescribing automatic discovery of providers (Copilot/Azure/Ollama). - Documents a proposed detection flow and security constraints (CLI allowlist, timeouts, sentinel auth).
- Adds a tests section with example commands.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,50 @@ | |||
| # Provider Auto-Detection | |||
|
|
|||
| Automatically detects available AI providers on the user's machine — no manual API key entry required. | |||
Comment on lines
+5
to
+6
| ## Supported providers | ||
|
|
Comment on lines
+7
to
+11
| | Provider | Detection method | Auth | | ||
| |----------|-----------------|------| | ||
| | **GitHub Copilot** | `gh auth token` → validate → model catalog | Sentinel `__GH_CLI_AUTH__` (token refreshed at runtime) | | ||
| | **Azure OpenAI** | `az` CLI → account enumeration → deployment filtering | Sentinel `__AZ_CLI_AUTH__` (key refreshed at runtime) | | ||
| | **Ollama** | HTTP probe to `localhost:11434` | None | |
Comment on lines
+15
to
+19
| Detection logic is in `ai-common/src/providers/providerAutoDetect.ts` (platform-agnostic). It receives a `CommandRunner` from the host app for CLI execution. | ||
|
|
||
| UI is in `ai-ui/src/components/settings/`: | ||
| - `AutoDetectProvider.tsx` — Dialog + `useAutoDetect()` hook | ||
| - `ModelSelector` — Integrates the "Auto Detect" button |
Comment on lines
+24
to
+28
| User clicks "Auto Detect" | ||
| → useAutoDetect() → detectProviders(existingConfigs, dismissedKeys, commandRunner) | ||
| ├── detectCopilotProvider() → gh auth token → validate → model catalog | ||
| ├── collectAzureOpenAIProviders() → az account → list accounts → deployments | ||
| └── detectOllamaProvider() → HTTP GET localhost:11434/api/tags |
| ├── detectCopilotProvider() → gh auth token → validate → model catalog | ||
| ├── collectAzureOpenAIProviders() → az account → list accounts → deployments | ||
| └── detectOllamaProvider() → HTTP GET localhost:11434/api/tags | ||
| → DetectedProvidersDialog → User adds or dismisses |
Comment on lines
+34
to
+36
| - **Command allowlist**: Only `gh` and `az` are permitted. | ||
| - **15 s timeout** on all CLI commands. | ||
| - **Sentinel values**: Real tokens are never stored in config. Sentinel strings are stored; actual tokens are fetched from CLI only at model-creation time via `refreshGitHubToken()` / `refreshAzureOpenAIKey()`. |
Comment on lines
+38
to
+40
| ## Dismissal & deduplication | ||
|
|
||
| Dismissed providers are tracked by key (`copilot`, `local`, `azure:<accountName>`) and excluded on subsequent detection runs. Providers already in the user's config are also excluded. |
Comment on lines
+44
to
+46
| - `ai-common/src/providers/providerAutoDetect.test.ts` — core detection logic | ||
| - `ai-ui/src/components/settings/AutoDetectProvider.test.ts` — UI orchestration | ||
|
|
Comment on lines
+47
to
+50
| ```bash | ||
| packages/ai-common | ||
| npx vitest run src/providers/providerAutoDetect.test.ts | ||
| ``` |
8b5796b to
68f44e3
Compare
…on guide Documents the automatic provider detection system. Supported providers detected without manual API key entry: - GitHub Copilot: via `gh auth token`, validated against model catalog. - Azure OpenAI: via `az` CLI account enumeration and deployment filtering. - Ollama: via HTTP probe to localhost:11434. Detection logic lives in `ai-common/src/providers/providerAutoDetect.ts` and accepts an injected `CommandRunner` so the same code works in both the browser (Electron IPC) and the CLI (Node child_process) contexts. Sentinel strings (`__GH_CLI_AUTH__`, `__AZ_CLI_AUTH__`) mark credentials that are refreshed at runtime rather than stored. Signed-off-by: René Dudfield <renedudfield@microsoft.com> Co-authored-by: Ashu Ghildiyal <aghildiyal@microsoft.com> Signed-off-by: Ashu Ghildiyal <aghildiyal@microsoft.com>
68f44e3 to
35f3995
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
docs/provider-auto-detection.mdexplaining how the AI assistant automatically detects available providers (Ollama, OpenAI-compatible endpoints) from the environment and presents detected options to the user.Assisted by Copilot.
Part of the ai-assistant documentation series.