MCPcopy Index your code
hub / github.com/codeaashu/claude-code / loadSessionOnlyPlugins

Function loadSessionOnlyPlugins

src/utils/plugins/pluginLoader.ts:2928–2993  ·  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

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

Callers 1

assemblePluginLoadResultFunction · 0.85

Calls 7

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

Tested by

no test coverage detected