vscode-copilot-chat / common
AGENTS.md10k starsChanged 7 months agoMITArchived repositoryView on GitHub
IAuthenticationService manages GitHub and Copilot authentication. It provides GitHub sessions (OAuth tokens) and Copilot tokens (CAPI tokens). getGitHubSession requires a kind parameter. Choose thoughtfully: Returns AuthenticationSession (never undefined). Throws if the user cancels. Requires createIfNone with a StrictAuthenticationPresentationOptions containing a localized detail string explaining why auth is needed: Same as above but forces re-authentication even if a session exists. Use when the current token has lost authorization: Returns AuthenticationSession | undefined. Never shows UI. Use when auth is optional: For…
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 75
When authService.isMinimalMode is true, the service will not fetch permissive tokens:
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Authentication Service Usage Guide
Overview
IAuthenticationService manages GitHub and Copilot authentication. It provides GitHub sessions (OAuth tokens) and Copilot tokens (CAPI tokens).
Choosing a Session Kind
getGitHubSession requires a kind parameter. Choose thoughtfully:
'any'— Accepts whatever GitHub session is available, even one with minimal scopes (e.g., justuser:email). Use this when you only need basic access and don't require repo or write permissions.'permissive'— Requires a session with broader scopes (read:user,user:email,repo,workflow). Use when you need private repo access or write permissions.
The Three Overloads of getGitHubSession
1. Interactive — prompt user to sign in
Returns AuthenticationSession (never undefined). Throws if the user cancels.
Requires createIfNone with a StrictAuthenticationPresentationOptions containing a localized detail string explaining why auth is needed:
const session = await authService.getGitHubSession('any', {
createIfNone: { detail: l10n.t('Sign in to GitHub to use feature X.') }
});2. Interactive — force a new session
Same as above but forces re-authentication even if a session exists. Use when the current token has lost authorization:
const session = await authService.getGitHubSession('any', {
forceNewSession: { detail: l10n.t('Sign in again to restore access.') }
});3. Silent — no user prompt
Returns AuthenticationSession | undefined. Never shows UI. Use when auth is optional:
const session = await authService.getGitHubSession('any', { silent: true });
if (!session) {
// No session available, handle gracefully
}Important Constraints
createIfNoneandforceNewSessiondo NOT acceptboolean. You must pass aStrictAuthenticationPresentationOptionswith a requireddetailstring. Passingtrue,false, or{}will not compile.- The
detailstring must be localized usingl10n.t('...'). - The silent overload's options type is
Omit<AuthenticationGetSessionOptions, 'createIfNone' | 'forceNewSession'>— you cannot sneak a booleancreateIfNonethrough it.
Synchronous Cache Properties
For non-blocking checks (no network, no UI), use the cached properties:
authService.anyGitHubSession— cached'any'session orundefinedauthService.permissiveGitHubSession— cached'permissive'session orundefinedauthService.copilotToken— cached Copilot token (without the raw token string) orundefined
React to onDidAuthenticationChange to stay up to date.
Copilot Tokens
Most callers just need a valid CAPI token. getCopilotToken() handles refresh automatically:
const token = await authService.getCopilotToken();Minimal Mode
When authService.isMinimalMode is true, the service will not fetch permissive tokens:
- Interactive
'permissive'calls throwMinimalModeError - Silent
'permissive'calls returnundefined
Auth State Flows
There are three states a user can be in:
- Not signed in — No
'any'session exists. The user has no GitHub session at all. An interactivecreateIfNonecall will show VS Code's built-in sign-in dialog. - Signed in from VS Code — The user explicitly signed in through VS Code (e.g., via Accounts menu or a
createIfNoneprompt). In this case, VS Code automatically acquires the permissive token since it requests the broader scopes upfront. Both'any'and'permissive'sessions are available. - Signed in passively (e.g., via Settings Sync) — The user is signed into GitHub through a passive mechanism that only grants minimal scopes. Copilot Chat works with the
'any'token, but no'permissive'token is available. A'permissive'call withcreateIfNonewill prompt the user to grant additional permissions.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository11 other files it gives its agents.
- assets/prompts/skills/agent-customization/references/agents.mdAGENTS.md
- src/extension/chatSessions/claude/AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- anthropic-sdk-upgraderSkill
- launchSkill
- agent-customizationSkill
- get-search-view-resultsSkill
- install-vscode-extensionSkill
- project-setup-info-context7Skill
- project-setup-info-localSkill
- troubleshootSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

