MCPcopy
hub / github.com/claude-code-best/claude-code / loadSessionOnlyPlugins

Function loadSessionOnlyPlugins

src/utils/plugins/pluginLoader.ts:2931–2996  ·  view source on GitHub ↗

* Load session-only plugins from --plugin-dir CLI flag. * * These plugins are loaded directly without going through the marketplace system. * They appear with source='plugin-name@inline' and are always enabled for the current session. * * @param sessionPluginPaths - Array of plugin directory pa

(
  sessionPluginPaths: Array<string>,
)

Source from the content-addressed store, hash-verified

2929 * @returns LoadedPlugin objects and any errors encountered
2930 */
2931async function loadSessionOnlyPlugins(
2932 sessionPluginPaths: Array<string>,
2933): Promise<{ plugins: LoadedPlugin[]; errors: PluginError[] }> {
2934 if (sessionPluginPaths.length === 0) {
2935 return { plugins: [], errors: [] }
2936 }
2937
2938 const plugins: LoadedPlugin[] = []
2939 const errors: PluginError[] = []
2940
2941 for (const [index, pluginPath] of sessionPluginPaths.entries()) {
2942 try {
2943 const resolvedPath = resolve(pluginPath)
2944
2945 if (!(await pathExists(resolvedPath))) {
2946 logForDebugging(
2947 `Plugin path does not exist: ${resolvedPath}, skipping`,
2948 { level: 'warn' },
2949 )
2950 errors.push({
2951 type: 'path-not-found',
2952 source: `inline[${index}]`,
2953 path: resolvedPath,
2954 component: 'commands',
2955 })
2956 continue
2957 }
2958
2959 const dirName = basename(resolvedPath)
2960 const { plugin, errors: pluginErrors } = await createPluginFromPath(
2961 resolvedPath,
2962 `${dirName}@inline`, // temporary, will be updated after we know the real name
2963 true, // always enabled
2964 dirName,
2965 )
2966
2967 // Update source to use the actual plugin name from manifest
2968 plugin.source = `${plugin.name}@inline`
2969 plugin.repository = `${plugin.name}@inline`
2970
2971 plugins.push(plugin)
2972 errors.push(...pluginErrors)
2973
2974 logForDebugging(`Loaded inline plugin from path: ${plugin.name}`)
2975 } catch (error) {
2976 const errorMsg = errorMessage(error)
2977 logForDebugging(
2978 `Failed to load session plugin from ${pluginPath}: ${errorMsg}`,
2979 { level: 'warn' },
2980 )
2981 errors.push({
2982 type: 'generic-error',
2983 source: `inline[${index}]`,
2984 error: `Failed to load plugin: ${errorMsg}`,
2985 })
2986 }
2987 }
2988

Callers 1

assemblePluginLoadResultFunction · 0.85

Calls 7

pathExistsFunction · 0.85
createPluginFromPathFunction · 0.85
entriesMethod · 0.80
resolveFunction · 0.50
logForDebuggingFunction · 0.50
errorMessageFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected