0201d5fdd3 sessions: implement chatSessionCustomizationProvider for Claude and Copilot CLI (#4772)
* Add customization providers for Claude and Copilot CLI chat sessions

* Add unit tests for chat session customization providers

Add tests for ClaudeCustomizationProvider and CopilotCLICustomizationProvider
covering metadata, item discovery, and change event forwarding. Refactor
metadata from static readonly to static getter for testability (avoids
class initializer accessing vscode.ChatSessionCustomizationType before
shim setup).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix customization provider accuracy: add hook discovery, mark unsupported types

- Claude provider now discovers hooks from .claude/settings.json and
  .claude/settings.local.json (workspace + user home), reporting them
  as ChatSessionCustomizationType.Hook items with event/matcher names
- Copilot CLI provider marks both Hook and Prompt as unsupported since
  it doesn't support hooks and prompt files aren't enumerable via the API
- Claude provider now takes IWorkspaceService, IFileSystemService, and
  INativeEnvService to read settings files for hook discovery
- Added 6 new hook discovery tests covering workspace/user settings,
  multiple matchers, invalid JSON, and missing files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Mark Agent as unsupported for Claude customization provider

Claude doesn't use .agent.md files — it has its own agent system via
CLAUDE.md memory files and the Claude Agent SDK. Remove Agent items
from Claude's provideChatSessionCustomizations output and add Agent
to its unsupportedTypes metadata.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove workspaceSubpaths from API, add internal path filtering

Remove the workspaceSubpaths property from ChatSessionCustomizationProviderMetadata
since the extension should filter internally. Each provider now only returns items
under its relevant paths:

- Claude: instructions/skills under .claude/ (workspace folders + user home)
- Copilot CLI: instructions/skills under .github/ or .copilot/ (agents are always
  included since they're Copilot-specific)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add TODO comments for work in progress on chatSessionCustomizationProvider API

* Sync chatSessionCustomizationProvider d.ts with VS Code origin/main

Add groupKey, badge, and badgeTooltip fields to ChatSessionCustomizationItem
to match upstream changes from #305810 and #305813.

The providers don't set these fields explicitly — the VS Code UI
auto-enriches instruction items by parsing frontmatter when groupKey
is not provided.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* sessions: Claude customization provider uses SDK runtime data

- Add IClaudeRuntimeDataService to cache agents from Query.supportedAgents()
- ClaudeCodeSession calls runtimeDataService.update() after query creation
- Rewrite ClaudeCustomizationProvider:
  - Agents: reported from SDK via IClaudeRuntimeDataService (built-in groupKey)
  - Instructions: hard-coded CLAUDE.md paths with existence checks
  - Skills: filtered from IChatPromptFileService under .claude/
  - Hooks: unchanged (from .claude/settings.json)
- unsupportedTypes changed from [Agent, Prompt] to [Prompt] only
- 28 tests (22 provider + 6 service)

* sessions: Copilot CLI customization provider uses runtime agent data

- Inject ICopilotCLIAgents to enrich agents with displayName/description
- Expand path filter: add .agents/ to CLI_SUBPATHS
- Add home directory support: ~/.copilot/, ~/.agents/
- Listen to ICopilotCLIAgents.onDidChangeAgents for change events
- 21 tests covering new paths, agent enrichment, and events

* fix: register IClaudeRuntimeDataService in test services

The existing claudeCodeAgent tests were failing because ClaudeCodeSession
now depends on IClaudeRuntimeDataService, but it was not registered in
createExtensionUnitTestingServices().

* sessions: implement correct chatSessionCustomizationProvider for Claude and Copilot CLI

Claude provider:
- New IClaudeRuntimeDataService to cache SDK Query agents
- Hybrid agent approach: file-based .claude/ agents pre-session, SDK agents post-session
- Instructions from hard-coded CLAUDE.md paths (stat-checked)
- Skills from .claude/skills/ via IChatPromptFileService
- Hooks from .claude/settings.json (unchanged)
- Per-category debug logging with names

Copilot CLI provider:
- ICopilotCLIAgents as primary agent source (SDK + prompt files)
- Path filter expanded to .github/, .copilot/, .agents/
- Home directory support (~/.copilot/, ~/.agents/)
- Agent enrichment with displayName/description from SDK

Menu contributions:
- chat/customizations/create for Claude agents, hooks, instructions sections

Code review fixes:
- Use stat() instead of readFile() for existence checks
- Fire-and-forget runtimeDataService.update() to avoid blocking session startup
- Restore vscode.ChatSessionCustomizationType in test afterEach
- Type-safe makeSweAgent helper (no as any)

* claude: mark plugins as unsupported type

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 23:58:02 +00:00
S
Description
Visual Studio Code
2.3 GiB
Languages
TypeScript 79.3%
jsonc 16.5%
CSS 1.4%
JavaScript 0.6%
C 0.6%
Other 1.3%