Skip to content

support for chat customizations in parent repo folders#300916

Merged
aeschli merged 2 commits intomainfrom
aeschli/corresponding-earwig-507
Mar 12, 2026
Merged

support for chat customizations in parent repo folders#300916
aeschli merged 2 commits intomainfrom
aeschli/corresponding-earwig-507

Conversation

@aeschli
Copy link
Contributor

@aeschli aeschli commented Mar 11, 2026

Fixes #293277

Support for finding chat customizations (instructions/prompts/agents/skills/..) in parent repositories.
This was requested by users of monorepos where users only open subfolders in VS Code.

  • new setting chat.useCustomizationsInParentRepositories, default false (for now)
  • when enabled: if a workspaceFolder is not a repository (does not have a .git folder), walk up until we find repository folder. If found, and the folder is trusted, use chat customizations of that folder and all folders in between.
  • incudes agent instructions (AGENT.md, CLAUDE.md...), instructions, skills, prompts, agents and hooks using the locations configured in the corresponding settings.

Copilot AI review requested due to automatic review settings March 11, 2026 20:55
@aeschli aeschli enabled auto-merge (squash) March 11, 2026 20:55
@aeschli aeschli self-assigned this Mar 11, 2026
@vs-code-engineering vs-code-engineering bot added this to the 1.112.0 milestone Mar 11, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends chat customization discovery (prompts, instructions, agents, etc.) to optionally search parent repository folders (walking up to a .git root) and gates that behavior behind the chat.searchRootRepositoryCustomizations setting and workspace trust checks.

Changes:

  • Add parent-repo root discovery logic to PromptFilesLocator, including trust-gating and updated watcher refresh behavior.
  • Refactor prompt discovery to use resolved locations with { parent, filePattern } metadata, and update the resolved-source-folder shape accordingly.
  • Update and expand tests to cover parent-repo discovery and trust behavior across prompt discovery and automatic instructions.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/vs/workbench/test/common/workbenchTestServices.ts Enhances the test workspace trust service with trusted URI support used by parent-repo discovery.
src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.ts Implements parent repo folder walking to .git, trust checks, and refactors location resolution to include parent/filePattern.
src/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations.ts Extends IResolvedPromptSourceFolder with parent and filePattern metadata.
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts Passes a logger into getWorkspaceFolderRoots for discovery logging.
src/vs/workbench/contrib/chat/test/common/promptSyntax/utils/promptFilesLocator.test.ts Refactors tests to use mockFiles and adds coverage for getWorkspaceFolderRoots behavior.
src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts Adds integration tests asserting parent-repo discovery and “untrusted parent repo” exclusion.
src/vs/workbench/contrib/chat/test/common/promptSyntax/computeAutomaticInstructions.test.ts Adds trust + .git fixtures to verify parent-repo discovery for automatic instructions.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 409 to 415
getUriTrustInfo(uri: URI): Promise<IWorkspaceTrustUriInfo> {
throw new Error('Method not implemented.');
return Promise.resolve({ trusted: this.trustedUris.has(uri), uri });
}

async setTrustedUris(folders: URI[]): Promise<void> {
throw new Error('Method not implemented.');
this.trustedUris = new ResourceSet(folders);
}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestWorkspaceTrustManagementService.getUriTrustInfo currently reports trust only when the URI is an exact member of trustedUris, which is inconsistent with isWorkspaceTrusted() (defaults to true) and doesn’t match typical trust semantics (trust applying to descendants via isEqualOrParent). Also, setTrustedUris updates state without firing onDidChangeTrustedFolders, so components listening for trust changes won’t react in tests. Consider (1) making getUriTrustInfo incorporate this.trusted and treat URIs under any trusted root as trusted, and (2) firing _onDidChangeTrustedFolders from setTrustedUris (and possibly also when trust state changes).

See below for a potential fix:

		// If the workspace is trusted, all URIs are trusted
		if (this.trusted) {
			return Promise.resolve({ trusted: true, uri });
		}

		// Otherwise, trust applies to any URI that is equal to or a parent of a trusted root
		let trusted = false;
		for (const trustedUri of this.trustedUris) {
			if (isEqualOrParent(uri, trustedUri, !isLinux)) {
				trusted = true;
				break;
			}
		}

		return Promise.resolve({ trusted, uri });
	}

	async setTrustedUris(folders: URI[]): Promise<void> {
		this.trustedUris = new ResourceSet(folders);
		this._onDidChangeTrustedFolders.fire();

Copilot uses AI. Check for mistakes.
@aeschli aeschli changed the title support for parent repo folders for all chat customizations support for chat customizations in parent repo folders Mar 11, 2026
@aeschli aeschli merged commit bb5835f into main Mar 12, 2026
21 checks passed
@aeschli aeschli deleted the aeschli/corresponding-earwig-507 branch March 12, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Customizations: Nested directory discovery for monorepo support

3 participants