refactor and add tests for agentCustomizationContentExpander#317773
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR refactors plugin-content expansion logic into a dedicated AgentCustomizationContentExpander and adds a comprehensive test suite covering skills/agents/rules/commands discovery and metadata handling.
Changes:
- Introduced
AgentCustomizationContentExpanderto encapsulate scanning plugin subfolders and parsing frontmatter metadata. - Refactored
AgentCustomizationItemProviderto delegate expansion and simplify its internal logic. - Added extensive browser tests validating discovery rules, metadata extraction, and propagation of
groupKey/pluginUri.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/agentHost/agentCustomizationContentExpander.test.ts | Adds coverage for expansion behavior across all supported folder types and key propagation. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationItemProvider.ts | Delegates plugin expansion to the new expander and restructures parallel expansion flow. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationContentExpander.ts | New implementation of plugin-content expansion and frontmatter parsing. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 3
Comment on lines
+222
to
+228
| private async _expandPluginContents(plugin: PluginMeta, token: CancellationToken): Promise<readonly ICustomizationItem[]> { | ||
| const cached = this._expansionCache.get(plugin.item.uri); | ||
| if (cached && cached.nonce === plugin.nonce) { | ||
| return cached.children; | ||
| } | ||
|
|
||
| // pluginUri is already an agent-host:// URI (from toRemoteUri), | ||
| // so use it directly as the filesystem root. | ||
| const fsRoot = pluginUri; | ||
| const children: ICustomizationItem[] = []; | ||
| try { | ||
| if (!await this._fileService.canHandleResource(fsRoot)) { | ||
| return []; | ||
| } | ||
| if (token.isCancellationRequested) { | ||
| return []; | ||
| } | ||
|
|
||
| const dirNames = ['agents', 'skills', 'commands', 'rules'] as const; | ||
| const subdirs = dirNames.map(name => ({ name, resource: URI.joinPath(fsRoot, name) })); | ||
| const stats = await this._fileService.resolveAll(subdirs.map(s => ({ resource: s.resource }))); | ||
|
|
||
| if (token.isCancellationRequested) { | ||
| return []; | ||
| } | ||
|
|
||
| for (let i = 0; i < subdirs.length; i++) { | ||
| const stat = stats[i]; | ||
| if (!stat.success || !stat.stat?.isDirectory || !stat.stat.children) { | ||
| continue; | ||
| } | ||
| const promptType = promptsTypeForPluginDir(subdirs[i].name); | ||
| if (!promptType) { | ||
| continue; | ||
| } | ||
| children.push(...await this._collectFromTypeDir(stat.stat.children, pluginUri, promptType, groupKey, isBundleItem, token)); | ||
| } | ||
| children.sort((a, b) => `${a.type}:${a.name}`.localeCompare(`${b.type}:${b.name}`)); | ||
| } catch (err) { | ||
| this._logService.trace(`[AgentCustomizationItemProvider] Failed to expand plugin ${pluginUri.toString()}: ${err}`); | ||
| return []; | ||
| } | ||
|
|
||
| this._expansionCache.set(pluginUri, { nonce, children }); | ||
| const children = await this._contentExpander.expandPluginContents(plugin.item.uri, plugin.childGroupKey, plugin.isBundleItem, plugin.item.source, token); | ||
| this._expansionCache.set(plugin.item.uri, { nonce: plugin.nonce, children }); |
Comment on lines
+77
to
+89
| const eligible: Entry[] = []; | ||
| const readMetaDataPromises = []; | ||
| for (const child of entries) { | ||
| // Skip dotfiles (e.g. .DS_Store) | ||
| if (child.name.startsWith('.')) { | ||
| continue; | ||
| } | ||
| if (!child.isDirectory) { | ||
| continue; | ||
| } | ||
| eligible.push(child); | ||
| readMetaDataPromises.push(this.readPromptMetadata(joinPath(child.resource, SKILL_FILENAME), token)); | ||
| } |
roblourens
previously approved these changes
May 21, 2026
roblourens
approved these changes
May 21, 2026
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.
No description provided.