| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import type { Command } from '../commands.js' |
| import type { BundledSkillDefinition } from '../skills/bundledSkills.js' |
| import type { BuiltinPluginDefinition, LoadedPlugin } from '../types/plugin.js' |
| import { getSettings_DEPRECATED } from '../utils/settings/settings.js' |
|
|
| const BUILTIN_PLUGINS: Map<string, BuiltinPluginDefinition> = new Map() |
|
|
| export const BUILTIN_MARKETPLACE_NAME = 'builtin' |
|
|
| |
| |
| |
| export function registerBuiltinPlugin( |
| definition: BuiltinPluginDefinition, |
| ): void { |
| BUILTIN_PLUGINS.set(definition.name, definition) |
| } |
|
|
| |
| |
| |
| export function isBuiltinPluginId(pluginId: string): boolean { |
| return pluginId.endsWith(`@${BUILTIN_MARKETPLACE_NAME}`) |
| } |
|
|
| |
| |
| |
| |
| |
| export function getBuiltinPluginDefinition( |
| name: string, |
| ): BuiltinPluginDefinition | undefined { |
| return BUILTIN_PLUGINS.get(name) |
| } |
|
|
| |
| |
| |
| |
| |
| export function getBuiltinPlugins(): { |
| enabled: LoadedPlugin[] |
| disabled: LoadedPlugin[] |
| } { |
| const settings = getSettings_DEPRECATED() |
| const enabled: LoadedPlugin[] = [] |
| const disabled: LoadedPlugin[] = [] |
|
|
| for (const [name, definition] of BUILTIN_PLUGINS) { |
| if (definition.isAvailable && !definition.isAvailable()) { |
| continue |
| } |
|
|
| const pluginId = `${name}@${BUILTIN_MARKETPLACE_NAME}` |
| const userSetting = settings?.enabledPlugins?.[pluginId] |
| |
| const isEnabled = |
| userSetting !== undefined |
| ? userSetting === true |
| : (definition.defaultEnabled ?? true) |
|
|
| const plugin: LoadedPlugin = { |
| name, |
| manifest: { |
| name, |
| description: definition.description, |
| version: definition.version, |
| }, |
| path: BUILTIN_MARKETPLACE_NAME, |
| source: pluginId, |
| repository: pluginId, |
| enabled: isEnabled, |
| isBuiltin: true, |
| hooksConfig: definition.hooks, |
| mcpServers: definition.mcpServers, |
| } |
|
|
| if (isEnabled) { |
| enabled.push(plugin) |
| } else { |
| disabled.push(plugin) |
| } |
| } |
|
|
| return { enabled, disabled } |
| } |
|
|
| |
| |
| |
| |
| export function getBuiltinPluginSkillCommands(): Command[] { |
| const { enabled } = getBuiltinPlugins() |
| const commands: Command[] = [] |
|
|
| for (const plugin of enabled) { |
| const definition = BUILTIN_PLUGINS.get(plugin.name) |
| if (!definition?.skills) continue |
| for (const skill of definition.skills) { |
| commands.push(skillDefinitionToCommand(skill)) |
| } |
| } |
|
|
| return commands |
| } |
|
|
| |
| |
| |
| export function clearBuiltinPlugins(): void { |
| BUILTIN_PLUGINS.clear() |
| } |
|
|
| |
|
|
| function skillDefinitionToCommand(definition: BundledSkillDefinition): Command { |
| return { |
| type: 'prompt', |
| name: definition.name, |
| description: definition.description, |
| hasUserSpecifiedDescription: true, |
| allowedTools: definition.allowedTools ?? [], |
| argumentHint: definition.argumentHint, |
| whenToUse: definition.whenToUse, |
| model: definition.model, |
| disableModelInvocation: definition.disableModelInvocation ?? false, |
| userInvocable: definition.userInvocable ?? true, |
| contentLength: 0, |
| |
| |
| |
| |
| source: 'bundled', |
| loadedFrom: 'bundled', |
| hooks: definition.hooks, |
| context: definition.context, |
| agent: definition.agent, |
| isEnabled: definition.isEnabled ?? (() => true), |
| isHidden: !(definition.userInvocable ?? true), |
| progressMessage: 'running', |
| getPromptForCommand: definition.getPromptForCommand, |
| } |
| } |
|
|