MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / refreshPluginState

Function refreshPluginState

src/cli/print.ts:1765–1790  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1763 // settings were fetched. Without clearing, getCommands() would rebuild
1764 // from a stale plugin list.
1765 async function refreshPluginState(): Promise<void> {
1766 // refreshActivePlugins handles the full cache sweep (clearAllCaches),
1767 // reloads all plugin component loaders, writes AppState.plugins +
1768 // AppState.agentDefinitions, registers hooks, and bumps mcp.pluginReconnectKey.
1769 const { agentDefinitions: freshAgentDefs } =
1770 await refreshActivePlugins(setAppState)
1771
1772 // Headless-specific: currentCommands/currentAgents are local mutable refs
1773 // captured by the query loop (REPL uses AppState instead). getCommands is
1774 // fresh because refreshActivePlugins cleared its cache.
1775 currentCommands = await getCommands(cwd())
1776
1777 // Preserve SDK-provided agents (--agents CLI flag or SDK initialize
1778 // control_request) — both inject via parseAgentsFromJson with
1779 // source='flagSettings'. loadMarkdownFilesForSubdir never assigns this
1780 // source, so it cleanly discriminates "injected, not disk-loadable".
1781 //
1782 // The previous filter used a negative set-diff (!freshAgentTypes.has(a))
1783 // which also matched plugin agents that were in the poisoned initial
1784 // currentAgents but correctly excluded from freshAgentDefs after managed
1785 // settings applied — leaking policy-blocked agents into the init message.
1786 // See gh-23085: isBridgeEnabled() at Commander-definition time poisoned
1787 // the settings cache before setEligibility(true) ran.
1788 const sdkAgents = currentAgents.filter(a => a.source === 'flagSettings')
1789 currentAgents = [...freshAgentDefs.allAgents, ...sdkAgents]
1790 }
1791
1792 // Re-diff MCP configs after plugin state changes. Filters to
1793 // process-transport-supported types and carries SDK-mode servers through

Callers 1

runFunction · 0.85

Calls 3

refreshActivePluginsFunction · 0.85
getCommandsFunction · 0.85
cwdFunction · 0.85

Tested by

no test coverage detected