vscode / copilotcli
AGENTS.md196k starsChanged 17 days agoMITView on GitHub
This folder contains the Copilot CLI integration for VS Code Chat. It enables users to open a new Chat window and interact with a Copilot CLI agent instance directly within VS Code. VS Code provides the UI, Copilot CLI SDK provides the smarts. Important: The Copilot CLI agent functionality is powered by the @github/copilot/sdk package. See the SDK package for full type definitions. The integration follows VS Code's platform layering pattern with three layers:
Trending
More talk lately.about the whole repository
Who's talking about microsoft/vscode
- A Hacker News story“VS Code inserting 'Co-Authored-by Copilot' into commits regardless of usage”Hacker News · May 2, 2026 · 1.5k points
- microsoft/TypeScript“Convert the codebase to modules”GitHub · Nov 2, 2022 · 1.3k reactions
- A Hacker News story“VS Code uses 13% CPU when idle due to blinking cursor rendering”Hacker News · Mar 23, 2017 · 899 points
- A Hacker News story“VS Code Roadmap 2018”Hacker News · Nov 1, 2017 · 360 points
- microsoft/vscode-python“Fix environment-dependent git pre-commit hooks”GitHub · Feb 18, 2020 · 338 reactions
The biggest 5 of 96 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 96
Talked about on Bluesky, Hacker News and GitHub (96 times).
On Bluesky · 48
- Jan 18, 2026Decided to quit being hard headed and just do what everyone else is doing/has done. — @advanced-eschatonics.com12 likes and reposts · 1 reply
- Jul 12, 2026📦 microsoft / vscode ⭐ 187,428 (+52) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
- Jul 2, 2026📦 microsoft / vscode ⭐ 186,897 (+73) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
- Nov 2, 2025📦 microsoft / vscode ⭐ 178,121 (+34) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
- Jan 15, 2025📦 microsoft / vscode ⭐ 166,156 (+43) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
43 more on Bluesky
- Jul 8, 2023📦 microsoft / vscode ⭐ 147,967 (+41) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social3 likes and reposts
- Apr 5, 2026📦 microsoft / vscode ⭐ 183,440 (+45) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Jul 18, 2025Sorry to hear you are hitting this problem! We would love to help you out over at github.com/microsoft/vs... and if you assign your issue… — @eleanor-py.bsky.social2 likes and reposts
- May 21, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 171,731 (+283) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social2 likes and reposts
- May 20, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 171,513 (+253) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts · 1 reply
- Mar 30, 2025📦 microsoft / vscode ⭐ 169,312 (+41) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Mar 7, 2025📦 microsoft / vscode ⭐ 168,219 (+82) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social2 likes and reposts
- Feb 12, 2025📦 microsoft / vscode ⭐ 167,217 (+56) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Feb 8, 2025📦 microsoft / vscode ⭐ 167,047 (+49) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Jan 24, 2025📦 microsoft / vscode ⭐ 166,533 (+32) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Jan 15, 2025📦 microsoft / vscode ⭐ 166,156 (+43) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social2 likes and reposts
- Sep 1, 2024📦 microsoft / vscode ⭐ 162,015 (+32) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Jun 10, 2024📦 microsoft / vscode ⭐ 159,629 (+49) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social2 likes and reposts
- Aug 26, 2023🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 150,079 (+137) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social2 likes and reposts · 1 reply
- Nov 7, 2026🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 194,788 (+295) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost · 1 reply
- Nov 6, 2026🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 194,788 (+295) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social1 likes and repost · 1 reply
- Sep 26, 2026📦 microsoft / vscode ⭐ 192,963 (+78) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Sep 26, 2026📦 microsoft / vscode ⭐ 192,963 (+78) 🗒 TypeScript Visual Studio Code — @github-trending.bsky.social1 likes and repost
- Jun 25, 2026🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 186,883 (+192) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jun 4, 2026🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 185,791 (+129) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- May 20, 2026📦 microsoft / vscode ⭐ 185,087 (+57) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Apr 16, 2026📦 microsoft / vscode ⭐ 183,924 (+72) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Mar 5, 2026📦 microsoft / vscode ⭐ 182,312 (+76) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Dec 28, 2025📦 microsoft / vscode ⭐ 180,078 (+53) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jul 2, 2025📦 microsoft / vscode ⭐ 174,099 (+53) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- May 24, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 172,520 (+306) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- May 8, 2025📦 microsoft / vscode ⭐ 170,885 (+85) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Apr 11, 2025📦 microsoft / vscode ⭐ 169,887 (+76) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Apr 7, 2025📦 microsoft / vscode ⭐ 169,634 (+51) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Mar 6, 2025📦 microsoft / vscode ⭐ 168,138 (+89) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Feb 16, 2025📦 microsoft / vscode ⭐ 167,406 (+60) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jan 2, 2025lol yeah vscode is kinda wild tbh github.com/microsoft/vscode is the open source project but the versions you get from… — @benharri.org1 likes and repost · 2 replies
- Nov 1, 2024📦 microsoft / vscode ⭐ 163,956 (+52) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jun 18, 2024📦 microsoft / vscode ⭐ 159,805 (+32) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jun 6, 2024📦 microsoft / vscode ⭐ 159,414 (+58) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Apr 11, 2024📦 microsoft / vscode ⭐ 157,765 (+42) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jan 29, 2024📦 microsoft / vscode ⭐ 155,349 (+36) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Jan 19, 2024📦 microsoft / vscode ⭐ 155,009 (+57) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Dec 24, 2023📦 microsoft / vscode ⭐ 154,283 (+39) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social1 likes and repost
- Mar 17, 2025Something I just realized I want: wikilinks but for any website; kinda like DDG bangs, but for linking to things more easily. Generally… — @blakes.dev0 likes and reposts · 1 reply
- Feb 16, 2024🚀 Skyrocketing! 🚀 (200+ new stars) 📦 microsoft / vscode ⭐ 156,140 (+203) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social0 likes and reposts · 1 reply
- Sep 4, 2023🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 150,693 (+178) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social0 likes and reposts · 1 reply
- Aug 26, 2023🔥 Hot Repo! 🔥 (100+ new stars) 📦 microsoft / vscode ⭐ 150,078 (+137) 🗒 TypeScript Visual Studio Code — @github-trending-js.bsky.social0 likes and reposts · 1 reply
On Hacker News · 39
- May 2, 2026VS Code inserting 'Co-Authored-by Copilot' into commits regardless of usage1.5k points · 850 comments
- Mar 23, 2017VS Code uses 13% CPU when idle due to blinking cursor renderingsays it tested it899 points · 760 comments
- Nov 1, 2017VS Code Roadmap 2018360 points · 230 comments
- Dec 19, 2019Santa hat removed from VS Code after complaint243 points · 157 comments
- Apr 18, 2017Show HN: Visual Studio Code for ARM, submitted to core236 points · 83 comments
34 more on Hacker News
- Feb 8, 2026Billing can be bypassed using a combo of subagents with an agent definition213 points · 122 comments
- Oct 27, 2023Microsoft: Require user consent before sending any telemetry128 points · 122 comments
- May 29, 2020Insider Build of VSCode for Windows/ARM64106 points · 79 comments
- May 6, 2026Update on "Co-authored-by: Copilot" in commit messages102 points · 66 comments
- Dec 20, 2019Visual Studio Code repository is open again87 points · 163 comments
- Jun 19, 2018Want free VS Code? Build it from source84 points · 65 comments
- Oct 21, 2020Issue Grooming81 points · 68 comments
- Sep 25, 2026Bug: Border radius has infected VSCode editor80 points · 53 comments
- Mar 19, 2022Visual Studio Code is randomly erasing included header files with latest update75 points · 44 comments
- Sep 3, 2023VSCode Removes Twitter Integration68 points · 31 comments
- Oct 15, 2017New VS Code icon is ugly66 points · 48 comments
- Feb 4, 2023Microsoft mangles VS Code protected properties to prevent UI customization65 points · 28 comments
- Apr 29, 2020VS Code was lost on shutdown with pending update (2018)64 points · 90 comments
- Oct 27, 2025Severe performance penalty found in VSCode rendering loop63 points · 45 comments
- Nov 24, 2020VSCode memory leak issue marked “out-of-scope”62 points · 71 comments
- Feb 16, 2021Visual Studio Code team considers Vim mode depending on upvotes56 points · 27 comments
- Nov 3, 2023VS Code Introduces Floating Windows Support - The Most Requested Feature Ever46 points · 10 comments
- Jan 29, 2019VS Code Roadmap 201933 points · 3 comments
- Apr 21, 2022VS Code Development Process27 points · 3 comments
- Feb 2, 2024VSCode stopped supporting an old glibc version and near EOL users are in trouble23 points · 8 comments
- Jul 11, 2024VSCode won't start on several Mac OS versions, broken over a week16 points · 3 comments
- Nov 15, 2025Markdown files are not openable because of GitHub Copilot11 points · 1 comment
- Mar 17, 2022VSCode creates many empty file with invalid code automatically8 points · 1 comment
- Dec 19, 2019VS Code Issue Tracker Meltdown8 points · 4 comments
- Aug 31, 2023VSCode, have you collaborated with China?7 points
- Mar 15, 2023VS Code Monitors Full Command Line, CPU, Memory Usage of All Processes7 points · 1 comment
- Nov 20, 2024Thing Deleted 3 Months of Work6 points · 4 comments
- Nov 3, 2024VSCode high CPU usage issue affecting macOS6 points
- Oct 9, 2026VSCode silently switches to Microsoft models, ignoring BYO agent configuration5 points · 1 comment
- May 28, 2026VSCode fires up screen recording5 points
- Oct 5, 2025Microsoft Accidentally removes extensions from VSCode Marketplace5 points · 1 comment
- Nov 2, 2023After 7 years, VS Code finally implements preview support for floating windows5 points · 2 comments
- Feb 27, 2020THIS THING DELETED 3 MONTHS OF WORK!!!!5 points · 5 comments
- Dec 20, 2019VS Code is getting flak for removing Santa hat emoji5 points · 7 comments
On GitHub · 9
- Nov 2, 2022Convert the codebase to modules — microsoft/TypeScript1.3k reactions · 56 comments
- Feb 18, 2020Fix environment-dependent git pre-commit hooks — microsoft/vscode-python338 reactions · 57 comments
- Dec 12, 2025Handle writes to non-blocking pty instead of wrapping via Node's tty api — microsoft/node-pty256 reactions · 5 comments
- Oct 31, 2016Add Windows support and first-class Linux support — vercel/hyper160 reactions · 98 comments
- Sep 11, 2024Proposed expandable hover API — microsoft/TypeScript99 reactions · 15 comments
4 more on GitHub
- Dec 22, 2020LSP 3.16.0 — neoclide/coc.nvim64 reactions · 52 comments
- Mar 8, 2021Import statement completions — microsoft/TypeScript47 reactions · 9 comments
- Aug 13, 2017Feature/simple fullscreen mode — electron/electron43 reactions · 8 comments
- May 30, 2018Add support for grid layout — VSCodeVim/Vim37 reactions · 18 comments
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 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 repository96 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .eslint-plugin-local/AGENTS.mdAGENTS.md
- extensions/copilot/assets/prompts/skills/agent-customization/references/agents.mdAGENTS.md
- extensions/copilot/src/platform/authentication/common/AGENTS.mdAGENTS.md
- src/vs/platform/agentHost/AGENTS.mdAGENTS.md
- src/vs/platform/agentHost/common/state/AGENTS.mdAGENTS.md
- src/vs/platform/agentHost/node/copilot/prompts/AGENTS.mdAGENTS.md
- src/vs/platform/agentHost/test/node/AGENTS.mdAGENTS.md
- src/vs/workbench/contrib/imageCarousel/AGENTS.mdAGENTS.md
- extensions/copilot/.github/copilot-instructions.mdCopilot instructions
- .github/copilot-instructions.mdCopilot instructions
- launchSkill
- github-copilot-upgraderSkill
- launchSkill
- agent-customizationSkill
- chronicleSkill
- create-agentSkill
- create-canvasSkill
- create-hookSkill
- create-instructionsSkill
- create-promptSkill
- create-skillSkill
- initSkill
- migrate-customizationsSkill
- record-videoSkill
- troubleshootSkill
- accessibilitySkill
- agent-host-chat-contributionsSkill
- agent-host-e2e-testsSkill
- agent-host-logsSkill
- author-contributionsSkill
- auto-perf-optimizeSkill
- azure-pipelinesSkill
- build-champ-triageSkill
- chat-customizations-editorSkill
- chat-perfSkill
- chat-pet-sprite-creationSkill
- ci-artifact-testingSkill
- codenotifySkill
- code-oss-logsSkill
- code-reviewSkill
- component-fixturesSkill
- componentSkill
- context-menusSkill
- cpu-profile-analysisSkill
- customizations-in-the-agent-hostSkill
- design-philosophySkill
- doc-commentsSkill
- endgame-statusSkill
- experimentsSkill
- feature-tryoutsSkill
- feedback-learningSkill
- fix-ci-failuresSkill
- fixissuenoSkill
- flaky-smoke-testsSkill
- heap-snapshot-analysisSkill
- hoverSkill
- integrated-browserSkill
- integration-testsSkill
- issue-groupingSkill
- The first 60 shown.
The file
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 0 are distinctive, and 8 are 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.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 201
If session is idle → normal request via send()
- Very specific: line 202
If session is busy → steering request via send({ mode: 'immediate' })
- Very specific: line 218
When autopilot / autoApprove permission level is set, all permissions are auto-approved without user interaction.
- Very specific: line 302
Add handle<Kind>Permission() in node/permissionHelpers.ts following the existing pattern
- Very specific: line 303
Add a case '<kind>': in the permission switch in node/copilotcliSession.ts (~line 468)
- Very specific: line 308
Add a listener in node/copilotcliSession.ts using this._sdkSession.on(eventName, handler)
- Very specific: line 310
Use this._stream?.markdown() / this._stream?.push() to output to the chat UI
- Very specific: line 320
Steering mode: When a session is already busy (InProgress or NeedsInput), use send({ mode: 'immediate' }) to inject messages into the …
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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
Copilot CLI Integration
This folder contains the Copilot CLI integration for VS Code Chat. It enables users to open a new Chat window and interact with a Copilot CLI agent instance directly within VS Code. VS Code provides the UI, Copilot CLI SDK provides the smarts.
Important: The Copilot CLI agent functionality is powered by the
@github/copilot/sdkpackage. See the SDK package for full type definitions.
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ VS Code Chat UI │
└─────────────────────────┬───────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ CopilotCLISessionService │
│ (node/copilotcliSessionService.ts) │
│ - Manages SDK LocalSessionManager lifecycle │
│ - Creates, retrieves, and caches CopilotCLISession instances │
│ - Handles session persistence, discovery, and forking │
│ - Monitors session files on disk for external changes │
│ - Installs OTel bridge span processor for debug panel │
└─────────────────────────┬───────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ CopilotCLISession │
│ (node/copilotcliSession.ts) │
│ - Wraps a single SDK Session for one conversation │
│ - Processes SDK events (messages, tools, permissions, errors) │
│ - Handles tool confirmation and permission requests │
│ - Supports steering (injecting messages into running sessions) │
│ - Manages model switching and reasoning effort │
│ - Tracks OTel spans for observability │
└─────────────────────────┬───────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Copilot CLI SDK (@github/copilot/sdk) │
│ - Manages the agentic conversation loop │
│ - Executes tools and reports results via events │
│ - Handles permissions (read, write, shell, MCP) │
│ - Provides session persistence as events.jsonl files │
│ - Supports fleet mode and plan mode │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ MCP Server (In-Process) │
│ (vscode-node/contribution.ts, vscode-node/inProcHttpServer.ts) │
│ - Provides VS Code-specific tools to the SDK via MCP protocol │
│ - Runs as an in-process HTTP server (InProcHttpServer) │
│ - Exposes diff, diagnostics, selection, and session tools │
│ - Discoverable by CLI via lock files in ~/.copilot/ide/ │
└─────────────────────────────────────────────────────────────────┘Folder Structure
The integration follows VS Code's platform layering pattern with three layers:
copilotcli/
├── common/ # Platform-agnostic (NO Node.js or VS Code API imports)
│ ├── copilotCLITools.ts # Tool type definitions and processing helpers
│ ├── copilotCLIPrompt.ts # Prompt reference extraction and parsing
│ ├── customSessionTitleService.ts
│ ├── delegationSummaryService.ts
│ ├── utils.ts # SessionIdForCLI namespace (URI scheme: 'copilotcli')
│ └── test/
│
├── node/ # Node.js-specific (SDK integration, filesystem, permissions)
│ ├── copilotCli.ts # ICopilotCLISDK, CopilotCLIModels, CopilotCLIAgents
│ ├── copilotcliSession.ts # CopilotCLISession — main session wrapper
│ ├── copilotcliSessionService.ts # Session lifecycle management
│ ├── permissionHelpers.ts # Permission request handlers
│ ├── copilotcliPromptResolver.ts # Resolves prompts with variables and attachments
│ ├── copilotCLISkills.ts # Skills location resolution
│ ├── copilotCLIImageSupport.ts # Image attachment handling
│ ├── mcpHandler.ts # MCP server configuration for SDK sessions
│ ├── nodePtyShim.ts # Runtime node-pty copy for separate extension installs
│ ├── userInputHelpers.ts # User question/input handling interface
│ ├── exitPlanModeHandler.ts # Plan mode exit flow with user choice
│ ├── ripgrepShim.ts # Copies VS Code's ripgrep for SDK use
│ └── test/
│
└── vscode-node/ # VS Code API-dependent (commands, MCP tools, UI)
├── copilotCLIFolderMru.ts # Folder MRU (most-recently-used) service
└── test/Layering Rules
Strict import dependency rules — violations will cause build failures:
| Layer | Can import from | Cannot import from |
common/ | src/util/common/, src/platform/, sibling ../common/ | node/, vscode-node/, vscode module |
node/ | common/, src/util/, src/platform/, Node.js builtins | vscode-node/, vscode module |
vscode-node/ | common/, node/, src/util/, src/platform/, vscode module | (top layer — no restrictions) |
Key Components
node/copilotCli.ts
ICopilotCLISDK / CopilotCLISDK
- Service interface wrapping the dynamic
import('@github/copilot/sdk')for dependency injection and testability
ICopilotCLIModels / CopilotCLIModels
- Fetches and caches available AI models from the SDK via
getAvailableModels() - Registers a
LanguageModelChatProviderwithtargetChatSessionType: 'copilotcli'so VS Code's model picker shows CLI models - Exposes model capabilities: vision support, reasoning effort levels, token limits, billing multiplier
- Rebuilds model list on authentication changes
- Builds configuration schema for reasoning effort per model (low/medium/high/xhigh)
ICopilotCLIAgents / CopilotCLIAgents
- Discovers custom agents
node/copilotcliSession.ts
CopilotCLISession
- Wraps a single
Sessionobject from the@github/copilot/sdk - Entry point for every chat request via
handleRequest() - Listens to SDK events and translates them to VS Code chat UI parts
- Manages permission flow
- Tracks external edits via
ExternalEditTrackerfor proper diff display - Supports CLI commands:
compact,plan,fleet - Built-in slash commands:
/commit,/sync,/merge,/create-pr,/create-draft-pr,/update-pr - Captures pull request URLs from
create_pull_requesttool results
node/copilotcliSessionService.ts
ICopilotCLISessionService / CopilotCLISessionService
- Central service managing the lifecycle of all Copilot CLI sessions
common/copilotCLITools.ts
Defines all tool type interfaces used by the Copilot CLI agent:
- File Operations
- Shell Operations
- Search Operations
- Agent & Task Operations
- User Interaction
- Code Review & Git
- Data, Memory & MCP
- Security
common/copilotCLIPrompt.ts
Parses raw user prompts and extracts structured chat prompt references (files, locations, diagnostics)
node/copilotcliPromptResolver.ts
CopilotCLIPromptResolver
- Resolves chat request prompts by processing variable references and building attachments
- Extracts prompt variables from
ChatVariablesCollection(files, locations, diagnostics, custom instructions) - Converts image attachments
- Generates the final user prompt
- Handles workspace folder path translation for multi-folder isolation
node/permissionHelpers.ts
Handles permission requests from the SDK. Each permission kind has a dedicated handler:
- handleReadPermission
- handleWritePermission
- handleShellPermission
- handleMcpPermission
- showInteractivePermissionPrompt
node/mcpHandler.ts
ICopilotCLIMCPHandler / CopilotCLIMCPHandler
- Loads MCP server configuration for SDK sessions
- Proxies all VS Code-configured MCP servers through a gateway URL with
type: 'http'config per server
node/copilotCLIImageSupport.ts
ICopilotCLIImageSupport / CopilotCLIImageSupport
- Stores image data as files in extension global storage (
copilot-cli-images/) - Tracks trusted image URIs to auto-approve read permissions
- Supports PNG, JPEG, GIF, WebP, and BMP formats via
isImageMimeType()
node/exitPlanModeHandler.ts
handleExitPlanMode()
- Presents exit options when the SDK finishes plan generation: Autopilot, Interactive, Exit Only, Autopilot Fleet
- Syncs saved plan changes back to the SDK session
node/cliHelpers.ts
Path helpers for Copilot CLI directories.
Message Flow
- User sends message in VS Code Chat
- CopilotCLISessionService creates or retrieves an existing session wrapper
- CopilotCLISession.handleRequest() is called:
- If session is idle → normal request via
send() - If session is busy → steering request via
send({ mode: 'immediate' })
- If session is idle → normal request via
- SDK Session processes the request and emits events:
assistant.message_delta→ streamed markdown to chat UItool.execution_start/tool.execution_complete→ tool invocation UI partspermission.requested→ routed to permission handler (auto-approve or interactive)user_input.requested→ question carousel shown to userexit_plan_mode.requested→ plan mode exit choicessession.title_changed→ session title updatedsubagent.started/completed/failed→ subagent metadata enriches tool invocationshook.start/end→ forwarded to OTel bridge for debug panel
- Session completes — status set to
Completed, usage reported
Permission System
The SDK emits permission.requested events with a kind field.
When autopilot / autoApprove permission level is set, all permissions are auto-approved without user interaction.
Tool invocation messages are intentionally held in a queue (toolCallWaitingForPermissions) until the permission resolves, preventing a flash of "Running..." immediately followed by "Permission requested...".
Session Persistence
Copilot CLI sessions are persisted to ~/.copilot/session-state/<sessionId>/ directories containing:
events.jsonl— Ordered event stream (messages, tool calls, results)workspace.yaml— Workspace configuration
IWorkspaceInfo (../common/workspaceInfo.ts)
Central type representing all workspace/repository/worktree state for a session:
IChatSessionMetadataStore (../common/chatSessionMetadataStore.ts)
Persists VS Code-specific metadata that sits alongside the SDK's own session data. This metadata is not part of the SDK's events.jsonl — it tracks VS Code concepts like worktree properties, request-to-tool mappings, mode instructions, and checkpoint refs.
Key Types:
ChatSessionMetadataFile — The full metadata shape per session:
RequestDetails — Per-request metadata:
RepositoryProperties — Git repository metadata:
IChatSessionWorktreeService (../common/chatSessionWorktreeService.ts)
Manages Git worktree lifecycle for session isolation. When isolation is enabled, each session gets its own Git worktree so the agent can make changes without affecting the user's working copy.
IChatSessionWorktreeCheckpointService (../common/chatSessionWorktreeCheckpointService.ts)
Creates Git checkpoints (lightweight commits or refs) at the start and end of each request turn. These checkpoints enable the undo/revert feature — users can roll back to any previous turn's state.
IChatSessionWorkspaceFolderService (../common/chatSessionWorkspaceFolderService.ts)
Handles workspace folder tracking for sessions without Git worktree isolation — i.e., when the agent works directly in the user's workspace. Used in multi-root workspaces where some folders may not have Git repositories.
IFolderRepositoryManager (../common/folderRepositoryManager.ts)
Orchestrates the full folder/repository initialization flow for a session. This is the high-level coordinator that brings together worktree creation, trust verification, uncommitted change handling, and folder tracking.
ISessionRequestLifecycle (../vscode-node/sessionRequestLifecycle.ts)
Orchestrates the start and end of each chat request turn, coordinating worktree commits, checkpoint creation, PR detection, and metadata updates. Handles the complexity of steering — where multiple requests can be in-flight for the same session simultaneously.
Architecture Diagram: Shared Services
┌──────────────────────────────────────────────────────────────────────┐
│ SessionRequestLifecycle │
│ Orchestrates start/end of each request turn │
│ Handles steering (multiple concurrent requests per session) │
└──────┬──────────┬──────────────┬─────────────┬──────────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌────────────┐ ┌───────────┐ ┌─────────────┐ ┌──────────────────────┐
│ Worktree │ │ Workspace │ │ Checkpoint │ │ MetadataStore │
│ Service │ │ Folder │ │ Service │ │ │
│ │ │ Service │ │ │ │ - Request details │
│ - Create │ │ │ │ - Baseline │ │ - Worktree props │
│ - Commit │ │ - Track │ │ checkpts │ │ - Workspace folder │
│ - Cleanup │ │ - Stage │ │ - Post-turn │ │ - Repo properties │
│ - Archive │ │ - Changes │ │ checkpts │ │ - Mode instructions │
│ - Unarchive│ │ - Clear │ │ │ │ - Checkpoint refs │
└────────────┘ └───────────┘ └─────────────┘ └──────────────────────┘
│ │ │ │
└──────────┴──────────────┴─────────────┘
│
▼
┌──────────────────────┐
│ FolderRepositoryMgr │
│ │
│ - Init flow │
│ - Trust verification │
│ - Isolation mode │
└──────────────────────┘How to Add New Features
Adding a new permission handler
- Add
handle<Kind>Permission()innode/permissionHelpers.tsfollowing the existing pattern - Add a
case '<kind>':in the permission switch innode/copilotcliSession.ts(~line 468) - Handler should return a
PermissionRequestResultwithkind: 'approved' | 'denied-interactively-by-user' | ...
Handling a new SDK event
- Add a listener in
node/copilotcliSession.tsusingthis._sdkSession.on(eventName, handler) - Wrap with
toDisposable()and add to theDisposableStorefor proper cleanup - Use
this._stream?.markdown()/this._stream?.push()to output to the chat UI
Critical Pitfalls
- Shims before SDK import: For separate Marketplace/VSIX extension installs,
CopilotCLISDK.ensureShims()innode/copilotCli.tsMUST run before anyimport('@github/copilot/sdk'). That runtime path calls bothensureRipgrepShim()andensureNodePtyShim()to copy VS Code's native binaries fromenvService.appRootinto the installed extension's SDK layout. - Bundled/core shim path is different: When Copilot Chat is bundled together with core VS Code, build-time packaging materializes only the ripgrep shim and writes
node_modules/@github/copilot/shims.txt. That marker intentionally makes runtimeensureShims()return early, so node-pty is not copied in the bundled path; it is resolved from VS Code's own app tree instead. - Delayed permission UI: Tool invocation messages are held in
toolCallWaitingForPermissionsuntil permission resolves.flushPendingInvocationMessageForToolCallId()flushes only the specific approved tool, not all pending tools. This is intentional — don't bypass it. - Steering mode: When a session is already busy (
InProgressorNeedsInput), usesend({ mode: 'immediate' })to inject messages into the running conversation instead of starting a new request. - External sessions are never listed:
isExternalSession()innode/copilotcliSessionService.tsfilters out every session whoseIChatSessionMetadataStoreorigin is notvscode(e.g. started from the terminal CLI). It is applied on all listing paths —_getAllSessions()(disk, before any SDK detail read),getSessionItemImpl()(targeted refresh), and the in-progress wrapper fallback in_getAllSessions()— becausegetSession()can load an external session into_sessionWrapperswithout changing its origin. There is no setting for this — the Agent Host owns external session visibility viachat.agentSessions.showExternalAgentSessions. - Session listing must stay O(VS Code sessions), not O(all sessions):
~/.copilot/session-statecan hold tens of thousands of terminal/copilot -psessions._getAllSessions()callslistSessions({ metadataLimit: 0, includeDetached: false })(ids and times only; withincludeDetachedon, the SDK reads every event log at once regardless ofmetadataLimit), drops agent-host-owned ids and external sessions, and only then reads details viaenrichSessionMetadataunder aLimiter. Never calllistSessions()without options. Details are cached per session and reused while the SDKmodifiedTime(events.jsonl) and theworkspace.yamlmtime are unchanged; agent-host ownership (agentSessionData/<id>) is re-read on every listing and checked first, so an adopted legacy session drops out on the next refresh.copilotCLISDKUpgrade.spec.tsguards these SDK semantics. Working directories are recorded only for listed VS Code sessions;getSessionWorkingDirectory()resolves any other session on demand.
Commands & Slash Commands
Copilot CLI commands (user-facing, sent programmatically):
compact— compress conversation history to reduce tokensplan— enter plan mode (SDK generates plan before executing)fleet— start fleet mode for multi-agent parallel execution
Built-in custom slash commands (user-facing):
/commit, /sync, /merge, /create-pr, /create-draft-pr, /update-pr
VS Code Session commands (registered via registerCLIChatCommands in vscode-node/copilotCLIChatSessions.ts):
Configuration
The integration respects these VS Code settings (all under github.copilot.chat.cli.*):
| Setting | Default | Description |
mcp.enabled | true | Enable MCP server proxying for CLI sessions |
branchSupport.enabled | false | Enable Git branch support features |
planExitMode.enabled | true | Show plan exit mode choices (Autopilot/Interactive/Exit) |
planCommand.enabled | true | Enable the /plan command |
aiGenerateBranchNames.enabled | true | AI-generated branch names for worktrees |
forkSessions.enabled | true | Allow forking sessions into new conversations |
isolationOption.enabled | true | Show worktree isolation option in session UI |
autoCommit.enabled | true | Auto-commit worktree changes at end of each turn |
sessionController.enabled | false | Use session controller API (V2) |
sessionControllerForSessionsApp.enabled | false | Use session controller for Sessions window |
terminalLinks.enabled | true | Enable terminal link detection |
Dependencies
@github/copilot/sdk: Official Copilot CLI SDK (session management, tools, permissions, events)
Deprecated Code
V1 registration in ../vscode-node/copilotCLIChatSessionsContribution.ts and registerCopilotCLIServicesV1 are deprecated. All new development should use CopilotCLISessionService and the controller-based V2 API.
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.

