/** * Claude Code Plugin Types * * Type definitions for Claude Code plugin system compatibility. * Based on https://code.claude.com/docs/en/plugins-reference */ export type PluginScope = "user" | "project" | "local" | "managed"; /** * Plugin installation entry in installed_plugins.json */ export interface PluginInstallation { scope: PluginScope; installPath: string; version: string; installedAt: string; lastUpdated: string; gitCommitSha?: string; isLocal?: boolean; } /** * Installed plugins database v1 (legacy) * plugins stored as direct objects */ export interface InstalledPluginsDatabaseV1 { version: 1; plugins: Record; } /** * Installed plugins database v2 * plugins stored as arrays keyed by plugin identifier */ export interface InstalledPluginsDatabaseV2 { version: 2; plugins: Record; } /** * Installed plugins database v3 entry (current Claude Code format) * A flat array of plugin entries, each containing name and marketplace fields * used to construct the plugin key as "name@marketplace". */ export interface InstalledPluginEntryV3 { name: string; marketplace: string; scope: PluginScope; version: string; installPath: string; lastUpdated: string; gitCommitSha?: string; } /** * Installed plugins database structure * Located at ~/.claude/plugins/installed_plugins.json * * Supports three formats: * - v1: { version: 1, plugins: Record } * - v2: { version: 2, plugins: Record } * - v3: InstalledPluginEntryV3[] (flat array, current Claude Code format) */ export type InstalledPluginsDatabase = InstalledPluginsDatabaseV1 | InstalledPluginsDatabaseV2 | InstalledPluginEntryV3[]; /** * Plugin author information */ export interface PluginAuthor { name?: string; email?: string; url?: string; } /** * Plugin manifest (plugin.json) * Located at /.claude-plugin/plugin.json */ export interface PluginManifest { name: string; version?: string; description?: string; author?: PluginAuthor; homepage?: string; repository?: string; license?: string; keywords?: string[]; commands?: string | string[]; agents?: string | string[]; skills?: string | string[]; hooks?: string | HooksConfig; mcpServers?: string | McpServersConfig; lspServers?: string | LspServersConfig; outputStyles?: string | string[]; } /** * Hooks configuration */ export type HookEntry = { type: "command"; command?: string; } | { type: "prompt"; prompt?: string; } | { type: "agent"; agent?: string; } | { type: "http"; url: string; headers?: Record; allowedEnvVars?: string[]; timeout?: number; }; export interface HookMatcher { matcher?: string; hooks: HookEntry[]; } export interface HooksConfig { hooks?: { PreToolUse?: HookMatcher[]; PostToolUse?: HookMatcher[]; PostToolUseFailure?: HookMatcher[]; PermissionRequest?: HookMatcher[]; UserPromptSubmit?: HookMatcher[]; Notification?: HookMatcher[]; Stop?: HookMatcher[]; SubagentStart?: HookMatcher[]; SubagentStop?: HookMatcher[]; SessionStart?: HookMatcher[]; SessionEnd?: HookMatcher[]; PreCompact?: HookMatcher[]; }; } /** * MCP servers configuration in plugin */ export interface PluginMcpServer { command?: string; args?: string[]; env?: Record; cwd?: string; url?: string; type?: "stdio" | "http" | "sse"; disabled?: boolean; } export interface McpServersConfig { mcpServers?: Record; } /** * LSP server configuration */ export interface LspServerConfig { command: string; args?: string[]; extensionToLanguage: Record; transport?: "stdio" | "socket"; env?: Record; initializationOptions?: Record; settings?: Record; workspaceFolder?: string; startupTimeout?: number; shutdownTimeout?: number; restartOnCrash?: boolean; maxRestarts?: number; loggingConfig?: { args?: string[]; env?: Record; }; } export interface LspServersConfig { [language: string]: LspServerConfig; } /** * Loaded plugin with all resolved components */ export interface LoadedPlugin { name: string; version: string; scope: PluginScope; installPath: string; manifest?: PluginManifest; pluginKey: string; commandsDir?: string; agentsDir?: string; skillsDir?: string; hooksPath?: string; mcpPath?: string; lspPath?: string; } /** * Plugin load result with all components */ export interface PluginLoadResult { plugins: LoadedPlugin[]; errors: PluginLoadError[]; } export interface PluginLoadError { pluginKey: string; installPath: string; error: string; } /** * Claude settings from ~/.claude/settings.json */ export interface ClaudeSettings { enabledPlugins?: Record; [key: string]: unknown; } /** * Plugin loader options */ export interface PluginLoaderOptions { /** * Override enabled plugins from oh-my-opencode config. * Key format: "pluginName@marketplace" (e.g., "shell-scripting@claude-code-workflows") * Value: true = enabled, false = disabled * * This takes precedence over ~/.claude/settings.json enabledPlugins */ enabledPluginsOverride?: Record; }