Skip to content

chat: expose PLUGIN_ROOT to local plugin hooks - #338967

Merged
Paul (pwang347) merged 3 commits into
mainfrom
pwang/fix-local-plugin-root-hooks
Sep 30, 2026
Merged

Paul (pwang347) merged 3 commits into
mainfrom
pwang/fix-local-plugin-root-hooks

Conversation

@pwang347

@pwang347 Paul (pwang347) commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • expose PLUGIN_ROOT to Copilot-format and Agent Plugins v1 hooks collected by the Local chat harness
  • expand ${PLUGIN_ROOT} in hook commands using the contributing plugin directory
  • align Local behavior with Open Plugin hooks and the Copilot Agent Host runtime
  • cover plugin-level and plugin-provided custom-agent hooks

Reproduction

An Agent Plugins v1 sessionStart hook contributed through a managed plugin runs on the Local harness, but its subprocess receives no PLUGIN_ROOT. The same plugin receives PLUGIN_ROOT when the session uses Copilot Agent Host.

This can surface when a session expected to use Copilot remains on Local: the hook itself functions, while scripts that resolve bundled resources through PLUGIN_ROOT fail.

Validation

  • npm run compile — passed with 0 errors
  • ./scripts/test.sh --run src/vs/platform/agentPlugins/test/common/pluginParsers.test.ts --run src/vs/workbench/contrib/chat/test/common/plugins/agentPluginFormatDetection.test.ts --run src/vs/workbench/contrib/chat/test/common/plugins/shellQuotePluginRootInCommand.test.ts --run src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts — 240 passing
  • npm run eslint -- src/vs/platform/agentPlugins/common/pluginParsers.ts src/vs/platform/agentPlugins/test/common/pluginParsers.test.ts src/vs/workbench/contrib/chat/test/common/plugins/agentPluginFormatDetection.test.ts src/vs/workbench/contrib/chat/test/common/plugins/shellQuotePluginRootInCommand.test.ts src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts — passed
  • before/fixed Local harness scenarios on macOS arm64 — passed their expected assertions

Evidence

Before

Before: the managed plugin hook runs, but PLUGIN_ROOT is missing.

plugin-root-before.mp4

After

After: the same hook receives the contributing Agent Plugins v1 directory as PLUGIN_ROOT.

plugin-root-after.mp4

Copilot AI balanced review requested due to automatic review settings September 30, 2026 19:23
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: e9cfa3dc Current: 354e634b

Changed (2)

sessions/accountMenu/WeeklyAndFiveHourLimits/Light
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/DiscoverPluginsLoadingMore/Light
Before After
before after

2 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Plugin paths containing shell metacharacters can be corrupted or evaluated during command interpolation.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Exposes PLUGIN_ROOT to Copilot and Agent Plugins v1 hooks in the Local chat harness.

Changes:

  • Adds plugin-root interpolation and environment variables.
  • Covers plugin-level and custom-agent hooks.
  • Updates tests and plugin documentation.
File Description
pluginParsers.ts Enables root interpolation for two plugin formats.
pluginParsers.test.ts Tests Agent Plugin hook expansion.
agentPluginFormatDetection.test.ts Tests Copilot plugin discovery behavior.
promptsService.test.ts Tests custom-agent hook expansion.
AGENTS_PLUGINS.md Documents format behavior.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pwang347
Paul (pwang347) marked this pull request as ready for review September 30, 2026 20:23
@pwang347
Paul (pwang347) enabled auto-merge (squash) September 30, 2026 20:23
@pwang347
Paul (pwang347) merged commit 90243d1 into main Sep 30, 2026
35 checks passed
@pwang347
Paul (pwang347) deleted the pwang/fix-local-plugin-root-hooks branch September 30, 2026 21:01
@vs-code-engineering vs-code-engineering Bot added this to the 1.141.0 milestone Sep 30, 2026
Ashok Raj (ashokraj2011) added a commit to ashokraj2011/singularityflow that referenced this pull request Nov 9, 2026
… as VS Code before 1.141 does

VS Code passes PLUGIN_ROOT to a plugin's hooks only from 1.141 (microsoft/vscode#338967). An office laptop
on 1.126 refused every tool call with SFLOW_HOOK_PLUGIN_ROOT_UNAVAILABLE, and reload or reinstall could not
help. With no usable PLUGIN_ROOT or COPILOT_PLUGIN_ROOT, the hooks now read the folder recorded beside SFlow's
Copilot mode file, which plugin install writes from Copilot's own record and the launcher keeps current. Only
an absolute folder holding the launcher is used; otherwise the refusal now names the VS Code version.

The closed-composer test allows exactly that one SFlow state path under the home folder and still forbids
any other, listing and evaluation (owner decision).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Nov 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants