@within-7/minto 0.3.6 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/{cli.js → cli.cjs} +25 -23
  2. package/dist/commands/agents/AgentsCommand.js +459 -655
  3. package/dist/commands/agents/AgentsCommand.js.map +2 -2
  4. package/dist/commands/agents/types.js +1 -0
  5. package/dist/commands/agents/types.js.map +2 -2
  6. package/dist/commands/agents/utils/fileOperations.js +96 -36
  7. package/dist/commands/agents/utils/fileOperations.js.map +3 -3
  8. package/dist/commands/agents/utils/index.js +3 -1
  9. package/dist/commands/agents/utils/index.js.map +2 -2
  10. package/dist/commands/context.js +54 -23
  11. package/dist/commands/context.js.map +2 -2
  12. package/dist/commands/export.js +673 -93
  13. package/dist/commands/export.js.map +2 -2
  14. package/dist/commands/language.js +110 -0
  15. package/dist/commands/language.js.map +7 -0
  16. package/dist/commands/mcp-interactive.js +419 -217
  17. package/dist/commands/mcp-interactive.js.map +2 -2
  18. package/dist/commands/model.js +415 -66
  19. package/dist/commands/model.js.map +2 -2
  20. package/dist/commands/new.js +56 -0
  21. package/dist/commands/new.js.map +7 -0
  22. package/dist/commands/permissions.js +75 -49
  23. package/dist/commands/permissions.js.map +2 -2
  24. package/dist/commands/plugin.js +882 -185
  25. package/dist/commands/plugin.js.map +3 -3
  26. package/dist/commands/resume.js +251 -16
  27. package/dist/commands/resume.js.map +2 -2
  28. package/dist/commands/sandbox.js +168 -70
  29. package/dist/commands/sandbox.js.map +2 -2
  30. package/dist/commands/sessions.js +224 -0
  31. package/dist/commands/sessions.js.map +7 -0
  32. package/dist/commands/setup.js +596 -109
  33. package/dist/commands/setup.js.map +2 -2
  34. package/dist/commands/stats.js +292 -0
  35. package/dist/commands/stats.js.map +7 -0
  36. package/dist/commands/status.js +75 -7
  37. package/dist/commands/status.js.map +2 -2
  38. package/dist/commands/undo.js +154 -180
  39. package/dist/commands/undo.js.map +2 -2
  40. package/dist/commands.js +6 -0
  41. package/dist/commands.js.map +2 -2
  42. package/dist/components/AskUserQuestionDialog/AskUserQuestionDialog.js +3 -2
  43. package/dist/components/AskUserQuestionDialog/AskUserQuestionDialog.js.map +2 -2
  44. package/dist/components/Config.js +9 -8
  45. package/dist/components/Config.js.map +2 -2
  46. package/dist/components/HeaderBar.js +2 -1
  47. package/dist/components/HeaderBar.js.map +2 -2
  48. package/dist/components/Help.js +166 -32
  49. package/dist/components/Help.js.map +2 -2
  50. package/dist/components/HotkeyHelpPanel.js +46 -44
  51. package/dist/components/HotkeyHelpPanel.js.map +2 -2
  52. package/dist/components/InfoPanel/InfoPanel.js +123 -0
  53. package/dist/components/InfoPanel/InfoPanel.js.map +7 -0
  54. package/dist/components/InfoPanel/index.js +5 -0
  55. package/dist/components/InfoPanel/index.js.map +7 -0
  56. package/dist/components/InfoPanel/types.js +1 -0
  57. package/dist/components/InfoPanel/types.js.map +7 -0
  58. package/dist/components/Logo.js +5 -2
  59. package/dist/components/Logo.js.map +2 -2
  60. package/dist/components/MCPServerApprovalDialog.js +6 -5
  61. package/dist/components/MCPServerApprovalDialog.js.map +2 -2
  62. package/dist/components/MCPServerMultiselectDialog.js +5 -4
  63. package/dist/components/MCPServerMultiselectDialog.js.map +2 -2
  64. package/dist/components/MessageSelector.js +4 -3
  65. package/dist/components/MessageSelector.js.map +2 -2
  66. package/dist/components/ModelConfig.js +13 -12
  67. package/dist/components/ModelConfig.js.map +2 -2
  68. package/dist/components/ModelListManager.js +4 -3
  69. package/dist/components/ModelListManager.js.map +2 -2
  70. package/dist/components/ModelSelector/BrandTextInput.js +43 -0
  71. package/dist/components/ModelSelector/BrandTextInput.js.map +7 -0
  72. package/dist/components/ModelSelector/ModelSelector.js +419 -501
  73. package/dist/components/ModelSelector/ModelSelector.js.map +2 -2
  74. package/dist/components/ModelSelector/WizardContainer.js +45 -0
  75. package/dist/components/ModelSelector/WizardContainer.js.map +7 -0
  76. package/dist/components/ModelSelector/index.js +1 -3
  77. package/dist/components/ModelSelector/index.js.map +2 -2
  78. package/dist/components/PromptInput.js +77 -44
  79. package/dist/components/PromptInput.js.map +2 -2
  80. package/dist/components/SensitiveFileWarning.js +12 -8
  81. package/dist/components/SensitiveFileWarning.js.map +2 -2
  82. package/dist/components/SimpleSelector/SimpleSelector.js +154 -0
  83. package/dist/components/SimpleSelector/SimpleSelector.js.map +7 -0
  84. package/dist/components/SimpleSelector/index.js +5 -0
  85. package/dist/components/SimpleSelector/index.js.map +7 -0
  86. package/dist/components/SimpleSelector/types.js +1 -0
  87. package/dist/components/SimpleSelector/types.js.map +7 -0
  88. package/dist/components/StatusOverlayContent.js +21 -0
  89. package/dist/components/StatusOverlayContent.js.map +7 -0
  90. package/dist/components/TabbedListView/ScrollableList.js +117 -0
  91. package/dist/components/TabbedListView/ScrollableList.js.map +7 -0
  92. package/dist/components/TabbedListView/SearchInput.js +23 -0
  93. package/dist/components/TabbedListView/SearchInput.js.map +7 -0
  94. package/dist/components/TabbedListView/TabBar.js +20 -0
  95. package/dist/components/TabbedListView/TabBar.js.map +7 -0
  96. package/dist/components/TabbedListView/TabbedListView.js +246 -0
  97. package/dist/components/TabbedListView/TabbedListView.js.map +7 -0
  98. package/dist/components/TabbedListView/index.js +11 -0
  99. package/dist/components/TabbedListView/index.js.map +7 -0
  100. package/dist/components/TabbedListView/types.js +1 -0
  101. package/dist/components/TabbedListView/types.js.map +7 -0
  102. package/dist/components/TodoChangeBlock.js +6 -5
  103. package/dist/components/TodoChangeBlock.js.map +3 -3
  104. package/dist/components/TodoPanel.js +6 -3
  105. package/dist/components/TodoPanel.js.map +3 -3
  106. package/dist/components/TrustDialog.js +6 -5
  107. package/dist/components/TrustDialog.js.map +2 -2
  108. package/dist/components/messages/UserToolResultMessage/UserToolCanceledMessage.js +2 -1
  109. package/dist/components/messages/UserToolResultMessage/UserToolCanceledMessage.js.map +2 -2
  110. package/dist/constants/macros.js +1 -1
  111. package/dist/constants/macros.js.map +1 -1
  112. package/dist/constants/product.js +2 -2
  113. package/dist/constants/product.js.map +1 -1
  114. package/dist/constants/prompts.js +17 -0
  115. package/dist/constants/prompts.js.map +2 -2
  116. package/dist/constants/toolInputExamples.js +5 -1
  117. package/dist/constants/toolInputExamples.js.map +2 -2
  118. package/dist/core/backupHook.js +29 -0
  119. package/dist/core/backupHook.js.map +7 -0
  120. package/dist/core/config/defaults.js +8 -2
  121. package/dist/core/config/defaults.js.map +2 -2
  122. package/dist/core/config/schema.js +14 -2
  123. package/dist/core/config/schema.js.map +2 -2
  124. package/dist/core/costTracker.js +0 -16
  125. package/dist/core/costTracker.js.map +2 -2
  126. package/dist/core/tokenStatsManager.js +5 -0
  127. package/dist/core/tokenStatsManager.js.map +2 -2
  128. package/dist/cost-tracker.js +0 -16
  129. package/dist/cost-tracker.js.map +2 -2
  130. package/dist/entrypoints/bootstrap.js +56 -0
  131. package/dist/entrypoints/bootstrap.js.map +7 -0
  132. package/dist/entrypoints/cli.js +164 -23
  133. package/dist/entrypoints/cli.js.map +3 -3
  134. package/dist/history.js +75 -15
  135. package/dist/history.js.map +2 -2
  136. package/dist/i18n/index.js +2 -2
  137. package/dist/i18n/index.js.map +2 -2
  138. package/dist/i18n/locales/en.js +582 -1
  139. package/dist/i18n/locales/en.js.map +2 -2
  140. package/dist/i18n/locales/zh-CN.js +582 -1
  141. package/dist/i18n/locales/zh-CN.js.map +2 -2
  142. package/dist/i18n/types.js.map +1 -1
  143. package/dist/index.js +1 -1
  144. package/dist/index.js.map +2 -2
  145. package/dist/messages.js +11 -0
  146. package/dist/messages.js.map +2 -2
  147. package/dist/permissions.js.map +2 -2
  148. package/dist/query.js +9 -0
  149. package/dist/query.js.map +2 -2
  150. package/dist/screens/REPL.js +45 -7
  151. package/dist/screens/REPL.js.map +2 -2
  152. package/dist/services/customCommands.js +44 -16
  153. package/dist/services/customCommands.js.map +2 -2
  154. package/dist/services/plugins/lspServers.js +1 -1
  155. package/dist/services/plugins/lspServers.js.map +2 -2
  156. package/dist/services/plugins/pluginRuntime.js +2 -1
  157. package/dist/services/plugins/pluginRuntime.js.map +2 -2
  158. package/dist/services/plugins/pluginValidation.js +10 -3
  159. package/dist/services/plugins/pluginValidation.js.map +2 -2
  160. package/dist/services/plugins/skillMarketplace.js +16 -8
  161. package/dist/services/plugins/skillMarketplace.js.map +2 -2
  162. package/dist/services/systemReminder.js +17 -6
  163. package/dist/services/systemReminder.js.map +2 -2
  164. package/dist/tools/FileEditTool/FileEditTool.js +7 -0
  165. package/dist/tools/FileEditTool/FileEditTool.js.map +2 -2
  166. package/dist/tools/FileWriteTool/FileWriteTool.js +7 -0
  167. package/dist/tools/FileWriteTool/FileWriteTool.js.map +2 -2
  168. package/dist/tools/MultiEditTool/MultiEditTool.js +7 -0
  169. package/dist/tools/MultiEditTool/MultiEditTool.js.map +2 -2
  170. package/dist/tools/NotebookEditTool/NotebookEditTool.js +2 -0
  171. package/dist/tools/NotebookEditTool/NotebookEditTool.js.map +2 -2
  172. package/dist/tools/TaskTool/TaskTool.js +179 -1
  173. package/dist/tools/TaskTool/TaskTool.js.map +2 -2
  174. package/dist/tools/TodoWriteTool/prompt.js +21 -0
  175. package/dist/tools/TodoWriteTool/prompt.js.map +2 -2
  176. package/dist/tools/URLFetcherTool/prompt.js +14 -9
  177. package/dist/tools/URLFetcherTool/prompt.js.map +2 -2
  178. package/dist/tools/WebSearchTool/prompt.js +12 -6
  179. package/dist/tools/WebSearchTool/prompt.js.map +2 -2
  180. package/dist/types/PermissionMode.js +30 -1
  181. package/dist/types/PermissionMode.js.map +2 -2
  182. package/dist/types/plugin.js +2 -4
  183. package/dist/types/plugin.js.map +2 -2
  184. package/dist/utils/agentHookExecutor.js +103 -0
  185. package/dist/utils/agentHookExecutor.js.map +7 -0
  186. package/dist/utils/agentLoader.js +272 -32
  187. package/dist/utils/agentLoader.js.map +2 -2
  188. package/dist/utils/agentMemory.js +134 -0
  189. package/dist/utils/agentMemory.js.map +7 -0
  190. package/dist/utils/claudeCodeSync.js +439 -0
  191. package/dist/utils/claudeCodeSync.js.map +7 -0
  192. package/dist/utils/config.js +52 -24
  193. package/dist/utils/config.js.map +2 -2
  194. package/dist/utils/configPaths.js +199 -0
  195. package/dist/utils/configPaths.js.map +7 -0
  196. package/dist/utils/execFileNoThrow.js +2 -1
  197. package/dist/utils/execFileNoThrow.js.map +2 -2
  198. package/dist/utils/historyManager.js +234 -0
  199. package/dist/utils/historyManager.js.map +7 -0
  200. package/dist/utils/marketplaceManager.js +80 -43
  201. package/dist/utils/marketplaceManager.js.map +2 -2
  202. package/dist/utils/messages.js +13 -8
  203. package/dist/utils/messages.js.map +2 -2
  204. package/dist/utils/migration/index.js +37 -0
  205. package/dist/utils/migration/index.js.map +7 -0
  206. package/dist/utils/migration/migrateHistory.js +273 -0
  207. package/dist/utils/migration/migrateHistory.js.map +7 -0
  208. package/dist/utils/migration/migrateTodos.js +323 -0
  209. package/dist/utils/migration/migrateTodos.js.map +7 -0
  210. package/dist/utils/pasteCache.js +309 -0
  211. package/dist/utils/pasteCache.js.map +7 -0
  212. package/dist/utils/pluginInstaller.js +34 -24
  213. package/dist/utils/pluginInstaller.js.map +2 -2
  214. package/dist/utils/pluginLoader.js +54 -28
  215. package/dist/utils/pluginLoader.js.map +2 -2
  216. package/dist/utils/repoFetcher.js +110 -0
  217. package/dist/utils/repoFetcher.js.map +7 -0
  218. package/dist/utils/sessionIndex.js +192 -0
  219. package/dist/utils/sessionIndex.js.map +7 -0
  220. package/dist/utils/sessionTracker.js +170 -0
  221. package/dist/utils/sessionTracker.js.map +7 -0
  222. package/dist/utils/skillLoader.js +103 -5
  223. package/dist/utils/skillLoader.js.map +2 -2
  224. package/dist/utils/stats.js +417 -0
  225. package/dist/utils/stats.js.map +7 -0
  226. package/dist/utils/stringSubstitution.js +106 -0
  227. package/dist/utils/stringSubstitution.js.map +7 -0
  228. package/dist/utils/teamConfig.js +156 -14
  229. package/dist/utils/teamConfig.js.map +2 -2
  230. package/dist/utils/terminal.js +1 -1
  231. package/dist/utils/terminal.js.map +2 -2
  232. package/dist/utils/todoStorage.js +51 -19
  233. package/dist/utils/todoStorage.js.map +2 -2
  234. package/dist/utils/tooling/safeRender.js.map +2 -2
  235. package/dist/version.js +2 -2
  236. package/dist/version.js.map +1 -1
  237. package/package.json +71 -28
  238. package/scripts/{postinstall.js → postinstall.cjs} +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/services/customCommands.ts"],
4
- "sourcesContent": ["import { existsSync, readFileSync } from 'fs'\nimport { join } from 'path'\nimport { homedir } from 'os'\nimport { memoize } from 'lodash-es'\nimport type { MessageParam } from '@anthropic-ai/sdk/resources/index.mjs'\nimport type { Command } from '@commands'\nimport { getCwd } from '@utils/state'\nimport { execFile } from 'child_process'\nimport { promisify } from 'util'\nimport { loadAllPlugins } from '@utils/pluginLoader'\nimport type { LoadedPlugin, LoadedCommand } from '../types/plugin'\nimport {\n getCurrentProjectConfig,\n saveCurrentProjectConfig,\n} from '@utils/config'\n\nconst execFileAsync = promisify(execFile)\n\n/**\n * Check if a bash command is allowed based on project config permissions\n * This integrates with the same permission system used by BashTool\n */\nfunction isBashCommandAllowed(command: string): boolean {\n const projectConfig = getCurrentProjectConfig()\n const allowedTools = projectConfig?.allowedTools || []\n\n // Check if the command or its prefix is in allowed tools\n const parts = command.split(/\\s+/)\n const baseCommand = parts[0]\n\n // Check exact match\n if (allowedTools.includes(`Bash(${command})`)) {\n return true\n }\n\n // Check base command prefix match\n if (allowedTools.includes(`Bash(${baseCommand}:*)`)) {\n return true\n }\n\n // Safe commands that don't need permission\n const safeCommands = new Set([\n 'git',\n 'ls',\n 'pwd',\n 'date',\n 'which',\n 'echo',\n 'cat',\n 'head',\n 'tail',\n 'wc',\n 'sort',\n 'uniq',\n 'grep',\n 'find',\n 'dirname',\n 'basename',\n ])\n\n if (safeCommands.has(baseCommand)) {\n return true\n }\n\n return false\n}\n\n/**\n * Check if file read is allowed based on project config permissions\n * This integrates with the same permission system used by FileReadTool\n */\nfunction isFileReadAllowed(filePath: string): boolean {\n const projectConfig = getCurrentProjectConfig()\n const allowedTools = projectConfig?.allowedTools || []\n\n // File read is generally allowed - FileReadTool doesn't require permission\n // But we log it for audit purposes\n return true\n}\n\n/**\n * Execute bash commands found in custom command content using !`command` syntax\n *\n * This function processes dynamic command execution within custom commands,\n * following the same security model as the main BashTool but with restricted scope.\n * Commands are executed in the current working directory with a timeout.\n *\n * Security: Commands are checked against the permission system before execution.\n * Only safe commands (git, ls, etc.) or explicitly allowed commands will execute.\n *\n * @param content - The custom command content to process\n * @returns Promise<string> - Content with bash commands replaced by their output\n */\nexport async function executeBashCommands(content: string): Promise<string> {\n // Match patterns like !`git status` or !`command here`\n const bashCommandRegex = /!\\`([^`]+)\\`/g\n const matches = [...content.matchAll(bashCommandRegex)]\n\n if (matches.length === 0) {\n return content\n }\n\n let result = content\n\n for (const match of matches) {\n const fullMatch = match[0]\n const command = match[1].trim()\n\n // Security check: verify command is allowed\n if (!isBashCommandAllowed(command)) {\n console.warn(\n `Custom command bash execution denied: \"${command}\" - not in allowed list`,\n )\n result = result.replace(fullMatch, `(permission denied: ${command})`)\n continue\n }\n\n try {\n // Parse command and args using simple shell parsing\n // This mirrors the approach used in the main BashTool but with stricter limits\n const parts = command.split(/\\s+/)\n const cmd = parts[0]\n const args = parts.slice(1)\n\n // Execute with conservative timeout (5s vs BashTool's 2min default)\n const { stdout, stderr } = await execFileAsync(cmd, args, {\n timeout: 5000,\n encoding: 'utf8',\n cwd: getCwd(), // Use current working directory for consistency\n })\n\n // Replace the bash command with its output, preferring stdout\n const output = stdout.trim() || stderr.trim() || '(no output)'\n result = result.replace(fullMatch, output)\n } catch (error) {\n console.warn(`Failed to execute bash command \"${command}\":`, error)\n result = result.replace(fullMatch, `(error executing: ${command})`)\n }\n }\n\n return result\n}\n\n/**\n * Resolve file references using @filepath syntax within custom commands\n *\n * This function implements file inclusion for custom commands, similar to how\n * the FileReadTool works but with inline processing. Files are read from the\n * current working directory and formatted as markdown code blocks.\n *\n * Security note: Files are read with the same permissions as the main process,\n * following the same security model as other file operations in the system.\n *\n * @param content - The custom command content to process\n * @returns Promise<string> - Content with file references replaced by file contents\n */\nexport async function resolveFileReferences(content: string): Promise<string> {\n // Match patterns like @src/file.js or @path/to/file.txt\n // Use consistent file mention pattern from mentionProcessor\n // Exclude agent and ask-model patterns to avoid conflicts\n const fileRefRegex = /@([a-zA-Z0-9/._-]+(?:\\.[a-zA-Z0-9]+)?)/g\n const matches = [...content.matchAll(fileRefRegex)]\n\n if (matches.length === 0) {\n return content\n }\n\n let result = content\n\n for (const match of matches) {\n const fullMatch = match[0]\n const filePath = match[1]\n\n // Skip agent mentions - these are handled by the mention processor\n if (filePath.startsWith('agent-')) {\n continue\n }\n\n try {\n // Resolve relative to current working directory\n // This maintains consistency with how other file operations work\n const fullPath = join(getCwd(), filePath)\n\n if (existsSync(fullPath)) {\n const fileContent = readFileSync(fullPath, { encoding: 'utf-8' })\n\n // Format file content with filename header for clarity\n // This matches the format used by FileReadTool for consistency\n const formattedContent = `\\n\\n## File: ${filePath}\\n\\`\\`\\`\\n${fileContent}\\n\\`\\`\\`\\n`\n result = result.replace(fullMatch, formattedContent)\n } else {\n result = result.replace(fullMatch, `(file not found: ${filePath})`)\n }\n } catch (error) {\n console.warn(`Failed to read file \"${filePath}\":`, error)\n result = result.replace(fullMatch, `(error reading: ${filePath})`)\n }\n }\n\n return result\n}\n\n/**\n * Validate and process allowed-tools specification from frontmatter\n *\n * This function handles tool restriction specifications in custom commands.\n * When allowed-tools is specified, it adds instructions to the prompt to\n * restrict the assistant to only using those tools.\n *\n * Note: The actual enforcement happens at the prompt level - we instruct the\n * assistant to only use specific tools. This is consistent with how Claude Code\n * handles tool restrictions in agent configurations.\n *\n * @param allowedTools - Array of tool names from frontmatter\n * @returns boolean - True if validation passes\n */\nfunction validateAllowedTools(allowedTools: string[] | undefined): boolean {\n // Validation is always true - the restriction is enforced via prompt injection\n // in getPromptForCommand() which adds the tool restriction text\n return true\n}\n\n/**\n * Frontmatter configuration for custom commands\n *\n * This interface defines the YAML frontmatter structure that can be used\n * to configure custom commands. It mirrors the Claude Desktop custom command\n * system for compatibility while adding Minto-specific enhancements.\n */\nexport interface CustomCommandFrontmatter {\n /** Display name for the command (overrides filename-based naming) */\n name?: string\n /** Brief description of what the command does */\n description?: string\n /** Alternative names that can be used to invoke this command */\n aliases?: string[]\n /** Whether this command is active and can be executed */\n enabled?: boolean\n /** Whether this command should be hidden from help output */\n hidden?: boolean\n /** Message to display while the command is running */\n progressMessage?: string\n /** Named arguments for legacy {arg} placeholder support */\n argNames?: string[]\n /** Tools that this command is restricted to use */\n 'allowed-tools'?: string[]\n}\n\n/**\n * Extended Command interface with scope information\n *\n * This extends the base Command interface to include scope metadata\n * for distinguishing between user-level and project-level commands.\n */\nexport interface CustomCommandWithScope {\n /** Command type - matches PromptCommand */\n type: 'prompt'\n /** Command name */\n name: string\n /** Command description */\n description: string\n /** Whether command is enabled */\n isEnabled: boolean\n /** Whether command is hidden */\n isHidden: boolean\n /** Command aliases */\n aliases?: string[]\n /** Progress message */\n progressMessage: string\n /** Argument names for legacy support */\n argNames?: string[]\n /** User-facing name function */\n userFacingName(): string\n /** Prompt generation function */\n getPromptForCommand(args: string): Promise<MessageParam[]>\n /** Scope indicates whether this is a user or project command */\n scope?: 'user' | 'project'\n}\n\n/**\n * Parsed custom command file representation\n *\n * This interface represents a fully parsed custom command file with\n * separated frontmatter and content sections.\n */\nexport interface CustomCommandFile {\n /** Parsed frontmatter configuration */\n frontmatter: CustomCommandFrontmatter\n /** Markdown content (without frontmatter) */\n content: string\n /** Absolute path to the source file */\n filePath: string\n}\n\n/**\n * Parse YAML frontmatter from markdown content\n *\n * This function extracts and parses YAML frontmatter from markdown files,\n * supporting the same syntax as Jekyll and other static site generators.\n * It handles basic YAML constructs including strings, booleans, and arrays.\n *\n * The parser is intentionally simple and focused on the specific needs of\n * custom commands rather than being a full YAML parser. Complex YAML features\n * like nested objects, multi-line strings, and advanced syntax are not supported.\n *\n * @param content - Raw markdown content with optional frontmatter\n * @returns Object containing parsed frontmatter and remaining content\n */\nexport function parseFrontmatter(content: string): {\n frontmatter: CustomCommandFrontmatter\n content: string\n} {\n const frontmatterRegex = /^---\\s*\\n([\\s\\S]*?)---\\s*\\n?/\n const match = content.match(frontmatterRegex)\n\n if (!match) {\n return { frontmatter: {}, content }\n }\n\n const yamlContent = match[1] || ''\n const markdownContent = content.slice(match[0].length)\n const frontmatter: CustomCommandFrontmatter = {}\n\n // Simple YAML parser for basic key-value pairs and arrays\n // This handles the subset of YAML needed for custom command configuration\n const lines = yamlContent.split('\\n')\n let currentKey: string | null = null\n let arrayItems: string[] = []\n let inArray = false\n\n for (const line of lines) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('#')) continue\n\n // Handle array item continuation (- item)\n if (inArray && trimmed.startsWith('-')) {\n const item = trimmed.slice(1).trim().replace(/['\"]/g, '')\n arrayItems.push(item)\n continue\n }\n\n // End array processing when we hit a new key\n if (inArray && trimmed.includes(':')) {\n if (currentKey) {\n ;(frontmatter as any)[currentKey] = arrayItems\n }\n inArray = false\n arrayItems = []\n currentKey = null\n }\n\n const colonIndex = trimmed.indexOf(':')\n if (colonIndex === -1) continue\n\n const key = trimmed.slice(0, colonIndex).trim()\n const value = trimmed.slice(colonIndex + 1).trim()\n\n // Handle inline arrays [item1, item2]\n if (value.startsWith('[') && value.endsWith(']')) {\n const items = value\n .slice(1, -1)\n .split(',')\n .map(s => s.trim().replace(/['\"]/g, ''))\n .filter(s => s.length > 0)\n ;(frontmatter as any)[key] = items\n }\n // Handle multi-line arrays (value is empty or [])\n else if (value === '' || value === '[]') {\n currentKey = key\n inArray = true\n arrayItems = []\n }\n // Handle boolean values\n else if (value === 'true' || value === 'false') {\n ;(frontmatter as any)[key] = value === 'true'\n }\n // Handle string values (remove quotes)\n else {\n ;(frontmatter as any)[key] = value.replace(/['\"]/g, '')\n }\n }\n\n // Handle final array if we ended in array mode\n if (inArray && currentKey) {\n ;(frontmatter as any)[currentKey] = arrayItems\n }\n\n return { frontmatter, content: markdownContent }\n}\n\n/**\n * Scan directory for markdown files using find command\n *\n * This function discovers .md files in the specified directory using the\n * system's find command. It's designed as a fallback when ripgrep is not\n * available, providing the same functionality with broader compatibility.\n *\n * The function includes timeout and signal handling for robustness,\n * especially important when scanning large directory trees.\n *\n * @param args - Legacy parameter for ripgrep compatibility (ignored)\n * @param directory - Directory to scan for markdown files\n * @param signal - AbortSignal for cancellation support\n * @returns Promise<string[]> - Array of absolute paths to .md files\n */\nasync function scanMarkdownFiles(\n args: string[], // Legacy parameter for ripgrep compatibility\n directory: string,\n signal: AbortSignal,\n): Promise<string[]> {\n try {\n // Use find command as fallback since ripgrep may not be available\n // This provides broader compatibility across different systems\n const { stdout } = await execFileAsync(\n 'find',\n [directory, '-name', '*.md', '-type', 'f'],\n { signal, timeout: 3000 },\n )\n return stdout\n .trim()\n .split('\\n')\n .filter(line => line.length > 0)\n } catch (error) {\n // If find fails or directory doesn't exist, return empty array\n // This ensures graceful degradation when directories are missing\n return []\n }\n}\n\n/**\n * Create a Command object from custom command file data\n *\n * This function transforms parsed custom command data into a Command object\n * that integrates with the main command system. It handles naming, scoping,\n * and prompt generation according to the project's command patterns.\n *\n * Command naming follows a hierarchical structure:\n * - Project commands: \"project:namespace:command\"\n * - User commands: \"user:namespace:command\"\n * - Namespace is derived from directory structure\n *\n * @param frontmatter - Parsed frontmatter configuration\n * @param content - Markdown content of the command\n * @param filePath - Absolute path to the command file\n * @param baseDir - Base directory for scope determination\n * @returns CustomCommandWithScope | null - Processed command or null if invalid\n */\nfunction createCustomCommand(\n frontmatter: CustomCommandFrontmatter,\n content: string,\n filePath: string,\n baseDir: string,\n): CustomCommandWithScope | null {\n // Extract command name with namespace support\n const relativePath = filePath.replace(baseDir + '/', '')\n const pathParts = relativePath.split('/')\n const fileName = pathParts[pathParts.length - 1].replace('.md', '')\n\n // Determine scope based on directory location\n const userMintoDir = join(homedir(), '.minto', 'commands')\n const scope: 'user' | 'project' =\n baseDir === userMintoDir ? 'user' : 'project'\n const prefix = scope === 'user' ? 'user' : 'project'\n\n // Create proper command name with prefix and namespace\n let finalName: string\n if (frontmatter.name) {\n // If frontmatter specifies name, use it but ensure proper prefix\n finalName = frontmatter.name.startsWith(`${prefix}:`)\n ? frontmatter.name\n : `${prefix}:${frontmatter.name}`\n } else {\n // Generate name from file path, supporting directory-based namespacing\n if (pathParts.length > 1) {\n const namespace = pathParts.slice(0, -1).join(':')\n finalName = `${prefix}:${namespace}:${fileName}`\n } else {\n finalName = `${prefix}:${fileName}`\n }\n }\n\n // Extract configuration with sensible defaults\n const description = frontmatter.description || `Custom command: ${finalName}`\n const enabled = frontmatter.enabled !== false // Default to true\n const hidden = frontmatter.hidden === true // Default to false\n const aliases = frontmatter.aliases || []\n const progressMessage =\n frontmatter.progressMessage || `Running ${finalName}...`\n const argNames = frontmatter.argNames\n\n // Validate required fields\n if (!finalName) {\n console.warn(`Custom command file ${filePath} has no name, skipping`)\n return null\n }\n\n // Create the command object following the project's Command interface\n const command: CustomCommandWithScope = {\n type: 'prompt',\n name: finalName,\n description,\n isEnabled: enabled,\n isHidden: hidden,\n aliases,\n progressMessage,\n argNames,\n scope,\n userFacingName(): string {\n return finalName\n },\n async getPromptForCommand(args: string): Promise<MessageParam[]> {\n let prompt = content.trim()\n\n // Process argument substitution following legacy conventions\n // This supports both the official $ARGUMENTS format and legacy {arg} format\n\n // Step 1: Handle $ARGUMENTS placeholder (legacy command format)\n if (prompt.includes('$ARGUMENTS')) {\n prompt = prompt.replace(/\\$ARGUMENTS/g, args || '')\n }\n\n // Step 2: Legacy support for named argument placeholders\n if (argNames && argNames.length > 0) {\n const argValues = args.trim().split(/\\s+/)\n argNames.forEach((argName, index) => {\n const value = argValues[index] || ''\n prompt = prompt.replace(new RegExp(`\\\\{${argName}\\\\}`, 'g'), value)\n })\n }\n\n // Step 3: If args are provided but no placeholders used, append to prompt\n if (\n args.trim() &&\n !prompt.includes('$ARGUMENTS') &&\n (!argNames || argNames.length === 0)\n ) {\n prompt += `\\n\\nAdditional context: ${args}`\n }\n\n // Step 4: Add tool restrictions if specified\n const allowedTools = frontmatter['allowed-tools']\n if (\n allowedTools &&\n Array.isArray(allowedTools) &&\n allowedTools.length > 0\n ) {\n const allowedToolsStr = allowedTools.join(', ')\n prompt += `\\n\\nIMPORTANT: You are restricted to using only these tools: ${allowedToolsStr}. Do not use any other tools even if they might be helpful for the task.`\n }\n\n return [\n {\n role: 'user',\n content: prompt,\n },\n ]\n },\n }\n\n return command\n}\n\n/**\n * Load custom commands from .minto/commands/ directories\n *\n * This function scans both user-level and project-level command directories\n * for markdown files and processes them into Command objects.\n *\n * Directory structure:\n * - User commands: ~/.minto/commands/\n * - Project commands: {project}/.minto/commands/\n *\n * The function is memoized for performance but includes cache invalidation\n * based on directory contents and timestamps.\n *\n * @returns Promise<CustomCommandWithScope[]> - Array of loaded and enabled commands\n */\nexport const loadCustomCommands = memoize(\n async (): Promise<CustomCommandWithScope[]> => {\n const userMintoDir = join(homedir(), '.minto', 'commands')\n const projectMintoDir = join(getCwd(), '.minto', 'commands')\n\n // Set up abort controller for timeout handling\n const abortController = new AbortController()\n const timeout = setTimeout(() => abortController.abort(), 3000)\n\n try {\n const startTime = Date.now()\n\n // Scan directories for .md files concurrently\n const [projectMintoFiles, userMintoFiles] = await Promise.all([\n existsSync(projectMintoDir)\n ? scanMarkdownFiles(\n ['--files', '--hidden', '--glob', '*.md'],\n projectMintoDir,\n abortController.signal,\n )\n : Promise.resolve([]),\n existsSync(userMintoDir)\n ? scanMarkdownFiles(\n ['--files', '--glob', '*.md'],\n userMintoDir,\n abortController.signal,\n )\n : Promise.resolve([]),\n ])\n\n // Combine files with priority: project > user\n const projectFiles = [...projectMintoFiles]\n const userFiles = [...userMintoFiles]\n const allFiles = [...projectFiles, ...userFiles]\n const duration = Date.now() - startTime\n\n // Log performance metrics for monitoring\n // This follows the same pattern as other performance-sensitive operations\n\n // Parse files and create command objects\n const commands: CustomCommandWithScope[] = []\n\n // Process project files first (higher priority)\n for (const filePath of projectFiles) {\n try {\n const content = readFileSync(filePath, { encoding: 'utf-8' })\n const { frontmatter, content: commandContent } =\n parseFrontmatter(content)\n const command = createCustomCommand(\n frontmatter,\n commandContent,\n filePath,\n projectMintoDir,\n )\n\n if (command) {\n commands.push(command)\n }\n } catch (error) {\n console.warn(`Failed to load custom command from ${filePath}:`, error)\n }\n }\n\n // Process user files second (lower priority)\n for (const filePath of userFiles) {\n try {\n const content = readFileSync(filePath, { encoding: 'utf-8' })\n const { frontmatter, content: commandContent } =\n parseFrontmatter(content)\n const command = createCustomCommand(\n frontmatter,\n commandContent,\n filePath,\n userMintoDir,\n )\n\n if (command) {\n commands.push(command)\n }\n } catch (error) {\n console.warn(`Failed to load custom command from ${filePath}:`, error)\n }\n }\n\n // Filter enabled commands and log results\n const enabledCommands = commands.filter(cmd => cmd.isEnabled)\n\n // Log loading results for debugging and monitoring\n\n return enabledCommands\n } catch (error) {\n console.warn('Failed to load custom commands:', error)\n return []\n } finally {\n clearTimeout(timeout)\n }\n },\n // Memoization resolver based on current working directory and directory state\n // This ensures cache invalidation when directories change\n () => {\n const cwd = getCwd()\n const userMintoDir = join(homedir(), '.minto', 'commands')\n const projectMintoDir = join(cwd, '.minto', 'commands')\n\n // Create cache key that includes directory existence and timestamp\n // This provides reasonable cache invalidation without excessive file system checks\n return `${cwd}:${existsSync(userMintoDir)}:${existsSync(projectMintoDir)}:${Math.floor(Date.now() / 60000)}`\n },\n)\n\n/**\n * Clear the custom commands cache to force reload\n *\n * This function invalidates the memoized cache for custom commands,\n * forcing the next invocation to re-scan the filesystem. It's useful\n * when commands are added, removed, or modified during runtime.\n *\n * This follows the same pattern as other cache invalidation functions\n * in the project, such as getCommands.cache.clear().\n */\nexport const reloadCustomCommands = (): void => {\n loadCustomCommands.cache.clear()\n}\n\n/**\n * Get custom command directories for help and diagnostic purposes\n *\n * This function returns the standard directory paths where custom commands\n * are expected to be found. It's used by help systems and diagnostic tools\n * to inform users about the proper directory structure.\n *\n * @returns Object containing user and project command directory paths\n */\nexport function getCustomCommandDirectories(): {\n user: string\n project: string\n} {\n return {\n user: join(homedir(), '.minto', 'commands'),\n project: join(getCwd(), '.minto', 'commands'),\n }\n}\n\n/**\n * Check if custom commands are available in either directory\n *\n * This function provides a quick way to determine if custom commands\n * are configured without actually loading them. It's useful for conditional\n * UI elements and feature detection.\n *\n * @returns boolean - True if at least one command directory exists\n */\nexport function hasCustomCommands(): boolean {\n const { user, project } = getCustomCommandDirectories()\n return existsSync(user) || existsSync(project)\n}\n\n/**\n * Load commands from installed plugins\n *\n * This function integrates the plugin system with the custom commands system\n * by loading all commands from installed plugins and converting them to the\n * standard Command interface used throughout the application.\n *\n * Commands from plugins are treated similarly to custom commands but with\n * additional metadata to track their source plugin. This enables proper\n * attribution and conflict resolution.\n *\n * Command naming follows the pattern:\n * - Plugin commands: \"plugin:plugin-name:command-name\"\n * - This prevents conflicts with user/project commands\n *\n * @returns Promise<CustomCommandWithScope[]> - Array of loaded plugin commands\n */\nexport const loadPluginCommands = memoize(\n async (): Promise<CustomCommandWithScope[]> => {\n try {\n const startTime = Date.now()\n const plugins = loadAllPlugins()\n const commands: CustomCommandWithScope[] = []\n\n // Process each plugin's commands\n for (const plugin of plugins) {\n if (!plugin.enabled) continue\n\n for (const pluginCommand of plugin.commands) {\n try {\n // Skip disabled commands\n if (pluginCommand.config.enabled === false) continue\n\n // Create fully qualified command name\n const commandName = pluginCommand.config.name || pluginCommand.name\n const qualifiedName = commandName.startsWith('plugin:')\n ? commandName\n : `plugin:${plugin.manifest.name}:${commandName}`\n\n // Convert LoadedCommand to CustomCommandWithScope\n const command: CustomCommandWithScope = {\n type: 'prompt',\n name: qualifiedName,\n description:\n pluginCommand.config.description ||\n `Plugin command from ${plugin.manifest.displayName || plugin.manifest.name}`,\n isEnabled: pluginCommand.config.enabled ?? true,\n isHidden: pluginCommand.config.hidden ?? false,\n aliases: pluginCommand.config.aliases || [],\n progressMessage:\n pluginCommand.config.progressMessage ||\n `Running ${commandName}...`,\n argNames: pluginCommand.config.argNames,\n scope: 'user', // Plugin commands are treated as user-scoped\n userFacingName(): string {\n return qualifiedName\n },\n async getPromptForCommand(args: string): Promise<MessageParam[]> {\n let prompt = pluginCommand.config.content.trim()\n\n // Process argument substitution following same conventions as custom commands\n\n // Step 1: Handle $ARGUMENTS placeholder\n if (prompt.includes('$ARGUMENTS')) {\n prompt = prompt.replace(/\\$ARGUMENTS/g, args || '')\n }\n\n // Step 2: Legacy support for named argument placeholders\n if (\n pluginCommand.config.argNames &&\n pluginCommand.config.argNames.length > 0\n ) {\n const argValues = args.trim().split(/\\s+/)\n pluginCommand.config.argNames.forEach((argName, index) => {\n const value = argValues[index] || ''\n prompt = prompt.replace(\n new RegExp(`\\\\{${argName}\\\\}`, 'g'),\n value,\n )\n })\n }\n\n // Step 3: If args provided but no placeholders, append to prompt\n if (\n args.trim() &&\n !prompt.includes('$ARGUMENTS') &&\n (!pluginCommand.config.argNames ||\n pluginCommand.config.argNames.length === 0)\n ) {\n prompt += `\\n\\nAdditional context: ${args}`\n }\n\n // Step 4: Add tool restrictions if specified\n const allowedTools = pluginCommand.config['allowed-tools']\n if (\n allowedTools &&\n Array.isArray(allowedTools) &&\n allowedTools.length > 0\n ) {\n const allowedToolsStr = allowedTools.join(', ')\n prompt += `\\n\\nIMPORTANT: You are restricted to using only these tools: ${allowedToolsStr}. Do not use any other tools even if they might be helpful for the task.`\n }\n\n // Step 5: Add plugin attribution\n prompt += `\\n\\n---\\n_Command provided by plugin: ${plugin.manifest.displayName || plugin.manifest.name} (${plugin.manifest.version})_`\n\n return [\n {\n role: 'user',\n content: prompt,\n },\n ]\n },\n }\n\n commands.push(command)\n } catch (error) {\n console.warn(\n `Failed to load command ${pluginCommand.name} from plugin ${plugin.manifest.name}:`,\n error,\n )\n }\n }\n }\n\n const duration = Date.now() - startTime\n\n // Log loading results for debugging and monitoring\n\n return commands\n } catch (error) {\n console.warn('Failed to load plugin commands:', error)\n return []\n }\n },\n // Memoization resolver based on current working directory\n // This ensures cache invalidation when plugins might change\n () => {\n const cwd = getCwd()\n // Cache key includes timestamp for periodic refresh (every minute)\n return `${cwd}:${Math.floor(Date.now() / 60000)}`\n },\n)\n\n/**\n * Clear the plugin commands cache to force reload\n *\n * This function invalidates the memoized cache for plugin commands,\n * forcing the next invocation to re-scan installed plugins. It's useful\n * when plugins are installed, removed, or modified during runtime.\n */\nexport const reloadPluginCommands = (): void => {\n loadPluginCommands.cache.clear()\n}\n"],
5
- "mappings": "AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,eAAe;AAGxB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAE/B;AAAA,EACE;AAAA,OAEK;AAEP,MAAM,gBAAgB,UAAU,QAAQ;AAMxC,SAAS,qBAAqB,SAA0B;AACtD,QAAM,gBAAgB,wBAAwB;AAC9C,QAAM,eAAe,eAAe,gBAAgB,CAAC;AAGrD,QAAM,QAAQ,QAAQ,MAAM,KAAK;AACjC,QAAM,cAAc,MAAM,CAAC;AAG3B,MAAI,aAAa,SAAS,QAAQ,OAAO,GAAG,GAAG;AAC7C,WAAO;AAAA,EACT;AAGA,MAAI,aAAa,SAAS,QAAQ,WAAW,KAAK,GAAG;AACnD,WAAO;AAAA,EACT;AAGA,QAAM,eAAe,oBAAI,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,MAAI,aAAa,IAAI,WAAW,GAAG;AACjC,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAMA,SAAS,k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AAQ,YAAY,KAC1B,aAAa,SAAS,GACtB;AACA,wBAAM,kBAAkB,aAAa,KAAK,IAAI;AAC9C,4BAAU;AAAA;AAAA,2DAAgE,eAAe;AAAA,gBAC3F;AAGA,0BAAU;AAAA;AAAA;AAAA,+BAAyC,OAAO,SAAS,eAAe,OAAO,SAAS,IAAI,KAAK,OAAO,SAAS,OAAO;AAElI,uBAAO;AAAA,kBACL;AAAA,oBACE,MAAM;AAAA,oBACN,SAAS;AAAA,kBACX;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAEA,qBAAS,KAAK,OAAO;AAAA,UACvB,SAAS,OAAO;AACd,oBAAQ;AAAA,cACN,0BAA0B,cAAc,IAAI,gBAAgB,OAAO,SAAS,IAAI;AAAA,cAChF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,YAAM,WAAW,KAAK,IAAI,IAAI;AAI9B,aAAO;AAAA,IACT,SAAS,OAAO;AACd,cAAQ,KAAK,mCAAmC,KAAK;AACrD,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AAAA;AAAA;AAAA,EAGA,MAAM;AACJ,UAAM,MAAM,OAAO;AAEnB,WAAO,GAAG,GAAG,IAAI,KAAK,MAAM,KAAK,IAAI,IAAI,GAAK,CAAC;AAAA,EACjD;AACF;AASO,MAAM,uBAAuB,MAAY;AAC9C,qBAAmB,MAAM,MAAM;AACjC;",
4
+ "sourcesContent": ["import { existsSync, readFileSync } from 'fs'\nimport { join } from 'path'\nimport { homedir } from 'os'\nimport { memoize } from 'lodash-es'\nimport type { MessageParam } from '@anthropic-ai/sdk/resources/index.mjs'\nimport type { Command } from '@commands'\nimport { getCwd } from '@utils/state'\nimport { execFile } from 'child_process'\nimport { promisify } from 'util'\nimport { loadAllPlugins } from '@utils/pluginLoader'\nimport type { LoadedPlugin, LoadedCommand } from '../types/plugin'\nimport {\n getCurrentProjectConfig,\n saveCurrentProjectConfig,\n} from '@utils/config'\nimport { substituteVariables } from '@utils/stringSubstitution'\n\nconst execFileAsync = promisify(execFile)\n\n/**\n * Check if a bash command is allowed based on project config permissions\n * This integrates with the same permission system used by BashTool\n */\nfunction isBashCommandAllowed(command: string): boolean {\n const projectConfig = getCurrentProjectConfig()\n const allowedTools = projectConfig?.allowedTools || []\n\n // Check if the command or its prefix is in allowed tools\n const parts = command.split(/\\s+/)\n const baseCommand = parts[0]\n\n // Check exact match\n if (allowedTools.includes(`Bash(${command})`)) {\n return true\n }\n\n // Check base command prefix match\n if (allowedTools.includes(`Bash(${baseCommand}:*)`)) {\n return true\n }\n\n // Safe commands that don't need permission\n const safeCommands = new Set([\n 'git',\n 'ls',\n 'pwd',\n 'date',\n 'which',\n 'echo',\n 'cat',\n 'head',\n 'tail',\n 'wc',\n 'sort',\n 'uniq',\n 'grep',\n 'find',\n 'dirname',\n 'basename',\n ])\n\n if (safeCommands.has(baseCommand)) {\n return true\n }\n\n return false\n}\n\n/**\n * Check if file read is allowed based on project config permissions\n * This integrates with the same permission system used by FileReadTool\n */\nfunction isFileReadAllowed(filePath: string): boolean {\n const projectConfig = getCurrentProjectConfig()\n const allowedTools = projectConfig?.allowedTools || []\n\n // File read is generally allowed - FileReadTool doesn't require permission\n // But we log it for audit purposes\n return true\n}\n\n/**\n * Execute bash commands found in custom command content using !`command` syntax\n *\n * This function processes dynamic command execution within custom commands,\n * following the same security model as the main BashTool but with restricted scope.\n * Commands are executed in the current working directory with a timeout.\n *\n * Security: Commands are checked against the permission system before execution.\n * Only safe commands (git, ls, etc.) or explicitly allowed commands will execute.\n *\n * @param content - The custom command content to process\n * @returns Promise<string> - Content with bash commands replaced by their output\n */\nexport async function executeBashCommands(content: string): Promise<string> {\n // Match patterns like !`git status` or !`command here`\n const bashCommandRegex = /!\\`([^`]+)\\`/g\n const matches = [...content.matchAll(bashCommandRegex)]\n\n if (matches.length === 0) {\n return content\n }\n\n let result = content\n\n for (const match of matches) {\n const fullMatch = match[0]\n const command = match[1].trim()\n\n // Security check: verify command is allowed\n if (!isBashCommandAllowed(command)) {\n console.warn(\n `Custom command bash execution denied: \"${command}\" - not in allowed list`,\n )\n result = result.replace(fullMatch, `(permission denied: ${command})`)\n continue\n }\n\n try {\n // Parse command and args using simple shell parsing\n // This mirrors the approach used in the main BashTool but with stricter limits\n const parts = command.split(/\\s+/)\n const cmd = parts[0]\n const args = parts.slice(1)\n\n // Execute with conservative timeout (5s vs BashTool's 2min default)\n const { stdout, stderr } = await execFileAsync(cmd, args, {\n timeout: 5000,\n encoding: 'utf8',\n cwd: getCwd(), // Use current working directory for consistency\n })\n\n // Replace the bash command with its output, preferring stdout\n const output = stdout.trim() || stderr.trim() || '(no output)'\n result = result.replace(fullMatch, output)\n } catch (error) {\n console.warn(`Failed to execute bash command \"${command}\":`, error)\n result = result.replace(fullMatch, `(error executing: ${command})`)\n }\n }\n\n return result\n}\n\n/**\n * Resolve file references using @filepath syntax within custom commands\n *\n * This function implements file inclusion for custom commands, similar to how\n * the FileReadTool works but with inline processing. Files are read from the\n * current working directory and formatted as markdown code blocks.\n *\n * Security note: Files are read with the same permissions as the main process,\n * following the same security model as other file operations in the system.\n *\n * @param content - The custom command content to process\n * @returns Promise<string> - Content with file references replaced by file contents\n */\nexport async function resolveFileReferences(content: string): Promise<string> {\n // Match patterns like @src/file.js or @path/to/file.txt\n // Use consistent file mention pattern from mentionProcessor\n // Exclude agent and ask-model patterns to avoid conflicts\n const fileRefRegex = /@([a-zA-Z0-9/._-]+(?:\\.[a-zA-Z0-9]+)?)/g\n const matches = [...content.matchAll(fileRefRegex)]\n\n if (matches.length === 0) {\n return content\n }\n\n let result = content\n\n for (const match of matches) {\n const fullMatch = match[0]\n const filePath = match[1]\n\n // Skip agent mentions - these are handled by the mention processor\n if (filePath.startsWith('agent-')) {\n continue\n }\n\n try {\n // Resolve relative to current working directory\n // This maintains consistency with how other file operations work\n const fullPath = join(getCwd(), filePath)\n\n if (existsSync(fullPath)) {\n const fileContent = readFileSync(fullPath, { encoding: 'utf-8' })\n\n // Format file content with filename header for clarity\n // This matches the format used by FileReadTool for consistency\n const formattedContent = `\\n\\n## File: ${filePath}\\n\\`\\`\\`\\n${fileContent}\\n\\`\\`\\`\\n`\n result = result.replace(fullMatch, formattedContent)\n } else {\n result = result.replace(fullMatch, `(file not found: ${filePath})`)\n }\n } catch (error) {\n console.warn(`Failed to read file \"${filePath}\":`, error)\n result = result.replace(fullMatch, `(error reading: ${filePath})`)\n }\n }\n\n return result\n}\n\n/**\n * Validate and process allowed-tools specification from frontmatter\n *\n * This function handles tool restriction specifications in custom commands.\n * When allowed-tools is specified, it adds instructions to the prompt to\n * restrict the assistant to only using those tools.\n *\n * Note: The actual enforcement happens at the prompt level - we instruct the\n * assistant to only use specific tools. This is consistent with how Claude Code\n * handles tool restrictions in agent configurations.\n *\n * @param allowedTools - Array of tool names from frontmatter\n * @returns boolean - True if validation passes\n */\nfunction validateAllowedTools(allowedTools: string[] | undefined): boolean {\n // Validation is always true - the restriction is enforced via prompt injection\n // in getPromptForCommand() which adds the tool restriction text\n return true\n}\n\n/**\n * Frontmatter configuration for custom commands\n *\n * This interface defines the YAML frontmatter structure that can be used\n * to configure custom commands. It mirrors the Claude Desktop custom command\n * system for compatibility while adding Minto-specific enhancements.\n */\nexport interface CustomCommandFrontmatter {\n /** Display name for the command (overrides filename-based naming) */\n name?: string\n /** Brief description of what the command does */\n description?: string\n /** Alternative names that can be used to invoke this command */\n aliases?: string[]\n /** Whether this command is active and can be executed */\n enabled?: boolean\n /** Whether this command should be hidden from help output */\n hidden?: boolean\n /** Message to display while the command is running */\n progressMessage?: string\n /** Named arguments for legacy {arg} placeholder support */\n argNames?: string[]\n /** Tools that this command is restricted to use */\n 'allowed-tools'?: string[]\n}\n\n/**\n * Extended Command interface with scope information\n *\n * This extends the base Command interface to include scope metadata\n * for distinguishing between user-level and project-level commands.\n */\nexport interface CustomCommandWithScope {\n /** Command type - matches PromptCommand */\n type: 'prompt'\n /** Command name */\n name: string\n /** Command description */\n description: string\n /** Whether command is enabled */\n isEnabled: boolean\n /** Whether command is hidden */\n isHidden: boolean\n /** Command aliases */\n aliases?: string[]\n /** Progress message */\n progressMessage: string\n /** Argument names for legacy support */\n argNames?: string[]\n /** User-facing name function */\n userFacingName(): string\n /** Prompt generation function */\n getPromptForCommand(args: string): Promise<MessageParam[]>\n /** Scope indicates whether this is a user or project command */\n scope?: 'user' | 'project'\n}\n\n/**\n * Parsed custom command file representation\n *\n * This interface represents a fully parsed custom command file with\n * separated frontmatter and content sections.\n */\nexport interface CustomCommandFile {\n /** Parsed frontmatter configuration */\n frontmatter: CustomCommandFrontmatter\n /** Markdown content (without frontmatter) */\n content: string\n /** Absolute path to the source file */\n filePath: string\n}\n\n/**\n * Parse YAML frontmatter from markdown content\n *\n * This function extracts and parses YAML frontmatter from markdown files,\n * supporting the same syntax as Jekyll and other static site generators.\n * It handles basic YAML constructs including strings, booleans, and arrays.\n *\n * The parser is intentionally simple and focused on the specific needs of\n * custom commands rather than being a full YAML parser. Complex YAML features\n * like nested objects, multi-line strings, and advanced syntax are not supported.\n *\n * @param content - Raw markdown content with optional frontmatter\n * @returns Object containing parsed frontmatter and remaining content\n */\nexport function parseFrontmatter(content: string): {\n frontmatter: CustomCommandFrontmatter\n content: string\n} {\n const frontmatterRegex = /^---\\s*\\n([\\s\\S]*?)---\\s*\\n?/\n const match = content.match(frontmatterRegex)\n\n if (!match) {\n return { frontmatter: {}, content }\n }\n\n const yamlContent = match[1] || ''\n const markdownContent = content.slice(match[0].length)\n const frontmatter: CustomCommandFrontmatter = {}\n\n // Simple YAML parser for basic key-value pairs and arrays\n // This handles the subset of YAML needed for custom command configuration\n const lines = yamlContent.split('\\n')\n let currentKey: string | null = null\n let arrayItems: string[] = []\n let inArray = false\n\n for (const line of lines) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('#')) continue\n\n // Handle array item continuation (- item)\n if (inArray && trimmed.startsWith('-')) {\n const item = trimmed.slice(1).trim().replace(/['\"]/g, '')\n arrayItems.push(item)\n continue\n }\n\n // End array processing when we hit a new key\n if (inArray && trimmed.includes(':')) {\n if (currentKey) {\n ;(frontmatter as any)[currentKey] = arrayItems\n }\n inArray = false\n arrayItems = []\n currentKey = null\n }\n\n const colonIndex = trimmed.indexOf(':')\n if (colonIndex === -1) continue\n\n const key = trimmed.slice(0, colonIndex).trim()\n const value = trimmed.slice(colonIndex + 1).trim()\n\n // Handle inline arrays [item1, item2]\n if (value.startsWith('[') && value.endsWith(']')) {\n const items = value\n .slice(1, -1)\n .split(',')\n .map(s => s.trim().replace(/['\"]/g, ''))\n .filter(s => s.length > 0)\n ;(frontmatter as any)[key] = items\n }\n // Handle multi-line arrays (value is empty or [])\n else if (value === '' || value === '[]') {\n currentKey = key\n inArray = true\n arrayItems = []\n }\n // Handle boolean values\n else if (value === 'true' || value === 'false') {\n ;(frontmatter as any)[key] = value === 'true'\n }\n // Handle string values (remove quotes)\n else {\n ;(frontmatter as any)[key] = value.replace(/['\"]/g, '')\n }\n }\n\n // Handle final array if we ended in array mode\n if (inArray && currentKey) {\n ;(frontmatter as any)[currentKey] = arrayItems\n }\n\n return { frontmatter, content: markdownContent }\n}\n\n/**\n * Scan directory for markdown files using find command\n *\n * This function discovers .md files in the specified directory using the\n * system's find command. It's designed as a fallback when ripgrep is not\n * available, providing the same functionality with broader compatibility.\n *\n * The function includes timeout and signal handling for robustness,\n * especially important when scanning large directory trees.\n *\n * @param args - Legacy parameter for ripgrep compatibility (ignored)\n * @param directory - Directory to scan for markdown files\n * @param signal - AbortSignal for cancellation support\n * @returns Promise<string[]> - Array of absolute paths to .md files\n */\nasync function scanMarkdownFiles(\n args: string[], // Legacy parameter for ripgrep compatibility\n directory: string,\n signal: AbortSignal,\n): Promise<string[]> {\n try {\n // Use find command as fallback since ripgrep may not be available\n // This provides broader compatibility across different systems\n const { stdout } = await execFileAsync(\n 'find',\n [directory, '-name', '*.md', '-type', 'f'],\n { signal, timeout: 3000 },\n )\n return stdout\n .trim()\n .split('\\n')\n .filter(line => line.length > 0)\n } catch (error) {\n // If find fails or directory doesn't exist, return empty array\n // This ensures graceful degradation when directories are missing\n return []\n }\n}\n\n/**\n * Create a Command object from custom command file data\n *\n * This function transforms parsed custom command data into a Command object\n * that integrates with the main command system. It handles naming, scoping,\n * and prompt generation according to the project's command patterns.\n *\n * Command naming follows a hierarchical structure:\n * - Project commands: \"project:namespace:command\"\n * - User commands: \"user:namespace:command\"\n * - Namespace is derived from directory structure\n *\n * @param frontmatter - Parsed frontmatter configuration\n * @param content - Markdown content of the command\n * @param filePath - Absolute path to the command file\n * @param baseDir - Base directory for scope determination\n * @returns CustomCommandWithScope | null - Processed command or null if invalid\n */\nfunction createCustomCommand(\n frontmatter: CustomCommandFrontmatter,\n content: string,\n filePath: string,\n baseDir: string,\n): CustomCommandWithScope | null {\n // Extract command name with namespace support\n const relativePath = filePath.replace(baseDir + '/', '')\n const pathParts = relativePath.split('/')\n const fileName = pathParts[pathParts.length - 1].replace('.md', '')\n\n // Determine scope based on directory location\n const userMintoDir = join(homedir(), '.minto', 'commands')\n const userClaudeDir = join(homedir(), '.claude', 'commands')\n const scope: 'user' | 'project' =\n baseDir === userMintoDir || baseDir === userClaudeDir ? 'user' : 'project'\n const prefix = scope === 'user' ? 'user' : 'project'\n\n // Create proper command name with prefix and namespace\n let finalName: string\n if (frontmatter.name) {\n // If frontmatter specifies name, use it but ensure proper prefix\n finalName = frontmatter.name.startsWith(`${prefix}:`)\n ? frontmatter.name\n : `${prefix}:${frontmatter.name}`\n } else {\n // Generate name from file path, supporting directory-based namespacing\n if (pathParts.length > 1) {\n const namespace = pathParts.slice(0, -1).join(':')\n finalName = `${prefix}:${namespace}:${fileName}`\n } else {\n finalName = `${prefix}:${fileName}`\n }\n }\n\n // Extract configuration with sensible defaults\n const description = frontmatter.description || `Custom command: ${finalName}`\n const enabled = frontmatter.enabled !== false // Default to true\n const hidden = frontmatter.hidden === true // Default to false\n const aliases = frontmatter.aliases || []\n const progressMessage =\n frontmatter.progressMessage || `Running ${finalName}...`\n const argNames = frontmatter.argNames\n\n // Validate required fields\n if (!finalName) {\n console.warn(`Custom command file ${filePath} has no name, skipping`)\n return null\n }\n\n // Create the command object following the project's Command interface\n const command: CustomCommandWithScope = {\n type: 'prompt',\n name: finalName,\n description,\n isEnabled: enabled,\n isHidden: hidden,\n aliases,\n progressMessage,\n argNames,\n scope,\n userFacingName(): string {\n return finalName\n },\n async getPromptForCommand(args: string): Promise<MessageParam[]> {\n let prompt = content.trim()\n\n // Use Claude Code spec string substitution engine\n // Supports: $ARGUMENTS, $ARGUMENTS[N], $N, ${VAR}, !`command`\n prompt = await substituteVariables(prompt, args || '', {\n cwd: getCwd(),\n allowDynamicCommands: false, // Security: disable !`command` by default\n })\n\n // Legacy support for named argument placeholders\n if (argNames && argNames.length > 0) {\n const argValues = args.trim().split(/\\s+/)\n argNames.forEach((argName, index) => {\n const value = argValues[index] || ''\n prompt = prompt.replace(new RegExp(`\\\\{${argName}\\\\}`, 'g'), value)\n })\n }\n\n // If args are provided but no placeholders used, append to prompt\n if (\n args.trim() &&\n !content.includes('$ARGUMENTS') &&\n !content.includes('$0') &&\n (!argNames || argNames.length === 0)\n ) {\n prompt += `\\n\\nAdditional context: ${args}`\n }\n\n // Add tool restrictions if specified\n const allowedTools = frontmatter['allowed-tools']\n if (\n allowedTools &&\n Array.isArray(allowedTools) &&\n allowedTools.length > 0\n ) {\n const allowedToolsStr = allowedTools.join(', ')\n prompt += `\\n\\nIMPORTANT: You are restricted to using only these tools: ${allowedToolsStr}. Do not use any other tools even if they might be helpful for the task.`\n }\n\n return [\n {\n role: 'user',\n content: prompt,\n },\n ]\n },\n }\n\n return command\n}\n\n/**\n * Load custom commands from .minto/commands/ directories\n *\n * This function scans both user-level and project-level command directories\n * for markdown files and processes them into Command objects.\n *\n * Directory structure:\n * - User commands: ~/.minto/commands/\n * - Project commands: {project}/.minto/commands/\n *\n * The function is memoized for performance but includes cache invalidation\n * based on directory contents and timestamps.\n *\n * @returns Promise<CustomCommandWithScope[]> - Array of loaded and enabled commands\n */\nexport const loadCustomCommands = memoize(\n async (): Promise<CustomCommandWithScope[]> => {\n // .claude/ dirs are legacy fallbacks, .minto/ dirs take precedence\n const userClaudeDir = join(homedir(), '.claude', 'commands')\n const userMintoDir = join(homedir(), '.minto', 'commands')\n const projectClaudeDir = join(getCwd(), '.claude', 'commands')\n const projectMintoDir = join(getCwd(), '.minto', 'commands')\n\n // Set up abort controller for timeout handling\n const abortController = new AbortController()\n const timeout = setTimeout(() => abortController.abort(), 3000)\n\n try {\n const startTime = Date.now()\n\n // Scan directories for .md files concurrently\n const [\n projectClaudeFiles,\n projectMintoFiles,\n userClaudeFiles,\n userMintoFiles,\n ] = await Promise.all([\n existsSync(projectClaudeDir)\n ? scanMarkdownFiles(\n ['--files', '--hidden', '--glob', '*.md'],\n projectClaudeDir,\n abortController.signal,\n )\n : Promise.resolve([]),\n existsSync(projectMintoDir)\n ? scanMarkdownFiles(\n ['--files', '--hidden', '--glob', '*.md'],\n projectMintoDir,\n abortController.signal,\n )\n : Promise.resolve([]),\n existsSync(userClaudeDir)\n ? scanMarkdownFiles(\n ['--files', '--glob', '*.md'],\n userClaudeDir,\n abortController.signal,\n )\n : Promise.resolve([]),\n existsSync(userMintoDir)\n ? scanMarkdownFiles(\n ['--files', '--glob', '*.md'],\n userMintoDir,\n abortController.signal,\n )\n : Promise.resolve([]),\n ])\n\n // Combine files with priority: project/.minto > project/.claude > user/.minto > user/.claude\n const projectFiles = [...projectClaudeFiles, ...projectMintoFiles]\n const userFiles = [...userClaudeFiles, ...userMintoFiles]\n const allFiles = [...projectFiles, ...userFiles]\n const duration = Date.now() - startTime\n\n // Log performance metrics for monitoring\n // This follows the same pattern as other performance-sensitive operations\n\n // Parse files and create command objects\n const commands: CustomCommandWithScope[] = []\n\n // Process project files first (higher priority)\n for (const filePath of projectFiles) {\n try {\n const content = readFileSync(filePath, { encoding: 'utf-8' })\n const { frontmatter, content: commandContent } =\n parseFrontmatter(content)\n const command = createCustomCommand(\n frontmatter,\n commandContent,\n filePath,\n projectMintoDir,\n )\n\n if (command) {\n commands.push(command)\n }\n } catch (error) {\n console.warn(`Failed to load custom command from ${filePath}:`, error)\n }\n }\n\n // Process user files second (lower priority)\n for (const filePath of userFiles) {\n try {\n const content = readFileSync(filePath, { encoding: 'utf-8' })\n const { frontmatter, content: commandContent } =\n parseFrontmatter(content)\n const command = createCustomCommand(\n frontmatter,\n commandContent,\n filePath,\n userMintoDir,\n )\n\n if (command) {\n commands.push(command)\n }\n } catch (error) {\n console.warn(`Failed to load custom command from ${filePath}:`, error)\n }\n }\n\n // Filter enabled commands and log results\n const enabledCommands = commands.filter(cmd => cmd.isEnabled)\n\n // Log loading results for debugging and monitoring\n\n return enabledCommands\n } catch (error) {\n console.warn('Failed to load custom commands:', error)\n return []\n } finally {\n clearTimeout(timeout)\n }\n },\n // Memoization resolver based on current working directory and directory state\n // This ensures cache invalidation when directories change\n () => {\n const cwd = getCwd()\n const userMintoDir = join(homedir(), '.minto', 'commands')\n const userClaudeDir = join(homedir(), '.claude', 'commands')\n const projectMintoDir = join(cwd, '.minto', 'commands')\n const projectClaudeDir = join(cwd, '.claude', 'commands')\n\n // Create cache key that includes directory existence and timestamp\n // This provides reasonable cache invalidation without excessive file system checks\n return `${cwd}:${existsSync(userMintoDir)}:${existsSync(userClaudeDir)}:${existsSync(projectMintoDir)}:${existsSync(projectClaudeDir)}:${Math.floor(Date.now() / 60000)}`\n },\n)\n\n/**\n * Clear the custom commands cache to force reload\n *\n * This function invalidates the memoized cache for custom commands,\n * forcing the next invocation to re-scan the filesystem. It's useful\n * when commands are added, removed, or modified during runtime.\n *\n * This follows the same pattern as other cache invalidation functions\n * in the project, such as getCommands.cache.clear().\n */\nexport const reloadCustomCommands = (): void => {\n loadCustomCommands.cache.clear()\n}\n\n/**\n * Get custom command directories for help and diagnostic purposes\n *\n * This function returns the standard directory paths where custom commands\n * are expected to be found. It's used by help systems and diagnostic tools\n * to inform users about the proper directory structure.\n *\n * @returns Object containing user and project command directory paths\n */\nexport function getCustomCommandDirectories(): {\n user: string\n project: string\n userClaude: string\n projectClaude: string\n} {\n return {\n user: join(homedir(), '.minto', 'commands'),\n userClaude: join(homedir(), '.claude', 'commands'),\n project: join(getCwd(), '.minto', 'commands'),\n projectClaude: join(getCwd(), '.claude', 'commands'),\n }\n}\n\n/**\n * Check if custom commands are available in either directory\n *\n * This function provides a quick way to determine if custom commands\n * are configured without actually loading them. It's useful for conditional\n * UI elements and feature detection.\n *\n * @returns boolean - True if at least one command directory exists\n */\nexport function hasCustomCommands(): boolean {\n const { user, userClaude, project, projectClaude } =\n getCustomCommandDirectories()\n return (\n existsSync(user) ||\n existsSync(userClaude) ||\n existsSync(project) ||\n existsSync(projectClaude)\n )\n}\n\n/**\n * Load commands from installed plugins\n *\n * This function integrates the plugin system with the custom commands system\n * by loading all commands from installed plugins and converting them to the\n * standard Command interface used throughout the application.\n *\n * Commands from plugins are treated similarly to custom commands but with\n * additional metadata to track their source plugin. This enables proper\n * attribution and conflict resolution.\n *\n * Command naming follows the pattern:\n * - Plugin commands: \"plugin:plugin-name:command-name\"\n * - This prevents conflicts with user/project commands\n *\n * @returns Promise<CustomCommandWithScope[]> - Array of loaded plugin commands\n */\nexport const loadPluginCommands = memoize(\n async (): Promise<CustomCommandWithScope[]> => {\n try {\n const startTime = Date.now()\n const plugins = loadAllPlugins()\n const commands: CustomCommandWithScope[] = []\n\n // Process each plugin's commands\n for (const plugin of plugins) {\n if (!plugin.enabled) continue\n\n for (const pluginCommand of plugin.commands) {\n try {\n // Skip disabled commands\n if (pluginCommand.config.enabled === false) continue\n\n // Create fully qualified command name\n const commandName = pluginCommand.config.name || pluginCommand.name\n const qualifiedName = commandName.startsWith('plugin:')\n ? commandName\n : `plugin:${plugin.manifest.name}:${commandName}`\n\n // Convert LoadedCommand to CustomCommandWithScope\n const command: CustomCommandWithScope = {\n type: 'prompt',\n name: qualifiedName,\n description:\n pluginCommand.config.description ||\n `Plugin command from ${plugin.manifest.displayName || plugin.manifest.name}`,\n isEnabled: pluginCommand.config.enabled ?? true,\n isHidden: pluginCommand.config.hidden ?? false,\n aliases: pluginCommand.config.aliases || [],\n progressMessage:\n pluginCommand.config.progressMessage ||\n `Running ${commandName}...`,\n argNames: pluginCommand.config.argNames,\n scope: 'user', // Plugin commands are treated as user-scoped\n userFacingName(): string {\n return qualifiedName\n },\n async getPromptForCommand(args: string): Promise<MessageParam[]> {\n let prompt = pluginCommand.config.content.trim()\n\n // Use Claude Code spec string substitution engine\n // Supports: $ARGUMENTS, $ARGUMENTS[N], $N, ${VAR}, !`command`\n prompt = await substituteVariables(prompt, args || '', {\n cwd: getCwd(),\n allowDynamicCommands: false, // Security: disable !`command` by default\n })\n\n // Legacy support for named argument placeholders\n if (\n pluginCommand.config.argNames &&\n pluginCommand.config.argNames.length > 0\n ) {\n const argValues = args.trim().split(/\\s+/)\n pluginCommand.config.argNames.forEach((argName, index) => {\n const value = argValues[index] || ''\n prompt = prompt.replace(\n new RegExp(`\\\\{${argName}\\\\}`, 'g'),\n value,\n )\n })\n }\n\n // If args provided but no placeholders, append to prompt\n const originalContent = pluginCommand.config.content\n if (\n args.trim() &&\n !originalContent.includes('$ARGUMENTS') &&\n !originalContent.includes('$0') &&\n (!pluginCommand.config.argNames ||\n pluginCommand.config.argNames.length === 0)\n ) {\n prompt += `\\n\\nAdditional context: ${args}`\n }\n\n // Add tool restrictions if specified\n const allowedTools = pluginCommand.config['allowed-tools']\n if (\n allowedTools &&\n Array.isArray(allowedTools) &&\n allowedTools.length > 0\n ) {\n const allowedToolsStr = allowedTools.join(', ')\n prompt += `\\n\\nIMPORTANT: You are restricted to using only these tools: ${allowedToolsStr}. Do not use any other tools even if they might be helpful for the task.`\n }\n\n // Add plugin attribution\n prompt += `\\n\\n---\\n_Command provided by plugin: ${plugin.manifest.displayName || plugin.manifest.name} (${plugin.manifest.version})_`\n\n return [\n {\n role: 'user',\n content: prompt,\n },\n ]\n },\n }\n\n commands.push(command)\n } catch (error) {\n console.warn(\n `Failed to load command ${pluginCommand.name} from plugin ${plugin.manifest.name}:`,\n error,\n )\n }\n }\n }\n\n const duration = Date.now() - startTime\n\n // Log loading results for debugging and monitoring\n\n return commands\n } catch (error) {\n console.warn('Failed to load plugin commands:', error)\n return []\n }\n },\n // Memoization resolver based on current working directory\n // This ensures cache invalidation when plugins might change\n () => {\n const cwd = getCwd()\n // Cache key includes timestamp for periodic refresh (every minute)\n return `${cwd}:${Math.floor(Date.now() / 60000)}`\n },\n)\n\n/**\n * Clear the plugin commands cache to force reload\n *\n * This function invalidates the memoized cache for plugin commands,\n * forcing the next invocation to re-scan installed plugins. It's useful\n * when plugins are installed, removed, or modified during runtime.\n */\nexport const reloadPluginCommands = (): void => {\n loadPluginCommands.cache.clear()\n}\n"],
5
+ "mappings": "AAAA,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,eAAe;AAGxB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAE/B;AAAA,EACE;AAAA,OAEK;AACP,SAAS,2BAA2B;AAEpC,MAAM,gBAAgB,UAAU,QAAQ;AAMxC,SAAS,qBAAqB,SAA0B;AACtD,QAAM,gBAAgB,wBAAwB;AAC9C,QAAM,eAAe,eAAe,gBAAgB,CAAC;AAGrD,QAAM,QAAQ,QAAQ,MAAM,KAAK;AACjC,QAAM,cAAc,MAAM,CAAC;AAG3B,MAAI,aAAa,SAAS,QAAQ,OAAO,GAAG,GAAG;AAC7C,WAAO;AAAA,EACT;AAGA,MAAI,aAAa,SAAS,QAAQ,WAAW,KAAK,GAAG;AACnD,WAAO;AAAA,EACT;AAGA,QAAM,eAAe,oBAAI,IAAI;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AA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0BAAU;AAAA;AAAA;AAAA,+BAAyC,OAAO,SAAS,eAAe,OAAO,SAAS,IAAI,KAAK,OAAO,SAAS,OAAO;AAElI,uBAAO;AAAA,kBACL;AAAA,oBACE,MAAM;AAAA,oBACN,SAAS;AAAA,kBACX;AAAA,gBACF;AAAA,cACF;AAAA,YACF;AAEA,qBAAS,KAAK,OAAO;AAAA,UACvB,SAAS,OAAO;AACd,oBAAQ;AAAA,cACN,0BAA0B,cAAc,IAAI,gBAAgB,OAAO,SAAS,IAAI;AAAA,cAChF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAEA,YAAM,WAAW,KAAK,IAAI,IAAI;AAI9B,aAAO;AAAA,IACT,SAAS,OAAO;AACd,cAAQ,KAAK,mCAAmC,KAAK;AACrD,aAAO,CAAC;AAAA,IACV;AAAA,EACF;AAAA;AAAA;AAAA,EAGA,MAAM;AACJ,UAAM,MAAM,OAAO;AAEnB,WAAO,GAAG,GAAG,IAAI,KAAK,MAAM,KAAK,IAAI,IAAI,GAAK,CAAC;AAAA,EACjD;AACF;AASO,MAAM,uBAAuB,MAAY;AAC9C,qBAAmB,MAAM,MAAM;AACjC;",
6
6
  "names": []
7
7
  }
@@ -101,7 +101,7 @@ function loadAllLspServers() {
101
101
  const servers = /* @__PURE__ */ new Map();
102
102
  const configFiles = getAllPluginLspConfigFiles();
103
103
  for (const filePath of configFiles) {
104
- const pluginRoot = filePath.includes(".minto-plugin") ? join(filePath, "..", "..") : join(filePath, "..");
104
+ const pluginRoot = filePath.includes(".minto-plugin") || filePath.includes(".claude-plugin") ? join(filePath, "..", "..") : join(filePath, "..");
105
105
  const fileServers = parseLspConfigFile(filePath, pluginRoot);
106
106
  for (const [languageId, server] of fileServers) {
107
107
  servers.set(languageId, server);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/services/plugins/lspServers.ts"],
4
- "sourcesContent": ["/**\n * LSP Servers Service\n *\n * Handles loading and managing LSP (Language Server Protocol) server\n * configurations from plugins. This is a Claude Code CLI specific feature.\n *\n * LSP servers provide code intelligence features like:\n * - Go to definition\n * - Find references\n * - Hover information\n * - Code completion\n * - Diagnostics\n */\n\nimport { existsSync, readFileSync } from 'fs'\nimport { join, resolve, isAbsolute } from 'path'\nimport { z } from 'zod'\nimport { getAllPluginLspConfigFiles } from '@utils/session/sessionPlugins'\nimport { getCwd } from '@utils/state'\n\n/**\n * LSP server transport type\n */\nexport type LspTransport = 'stdio' | 'socket' | 'pipe'\n\n/**\n * LSP server configuration schema\n */\nexport const LspServerConfigSchema = z.object({\n // Required\n command: z.string().min(1),\n\n // Optional command args\n args: z.array(z.string()).optional().default([]),\n\n // Transport configuration\n transport: z.enum(['stdio', 'socket', 'pipe']).optional().default('stdio'),\n\n // Environment variables\n env: z.record(z.string()).optional().default({}),\n\n // File patterns this server handles\n filePatterns: z.array(z.string()).optional().default([]),\n\n // Language ID mapping (extension -> languageId)\n extensionToLanguage: z.record(z.string()).optional().default({}),\n\n // Server initialization options\n initializationOptions: z.unknown().optional(),\n\n // Server settings\n settings: z.unknown().optional(),\n\n // Workspace folder (defaults to cwd)\n workspaceFolder: z.string().optional(),\n\n // Root path for relative file resolution\n rootPath: z.string().optional(),\n\n // Timeouts\n startupTimeout: z.number().optional().default(30000), // 30s default\n shutdownTimeout: z.number().optional().default(5000), // 5s default\n\n // Restart behavior\n restartOnCrash: z.boolean().optional().default(true),\n maxRestarts: z.number().optional().default(3),\n\n // Logging\n loggingConfig: z\n .object({\n level: z\n .enum(['off', 'error', 'warn', 'info', 'debug', 'trace'])\n .optional(),\n logFile: z.string().optional(),\n })\n .optional(),\n})\n\nexport type LspServerConfig = z.infer<typeof LspServerConfigSchema>\n\n/**\n * LSP configuration file schema (.lsp.json)\n */\nexport const LspConfigSchema = z.record(z.string(), LspServerConfigSchema)\n\nexport type LspConfig = z.infer<typeof LspConfigSchema>\n\n/**\n * Loaded LSP server (runtime representation)\n */\nexport interface LoadedLspServer {\n /** Language ID this server handles */\n languageId: string\n\n /** Server configuration */\n config: LspServerConfig\n\n /** Resolved command (with plugin root expanded) */\n resolvedCommand: string\n\n /** Resolved args (with plugin root expanded) */\n resolvedArgs: string[]\n\n /** Source plugin name */\n pluginName?: string\n\n /** Source file path */\n filePath: string\n\n /** Plugin root directory */\n pluginRoot?: string\n}\n\n/**\n * LSP server state\n */\nexport interface LspServerState {\n /** Language ID */\n languageId: string\n\n /** Whether server is running */\n running: boolean\n\n /** Number of restarts */\n restartCount: number\n\n /** Last error message */\n lastError?: string\n\n /** Process ID if running */\n pid?: number\n}\n\n/**\n * Cache for loaded LSP servers\n */\nlet lspServersCache: Map<string, LoadedLspServer> | null = null\n\n/**\n * Resolve plugin path variables in a string\n */\nexport function resolvePluginPath(value: string, pluginRoot: string): string {\n if (!value) return value\n\n // Replace ${CLAUDE_PLUGIN_ROOT} variable\n let resolved = value.replace(/\\$\\{CLAUDE_PLUGIN_ROOT\\}/g, pluginRoot)\n\n // Also support $CLAUDE_PLUGIN_ROOT without braces\n resolved = resolved.replace(/\\$CLAUDE_PLUGIN_ROOT/g, pluginRoot)\n\n // Replace ${MINTO_PLUGIN_ROOT} for Minto-specific plugins\n resolved = resolved.replace(/\\$\\{MINTO_PLUGIN_ROOT\\}/g, pluginRoot)\n resolved = resolved.replace(/\\$MINTO_PLUGIN_ROOT/g, pluginRoot)\n\n // Resolve relative paths\n if (!isAbsolute(resolved) && !resolved.startsWith('$')) {\n resolved = resolve(pluginRoot, resolved)\n }\n\n return resolved\n}\n\n/**\n * Resolve plugin path variables in an array\n */\nexport function resolvePluginPaths(\n values: string[],\n pluginRoot: string,\n): string[] {\n return values.map(v => resolvePluginPath(v, pluginRoot))\n}\n\n/**\n * Resolve plugin path variables in environment object\n */\nexport function resolvePluginEnv(\n env: Record<string, string>,\n pluginRoot: string,\n): Record<string, string> {\n const resolved: Record<string, string> = {}\n\n for (const [key, value] of Object.entries(env)) {\n resolved[key] = resolvePluginPath(value, pluginRoot)\n }\n\n return resolved\n}\n\n/**\n * Parse and validate LSP config file\n */\nfunction parseLspConfigFile(\n filePath: string,\n pluginRoot?: string,\n): Map<string, LoadedLspServer> {\n const servers = new Map<string, LoadedLspServer>()\n\n if (!existsSync(filePath)) {\n return servers\n }\n\n try {\n const content = readFileSync(filePath, 'utf-8')\n const data = JSON.parse(content)\n\n const result = LspConfigSchema.safeParse(data)\n\n if (!result.success) {\n console.warn(`Invalid LSP config in ${filePath}: ${result.error.message}`)\n return servers\n }\n\n const root = pluginRoot || join(filePath, '..')\n\n for (const [languageId, config] of Object.entries(result.data)) {\n const loadedServer: LoadedLspServer = {\n languageId,\n config,\n resolvedCommand: resolvePluginPath(config.command, root),\n resolvedArgs: resolvePluginPaths(config.args || [], root),\n filePath,\n pluginRoot: root,\n }\n\n servers.set(languageId, loadedServer)\n }\n } catch (error) {\n console.warn(\n `Failed to parse LSP config ${filePath}:`,\n error instanceof Error ? error.message : String(error),\n )\n }\n\n return servers\n}\n\n/**\n * Load all LSP servers from plugins\n */\nexport function loadAllLspServers(): LoadedLspServer[] {\n // Return cached servers if available\n if (lspServersCache !== null) {\n return Array.from(lspServersCache.values())\n }\n\n const servers = new Map<string, LoadedLspServer>()\n const configFiles = getAllPluginLspConfigFiles()\n\n for (const filePath of configFiles) {\n // Extract plugin root from config file path\n // Assuming structure: pluginRoot/.minto-plugin/lsp.json or pluginRoot/lsp.json\n const pluginRoot = filePath.includes('.minto-plugin')\n ? join(filePath, '..', '..')\n : join(filePath, '..')\n\n const fileServers = parseLspConfigFile(filePath, pluginRoot)\n\n // Merge servers, later configs override earlier ones\n for (const [languageId, server] of fileServers) {\n servers.set(languageId, server)\n }\n }\n\n // Cache the results\n lspServersCache = servers\n\n return Array.from(servers.values())\n}\n\n/**\n * Get LSP server for a specific language\n */\nexport function getLspServer(languageId: string): LoadedLspServer | undefined {\n // Ensure cache is populated\n if (lspServersCache === null) {\n loadAllLspServers()\n }\n\n return lspServersCache?.get(languageId)\n}\n\n/**\n * Get LSP server for a file based on extension\n */\nexport function getLspServerForFile(\n filePath: string,\n): LoadedLspServer | undefined {\n const servers = loadAllLspServers()\n\n // Extract extension\n const ext = filePath.includes('.') ? filePath.split('.').pop() : ''\n if (!ext) return undefined\n\n // Find server that handles this extension\n for (const server of servers) {\n // Check extensionToLanguage mapping\n if (server.config.extensionToLanguage?.[ext]) {\n return server\n }\n\n // Check filePatterns\n if (\n server.config.filePatterns?.some(pattern => {\n if (pattern.startsWith('*.')) {\n return ext === pattern.slice(2)\n }\n // Simple glob matching for **/*.ext patterns\n if (pattern.includes('**')) {\n const extPattern = pattern.split('**/*.').pop()\n return ext === extPattern\n }\n return false\n })\n ) {\n return server\n }\n }\n\n return undefined\n}\n\n/**\n * Get all supported language IDs\n */\nexport function getSupportedLanguages(): string[] {\n const servers = loadAllLspServers()\n return servers.map(s => s.languageId)\n}\n\n/**\n * Check if LSP is available for a language\n */\nexport function hasLspSupport(languageId: string): boolean {\n return getLspServer(languageId) !== undefined\n}\n\n/**\n * Clear the LSP servers cache\n */\nexport function clearLspServersCache(): void {\n lspServersCache = null\n}\n\n/**\n * Get count of loaded LSP servers\n */\nexport function getLspServerCount(): number {\n return loadAllLspServers().length\n}\n\n/**\n * Validate LSP server configuration\n */\nexport function validateLspConfig(config: unknown): {\n success: boolean\n data?: LspConfig\n error?: string\n} {\n const result = LspConfigSchema.safeParse(config)\n\n if (result.success) {\n return { success: true, data: result.data }\n }\n\n return { success: false, error: result.error.message }\n}\n\n/**\n * Create LSP initialization options with resolved paths\n */\nexport function createLspInitOptions(server: LoadedLspServer): {\n command: string\n args: string[]\n env: Record<string, string>\n workspaceFolder: string\n initializationOptions: unknown\n} {\n const root = server.pluginRoot || getCwd()\n\n return {\n command: server.resolvedCommand,\n args: server.resolvedArgs,\n env: resolvePluginEnv(server.config.env || {}, root),\n workspaceFolder: server.config.workspaceFolder\n ? resolvePluginPath(server.config.workspaceFolder, root)\n : getCwd(),\n initializationOptions: server.config.initializationOptions,\n }\n}\n"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,OAAO,OAAO;AAAA,EACvC;AACF;",
4
+ "sourcesContent": ["/**\n * LSP Servers Service\n *\n * Handles loading and managing LSP (Language Server Protocol) server\n * configurations from plugins. This is a Claude Code CLI specific feature.\n *\n * LSP servers provide code intelligence features like:\n * - Go to definition\n * - Find references\n * - Hover information\n * - Code completion\n * - Diagnostics\n */\n\nimport { existsSync, readFileSync } from 'fs'\nimport { join, resolve, isAbsolute } from 'path'\nimport { z } from 'zod'\nimport { getAllPluginLspConfigFiles } from '@utils/session/sessionPlugins'\nimport { getCwd } from '@utils/state'\n\n/**\n * LSP server transport type\n */\nexport type LspTransport = 'stdio' | 'socket' | 'pipe'\n\n/**\n * LSP server configuration schema\n */\nexport const LspServerConfigSchema = z.object({\n // Required\n command: z.string().min(1),\n\n // Optional command args\n args: z.array(z.string()).optional().default([]),\n\n // Transport configuration\n transport: z.enum(['stdio', 'socket', 'pipe']).optional().default('stdio'),\n\n // Environment variables\n env: z.record(z.string()).optional().default({}),\n\n // File patterns this server handles\n filePatterns: z.array(z.string()).optional().default([]),\n\n // Language ID mapping (extension -> languageId)\n extensionToLanguage: z.record(z.string()).optional().default({}),\n\n // Server initialization options\n initializationOptions: z.unknown().optional(),\n\n // Server settings\n settings: z.unknown().optional(),\n\n // Workspace folder (defaults to cwd)\n workspaceFolder: z.string().optional(),\n\n // Root path for relative file resolution\n rootPath: z.string().optional(),\n\n // Timeouts\n startupTimeout: z.number().optional().default(30000), // 30s default\n shutdownTimeout: z.number().optional().default(5000), // 5s default\n\n // Restart behavior\n restartOnCrash: z.boolean().optional().default(true),\n maxRestarts: z.number().optional().default(3),\n\n // Logging\n loggingConfig: z\n .object({\n level: z\n .enum(['off', 'error', 'warn', 'info', 'debug', 'trace'])\n .optional(),\n logFile: z.string().optional(),\n })\n .optional(),\n})\n\nexport type LspServerConfig = z.infer<typeof LspServerConfigSchema>\n\n/**\n * LSP configuration file schema (.lsp.json)\n */\nexport const LspConfigSchema = z.record(z.string(), LspServerConfigSchema)\n\nexport type LspConfig = z.infer<typeof LspConfigSchema>\n\n/**\n * Loaded LSP server (runtime representation)\n */\nexport interface LoadedLspServer {\n /** Language ID this server handles */\n languageId: string\n\n /** Server configuration */\n config: LspServerConfig\n\n /** Resolved command (with plugin root expanded) */\n resolvedCommand: string\n\n /** Resolved args (with plugin root expanded) */\n resolvedArgs: string[]\n\n /** Source plugin name */\n pluginName?: string\n\n /** Source file path */\n filePath: string\n\n /** Plugin root directory */\n pluginRoot?: string\n}\n\n/**\n * LSP server state\n */\nexport interface LspServerState {\n /** Language ID */\n languageId: string\n\n /** Whether server is running */\n running: boolean\n\n /** Number of restarts */\n restartCount: number\n\n /** Last error message */\n lastError?: string\n\n /** Process ID if running */\n pid?: number\n}\n\n/**\n * Cache for loaded LSP servers\n */\nlet lspServersCache: Map<string, LoadedLspServer> | null = null\n\n/**\n * Resolve plugin path variables in a string\n */\nexport function resolvePluginPath(value: string, pluginRoot: string): string {\n if (!value) return value\n\n // Replace ${CLAUDE_PLUGIN_ROOT} variable\n let resolved = value.replace(/\\$\\{CLAUDE_PLUGIN_ROOT\\}/g, pluginRoot)\n\n // Also support $CLAUDE_PLUGIN_ROOT without braces\n resolved = resolved.replace(/\\$CLAUDE_PLUGIN_ROOT/g, pluginRoot)\n\n // Replace ${MINTO_PLUGIN_ROOT} for Minto-specific plugins\n resolved = resolved.replace(/\\$\\{MINTO_PLUGIN_ROOT\\}/g, pluginRoot)\n resolved = resolved.replace(/\\$MINTO_PLUGIN_ROOT/g, pluginRoot)\n\n // Resolve relative paths\n if (!isAbsolute(resolved) && !resolved.startsWith('$')) {\n resolved = resolve(pluginRoot, resolved)\n }\n\n return resolved\n}\n\n/**\n * Resolve plugin path variables in an array\n */\nexport function resolvePluginPaths(\n values: string[],\n pluginRoot: string,\n): string[] {\n return values.map(v => resolvePluginPath(v, pluginRoot))\n}\n\n/**\n * Resolve plugin path variables in environment object\n */\nexport function resolvePluginEnv(\n env: Record<string, string>,\n pluginRoot: string,\n): Record<string, string> {\n const resolved: Record<string, string> = {}\n\n for (const [key, value] of Object.entries(env)) {\n resolved[key] = resolvePluginPath(value, pluginRoot)\n }\n\n return resolved\n}\n\n/**\n * Parse and validate LSP config file\n */\nfunction parseLspConfigFile(\n filePath: string,\n pluginRoot?: string,\n): Map<string, LoadedLspServer> {\n const servers = new Map<string, LoadedLspServer>()\n\n if (!existsSync(filePath)) {\n return servers\n }\n\n try {\n const content = readFileSync(filePath, 'utf-8')\n const data = JSON.parse(content)\n\n const result = LspConfigSchema.safeParse(data)\n\n if (!result.success) {\n console.warn(`Invalid LSP config in ${filePath}: ${result.error.message}`)\n return servers\n }\n\n const root = pluginRoot || join(filePath, '..')\n\n for (const [languageId, config] of Object.entries(result.data)) {\n const loadedServer: LoadedLspServer = {\n languageId,\n config,\n resolvedCommand: resolvePluginPath(config.command, root),\n resolvedArgs: resolvePluginPaths(config.args || [], root),\n filePath,\n pluginRoot: root,\n }\n\n servers.set(languageId, loadedServer)\n }\n } catch (error) {\n console.warn(\n `Failed to parse LSP config ${filePath}:`,\n error instanceof Error ? error.message : String(error),\n )\n }\n\n return servers\n}\n\n/**\n * Load all LSP servers from plugins\n */\nexport function loadAllLspServers(): LoadedLspServer[] {\n // Return cached servers if available\n if (lspServersCache !== null) {\n return Array.from(lspServersCache.values())\n }\n\n const servers = new Map<string, LoadedLspServer>()\n const configFiles = getAllPluginLspConfigFiles()\n\n for (const filePath of configFiles) {\n // Extract plugin root from config file path\n // Assuming structure: pluginRoot/.minto-plugin/lsp.json, pluginRoot/.claude-plugin/lsp.json, or pluginRoot/lsp.json\n const pluginRoot =\n filePath.includes('.minto-plugin') || filePath.includes('.claude-plugin')\n ? join(filePath, '..', '..')\n : join(filePath, '..')\n\n const fileServers = parseLspConfigFile(filePath, pluginRoot)\n\n // Merge servers, later configs override earlier ones\n for (const [languageId, server] of fileServers) {\n servers.set(languageId, server)\n }\n }\n\n // Cache the results\n lspServersCache = servers\n\n return Array.from(servers.values())\n}\n\n/**\n * Get LSP server for a specific language\n */\nexport function getLspServer(languageId: string): LoadedLspServer | undefined {\n // Ensure cache is populated\n if (lspServersCache === null) {\n loadAllLspServers()\n }\n\n return lspServersCache?.get(languageId)\n}\n\n/**\n * Get LSP server for a file based on extension\n */\nexport function getLspServerForFile(\n filePath: string,\n): LoadedLspServer | undefined {\n const servers = loadAllLspServers()\n\n // Extract extension\n const ext = filePath.includes('.') ? filePath.split('.').pop() : ''\n if (!ext) return undefined\n\n // Find server that handles this extension\n for (const server of servers) {\n // Check extensionToLanguage mapping\n if (server.config.extensionToLanguage?.[ext]) {\n return server\n }\n\n // Check filePatterns\n if (\n server.config.filePatterns?.some(pattern => {\n if (pattern.startsWith('*.')) {\n return ext === pattern.slice(2)\n }\n // Simple glob matching for **/*.ext patterns\n if (pattern.includes('**')) {\n const extPattern = pattern.split('**/*.').pop()\n return ext === extPattern\n }\n return false\n })\n ) {\n return server\n }\n }\n\n return undefined\n}\n\n/**\n * Get all supported language IDs\n */\nexport function getSupportedLanguages(): string[] {\n const servers = loadAllLspServers()\n return servers.map(s => s.languageId)\n}\n\n/**\n * Check if LSP is available for a language\n */\nexport function hasLspSupport(languageId: string): boolean {\n return getLspServer(languageId) !== undefined\n}\n\n/**\n * Clear the LSP servers cache\n */\nexport function clearLspServersCache(): void {\n lspServersCache = null\n}\n\n/**\n * Get count of loaded LSP servers\n */\nexport function getLspServerCount(): number {\n return loadAllLspServers().length\n}\n\n/**\n * Validate LSP server configuration\n */\nexport function validateLspConfig(config: unknown): {\n success: boolean\n data?: LspConfig\n error?: string\n} {\n const result = LspConfigSchema.safeParse(config)\n\n if (result.success) {\n return { success: true, data: result.data }\n }\n\n return { success: false, error: result.error.message }\n}\n\n/**\n * Create LSP initialization options with resolved paths\n */\nexport function createLspInitOptions(server: LoadedLspServer): {\n command: string\n args: string[]\n env: Record<string, string>\n workspaceFolder: string\n initializationOptions: unknown\n} {\n const root = server.pluginRoot || getCwd()\n\n return {\n command: server.resolvedCommand,\n args: server.resolvedArgs,\n env: resolvePluginEnv(server.config.env || {}, root),\n workspaceFolder: server.config.workspaceFolder\n ? resolvePluginPath(server.config.workspaceFolder, root)\n : getCwd(),\n initializationOptions: server.config.initializationOptions,\n }\n}\n"],
5
+ "mappings": "AAcA,SAAS,YAAY,oBAAoB;AACzC,SAAS,MAAM,SAAS,kBAAkB;AAC1C,SAAS,SAAS;AAClB,SAAS,kCAAkC;AAC3C,SAAS,cAAc;AAUhB,MAAM,wBAAwB,EAAE,OAAO;AAAA;AAAA,EAE5C,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA;AAAA,EAGzB,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAG/C,WAAW,EAAE,KAAK,CAAC,SAAS,UAAU,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,OAAO;AAAA;AAAA,EAGzE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAG/C,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAGvD,qBAAqB,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAAA;AAAA,EAG/D,uBAAuB,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAG5C,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA,EAG/B,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAGrC,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAG9B,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAAK;AAAA;AAAA,EACnD,iBAAiB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAAI;AAAA;AAAA;AAAA,EAGnD,gBAAgB,EAAE,QAAQ,EAAE,SAAS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A,IACb,KAAK,iBAAiB,OAAO,OAAO,OAAO,CAAC,GAAG,IAAI;AAAA,IACnD,iBAAiB,OAAO,OAAO,kBAC3B,kBAAkB,OAAO,OAAO,iBAAiB,IAAI,IACrD,OAAO;AAAA,IACX,uBAAuB,OAAO,OAAO;AAAA,EACvC;AACF;",
6
6
  "names": []
7
7
  }
@@ -97,8 +97,9 @@ function resolveManifestPaths(rootDir, value) {
97
97
  }
98
98
  function loadPluginFromDir(rootDir) {
99
99
  const mintoManifestPath = join(rootDir, ".minto-plugin", "plugin.json");
100
+ const claudeManifestPath = join(rootDir, ".claude-plugin", "plugin.json");
100
101
  const rootManifestPath = join(rootDir, "plugin.json");
101
- const manifestPath = existsSync(mintoManifestPath) ? mintoManifestPath : existsSync(rootManifestPath) ? rootManifestPath : null;
102
+ const manifestPath = existsSync(mintoManifestPath) ? mintoManifestPath : existsSync(claudeManifestPath) ? claudeManifestPath : existsSync(rootManifestPath) ? rootManifestPath : null;
102
103
  if (!manifestPath) {
103
104
  throw new Error(
104
105
  `Plugin manifest not found (expected .minto-plugin/plugin.json or plugin.json)`
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/services/plugins/pluginRuntime.ts"],
4
- "sourcesContent": ["/**\n * Plugin Runtime\n *\n * Handles loading and managing plugins at runtime.\n * Compatible with Claude Code CLI plugin specification.\n */\n\nimport { existsSync, readFileSync, statSync } from 'fs'\nimport { homedir } from 'os'\nimport { join, resolve } from 'path'\nimport { z } from 'zod'\nimport { glob as globLib } from 'glob'\nimport { getCwd } from '@utils/state'\nimport {\n setSessionPlugins,\n getSessionPlugins,\n} from '@utils/session/sessionPlugins'\nimport type { SessionPlugin } from '@minto-types/plugin'\nimport { PluginManifestSchema } from './pluginValidation'\n\n/**\n * Expand ~ to home directory\n */\nfunction expandHome(input: string): string {\n const trimmed = input.trim()\n if (trimmed === '~') return homedir()\n if (trimmed.startsWith('~/') || trimmed.startsWith('~\\\\')) {\n return join(homedir(), trimmed.slice(2))\n }\n return trimmed\n}\n\n/**\n * Check if a string looks like a glob pattern\n */\nfunction isLikelyGlob(value: string): boolean {\n return /[*?[\\]]/.test(value)\n}\n\n/**\n * Expand plugin directory inputs (handles globs and ~ expansion)\n */\nasync function expandPluginDirInputs(\n pluginDirs: string[],\n baseDir: string,\n): Promise<string[]> {\n const out: string[] = []\n\n for (const raw of pluginDirs) {\n const trimmed = String(raw ?? '').trim()\n if (!trimmed) continue\n\n const expanded = expandHome(trimmed)\n const abs = resolve(baseDir, expanded)\n\n if (isLikelyGlob(trimmed) || isLikelyGlob(expanded)) {\n const patternsToTry =\n expanded !== trimmed ? [expanded, trimmed] : [trimmed]\n let matched = false\n\n for (const pattern of patternsToTry) {\n try {\n const matches = await globLib(pattern, {\n cwd: baseDir,\n absolute: true,\n nodir: false,\n nocase: process.platform === 'win32',\n })\n\n const dirs = matches.filter(match => {\n try {\n return existsSync(match) && statSync(match).isDirectory()\n } catch {\n return false\n }\n })\n\n if (dirs.length > 0) {\n out.push(...dirs)\n matched = true\n break\n }\n } catch {\n // Ignore glob errors\n }\n }\n\n if (matched) continue\n }\n\n out.push(abs)\n }\n\n // Remove duplicates\n const seen = new Set<string>()\n const unique: string[] = []\n for (const item of out) {\n if (seen.has(item)) continue\n seen.add(item)\n unique.push(item)\n }\n\n return unique\n}\n\n/**\n * List directory if it exists and is a directory\n */\nfunction listIfDir(path: string): string[] {\n try {\n if (!existsSync(path)) return []\n if (!statSync(path).isDirectory()) return []\n return [path]\n } catch {\n return []\n }\n}\n\n/**\n * Return file path if it exists and is a file\n */\nfunction fileIfExists(path: string): string[] {\n try {\n if (!existsSync(path)) return []\n if (!statSync(path).isFile()) return []\n return [path]\n } catch {\n return []\n }\n}\n\n/**\n * Resolve manifest paths (handles string or array values)\n */\nfunction resolveManifestPaths(\n rootDir: string,\n value: unknown,\n): { dirs: string[]; files: string[] } {\n const dirs: string[] = []\n const files: string[] = []\n const list = Array.isArray(value) ? value : value ? [value] : []\n\n for (const item of list) {\n if (typeof item !== 'string') continue\n const abs = resolve(rootDir, item)\n dirs.push(...listIfDir(abs))\n files.push(...fileIfExists(abs))\n }\n\n return { dirs, files }\n}\n\n/**\n * Load a plugin from a directory\n *\n * Uses .minto-plugin directory structure or root plugin.json.\n */\nfunction loadPluginFromDir(rootDir: string): SessionPlugin {\n // Check for manifest in order of preference\n const mintoManifestPath = join(rootDir, '.minto-plugin', 'plugin.json')\n const rootManifestPath = join(rootDir, 'plugin.json')\n\n const manifestPath = existsSync(mintoManifestPath)\n ? mintoManifestPath\n : existsSync(rootManifestPath)\n ? rootManifestPath\n : null\n\n if (!manifestPath) {\n throw new Error(\n `Plugin manifest not found (expected .minto-plugin/plugin.json or plugin.json)`,\n )\n }\n\n // Read manifest\n let manifestRaw: string\n try {\n manifestRaw = readFileSync(manifestPath, 'utf8')\n } catch (err) {\n throw new Error(`Failed to read ${manifestPath}: ${String(err)}`)\n }\n\n // Parse JSON\n let manifestJson: unknown\n try {\n manifestJson = JSON.parse(manifestRaw)\n } catch (err) {\n throw new Error(`Invalid JSON in ${manifestPath}: ${String(err)}`)\n }\n\n // Validate manifest\n const parsed = PluginManifestSchema.safeParse(manifestJson)\n if (!parsed.success) {\n throw new Error(\n `Invalid plugin manifest schema in ${manifestPath}: ${parsed.error.message}`,\n )\n }\n\n const name = parsed.data.name\n const manifestData = parsed.data as Record<string, unknown>\n\n // Resolve commands\n const manifestCommands = resolveManifestPaths(rootDir, manifestData.commands)\n const commandsDirs = [\n ...listIfDir(join(rootDir, 'commands')),\n ...manifestCommands.dirs,\n ...manifestCommands.files,\n ]\n\n // Resolve skills\n const skillsDirs = [\n ...listIfDir(join(rootDir, 'skills')),\n ...resolveManifestPaths(rootDir, manifestData.skills).dirs,\n ]\n\n // Resolve agents\n const manifestAgents = resolveManifestPaths(rootDir, manifestData.agents)\n const agentsDirs = [\n ...listIfDir(join(rootDir, 'agents')),\n ...manifestAgents.dirs,\n ...manifestAgents.files,\n ]\n\n // Resolve output styles\n const manifestOutputStyles = resolveManifestPaths(\n rootDir,\n manifestData.outputStyles,\n )\n const outputStylesDirs = [\n ...listIfDir(join(rootDir, 'output-styles')),\n ...manifestOutputStyles.dirs,\n ...manifestOutputStyles.files,\n ]\n\n // Resolve hooks\n const standardHook = fileIfExists(join(rootDir, 'hooks', 'hooks.json'))\n const hookFromManifest = resolveManifestPaths(\n rootDir,\n manifestData.hooks,\n ).files\n const hooksFiles = [...standardHook, ...hookFromManifest]\n\n // Resolve MCP config files\n const mcpConfigFiles = [\n ...fileIfExists(join(rootDir, '.mcp.json')),\n ...fileIfExists(join(rootDir, '.mcp.jsonc')),\n ...resolveManifestPaths(rootDir, manifestData.mcpServers).files,\n ]\n\n // Resolve LSP config files\n const lspConfigFiles = [\n ...fileIfExists(join(rootDir, '.lsp.json')),\n ...resolveManifestPaths(rootDir, manifestData.lspServers).files,\n ]\n\n return {\n name,\n rootDir,\n manifestPath,\n manifest: parsed.data,\n commandsDirs,\n skillsDirs,\n agentsDirs,\n hooksFiles,\n outputStylesDirs,\n mcpConfigFiles,\n lspConfigFiles,\n }\n}\n\n/**\n * Configure session plugins\n *\n * Loads plugins from the specified directories and sets them\n * as the current session plugins.\n */\nexport async function configureSessionPlugins(args: {\n pluginDirs: string[]\n baseDir?: string\n}): Promise<{ plugins: SessionPlugin[]; errors: string[] }> {\n const baseDir = args.baseDir ?? getCwd()\n const dirs = await expandPluginDirInputs(args.pluginDirs ?? [], baseDir)\n\n const plugins: SessionPlugin[] = []\n const errors: string[] = []\n\n for (const dir of dirs) {\n try {\n plugins.push(loadPluginFromDir(dir))\n } catch (err) {\n errors.push(err instanceof Error ? err.message : String(err))\n }\n }\n\n // Set the plugins\n setSessionPlugins(plugins)\n\n // Reload dependent services\n try {\n // Reload custom commands\n const { reloadCustomCommands } = await import('@services/customCommands')\n reloadCustomCommands()\n\n // Clear command cache\n const { getCommands } = await import('@commands')\n ;(getCommands as any).cache?.clear?.()\n\n // Clear MCP tools cache\n const { getClients, getMCPTools } = await import('@services/mcpClient')\n ;(getClients as any).cache?.clear?.()\n ;(getMCPTools as any).cache?.clear?.()\n } catch {\n // Ignore errors during reload - services may not be available\n }\n\n return { plugins, errors }\n}\n\n/**\n * Load plugins from default locations\n *\n * Searches for plugins in:\n * 1. User plugins directory (~/.minto/plugins)\n * 2. Project plugins directory (.minto/plugins)\n */\nexport async function loadDefaultPlugins(): Promise<{\n plugins: SessionPlugin[]\n errors: string[]\n}> {\n const home = homedir()\n const cwd = getCwd()\n\n const pluginDirs = [\n // User-level plugins\n join(home, '.minto', 'plugins'),\n // Project-level plugins\n join(cwd, '.minto', 'plugins'),\n ].filter(dir => existsSync(dir))\n\n return configureSessionPlugins({ pluginDirs, baseDir: cwd })\n}\n\n/**\n * Get all currently loaded plugins\n */\nexport function getLoadedPlugins(): SessionPlugin[] {\n return getSessionPlugins()\n}\n\n/**\n * Check if any plugins are loaded\n */\nexport function hasLoadedPlugins(): boolean {\n return getSessionPlugins().length > 0\n}\n"],
5
- "mappings": "AAOA,SAAS,YAAY,cAAc,gBAAgB;AACnD,SAAS,eAAe;AACxB,SAAS,MAAM,eAAe;AAE9B,SAAS,QAAQ,eAAe;AAChC,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,4BAA4B;AAKrC,SAAS,WAAW,OAAuB;AACzC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,YAAY,IAAK,QAAO,QAAQ;AACpC,MAAI,QAAQ,WAAW,IAAI,KAAK,QAAQ,WAAW,KAAK,GAAG;AACzD,WAAO,KAAK,QAAQ,GAAG,QAAQ,MAAM,CAAC,CAAC;AAAA,EACzC;AACA,SAAO;AACT;AAKA,SAAS,aAAa,OAAwB;AAC5C,SAAO,UAAU,KAAK,KAAK;AAC7B;AAKA,eAAe,sBACb,YACA,SACmB;AACnB,QAAM,MAAgB,CAAC;AAEvB,aAAW,OAAO,YAAY;AAC5B,UAAM,UAAU,OAAO,OAAO,EAAE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S,IAAI,CAAC;AAC7D;AAKO,SAAS,mBAAoC;AAClD,SAAO,kBAAkB;AAC3B;AAKO,SAAS,mBAA4B;AAC1C,SAAO,kBAAkB,EAAE,SAAS;AACtC;",
4
+ "sourcesContent": ["/**\n * Plugin Runtime\n *\n * Handles loading and managing plugins at runtime.\n * Compatible with Claude Code CLI plugin specification.\n */\n\nimport { existsSync, readFileSync, statSync } from 'fs'\nimport { homedir } from 'os'\nimport { join, resolve } from 'path'\nimport { z } from 'zod'\nimport { glob as globLib } from 'glob'\nimport { getCwd } from '@utils/state'\nimport {\n setSessionPlugins,\n getSessionPlugins,\n} from '@utils/session/sessionPlugins'\nimport type { SessionPlugin } from '@minto-types/plugin'\nimport { PluginManifestSchema } from './pluginValidation'\n\n/**\n * Expand ~ to home directory\n */\nfunction expandHome(input: string): string {\n const trimmed = input.trim()\n if (trimmed === '~') return homedir()\n if (trimmed.startsWith('~/') || trimmed.startsWith('~\\\\')) {\n return join(homedir(), trimmed.slice(2))\n }\n return trimmed\n}\n\n/**\n * Check if a string looks like a glob pattern\n */\nfunction isLikelyGlob(value: string): boolean {\n return /[*?[\\]]/.test(value)\n}\n\n/**\n * Expand plugin directory inputs (handles globs and ~ expansion)\n */\nasync function expandPluginDirInputs(\n pluginDirs: string[],\n baseDir: string,\n): Promise<string[]> {\n const out: string[] = []\n\n for (const raw of pluginDirs) {\n const trimmed = String(raw ?? '').trim()\n if (!trimmed) continue\n\n const expanded = expandHome(trimmed)\n const abs = resolve(baseDir, expanded)\n\n if (isLikelyGlob(trimmed) || isLikelyGlob(expanded)) {\n const patternsToTry =\n expanded !== trimmed ? [expanded, trimmed] : [trimmed]\n let matched = false\n\n for (const pattern of patternsToTry) {\n try {\n const matches = await globLib(pattern, {\n cwd: baseDir,\n absolute: true,\n nodir: false,\n nocase: process.platform === 'win32',\n })\n\n const dirs = matches.filter(match => {\n try {\n return existsSync(match) && statSync(match).isDirectory()\n } catch {\n return false\n }\n })\n\n if (dirs.length > 0) {\n out.push(...dirs)\n matched = true\n break\n }\n } catch {\n // Ignore glob errors\n }\n }\n\n if (matched) continue\n }\n\n out.push(abs)\n }\n\n // Remove duplicates\n const seen = new Set<string>()\n const unique: string[] = []\n for (const item of out) {\n if (seen.has(item)) continue\n seen.add(item)\n unique.push(item)\n }\n\n return unique\n}\n\n/**\n * List directory if it exists and is a directory\n */\nfunction listIfDir(path: string): string[] {\n try {\n if (!existsSync(path)) return []\n if (!statSync(path).isDirectory()) return []\n return [path]\n } catch {\n return []\n }\n}\n\n/**\n * Return file path if it exists and is a file\n */\nfunction fileIfExists(path: string): string[] {\n try {\n if (!existsSync(path)) return []\n if (!statSync(path).isFile()) return []\n return [path]\n } catch {\n return []\n }\n}\n\n/**\n * Resolve manifest paths (handles string or array values)\n */\nfunction resolveManifestPaths(\n rootDir: string,\n value: unknown,\n): { dirs: string[]; files: string[] } {\n const dirs: string[] = []\n const files: string[] = []\n const list = Array.isArray(value) ? value : value ? [value] : []\n\n for (const item of list) {\n if (typeof item !== 'string') continue\n const abs = resolve(rootDir, item)\n dirs.push(...listIfDir(abs))\n files.push(...fileIfExists(abs))\n }\n\n return { dirs, files }\n}\n\n/**\n * Load a plugin from a directory\n *\n * Uses .minto-plugin directory structure or root plugin.json.\n */\nfunction loadPluginFromDir(rootDir: string): SessionPlugin {\n // Check for manifest in order of preference: .minto-plugin > .claude-plugin > root\n const mintoManifestPath = join(rootDir, '.minto-plugin', 'plugin.json')\n const claudeManifestPath = join(rootDir, '.claude-plugin', 'plugin.json')\n const rootManifestPath = join(rootDir, 'plugin.json')\n\n const manifestPath = existsSync(mintoManifestPath)\n ? mintoManifestPath\n : existsSync(claudeManifestPath)\n ? claudeManifestPath\n : existsSync(rootManifestPath)\n ? rootManifestPath\n : null\n\n if (!manifestPath) {\n throw new Error(\n `Plugin manifest not found (expected .minto-plugin/plugin.json or plugin.json)`,\n )\n }\n\n // Read manifest\n let manifestRaw: string\n try {\n manifestRaw = readFileSync(manifestPath, 'utf8')\n } catch (err) {\n throw new Error(`Failed to read ${manifestPath}: ${String(err)}`)\n }\n\n // Parse JSON\n let manifestJson: unknown\n try {\n manifestJson = JSON.parse(manifestRaw)\n } catch (err) {\n throw new Error(`Invalid JSON in ${manifestPath}: ${String(err)}`)\n }\n\n // Validate manifest\n const parsed = PluginManifestSchema.safeParse(manifestJson)\n if (!parsed.success) {\n throw new Error(\n `Invalid plugin manifest schema in ${manifestPath}: ${parsed.error.message}`,\n )\n }\n\n const name = parsed.data.name\n const manifestData = parsed.data as Record<string, unknown>\n\n // Resolve commands\n const manifestCommands = resolveManifestPaths(rootDir, manifestData.commands)\n const commandsDirs = [\n ...listIfDir(join(rootDir, 'commands')),\n ...manifestCommands.dirs,\n ...manifestCommands.files,\n ]\n\n // Resolve skills\n const skillsDirs = [\n ...listIfDir(join(rootDir, 'skills')),\n ...resolveManifestPaths(rootDir, manifestData.skills).dirs,\n ]\n\n // Resolve agents\n const manifestAgents = resolveManifestPaths(rootDir, manifestData.agents)\n const agentsDirs = [\n ...listIfDir(join(rootDir, 'agents')),\n ...manifestAgents.dirs,\n ...manifestAgents.files,\n ]\n\n // Resolve output styles\n const manifestOutputStyles = resolveManifestPaths(\n rootDir,\n manifestData.outputStyles,\n )\n const outputStylesDirs = [\n ...listIfDir(join(rootDir, 'output-styles')),\n ...manifestOutputStyles.dirs,\n ...manifestOutputStyles.files,\n ]\n\n // Resolve hooks\n const standardHook = fileIfExists(join(rootDir, 'hooks', 'hooks.json'))\n const hookFromManifest = resolveManifestPaths(\n rootDir,\n manifestData.hooks,\n ).files\n const hooksFiles = [...standardHook, ...hookFromManifest]\n\n // Resolve MCP config files\n const mcpConfigFiles = [\n ...fileIfExists(join(rootDir, '.mcp.json')),\n ...fileIfExists(join(rootDir, '.mcp.jsonc')),\n ...resolveManifestPaths(rootDir, manifestData.mcpServers).files,\n ]\n\n // Resolve LSP config files\n const lspConfigFiles = [\n ...fileIfExists(join(rootDir, '.lsp.json')),\n ...resolveManifestPaths(rootDir, manifestData.lspServers).files,\n ]\n\n return {\n name,\n rootDir,\n manifestPath,\n manifest: parsed.data,\n commandsDirs,\n skillsDirs,\n agentsDirs,\n hooksFiles,\n outputStylesDirs,\n mcpConfigFiles,\n lspConfigFiles,\n }\n}\n\n/**\n * Configure session plugins\n *\n * Loads plugins from the specified directories and sets them\n * as the current session plugins.\n */\nexport async function configureSessionPlugins(args: {\n pluginDirs: string[]\n baseDir?: string\n}): Promise<{ plugins: SessionPlugin[]; errors: string[] }> {\n const baseDir = args.baseDir ?? getCwd()\n const dirs = await expandPluginDirInputs(args.pluginDirs ?? [], baseDir)\n\n const plugins: SessionPlugin[] = []\n const errors: string[] = []\n\n for (const dir of dirs) {\n try {\n plugins.push(loadPluginFromDir(dir))\n } catch (err) {\n errors.push(err instanceof Error ? err.message : String(err))\n }\n }\n\n // Set the plugins\n setSessionPlugins(plugins)\n\n // Reload dependent services\n try {\n // Reload custom commands\n const { reloadCustomCommands } = await import('@services/customCommands')\n reloadCustomCommands()\n\n // Clear command cache\n const { getCommands } = await import('@commands')\n ;(getCommands as any).cache?.clear?.()\n\n // Clear MCP tools cache\n const { getClients, getMCPTools } = await import('@services/mcpClient')\n ;(getClients as any).cache?.clear?.()\n ;(getMCPTools as any).cache?.clear?.()\n } catch {\n // Ignore errors during reload - services may not be available\n }\n\n return { plugins, errors }\n}\n\n/**\n * Load plugins from default locations\n *\n * Searches for plugins in:\n * 1. User plugins directory (~/.minto/plugins)\n * 2. Project plugins directory (.minto/plugins)\n */\nexport async function loadDefaultPlugins(): Promise<{\n plugins: SessionPlugin[]\n errors: string[]\n}> {\n const home = homedir()\n const cwd = getCwd()\n\n const pluginDirs = [\n // User-level plugins\n join(home, '.minto', 'plugins'),\n // Project-level plugins\n join(cwd, '.minto', 'plugins'),\n ].filter(dir => existsSync(dir))\n\n return configureSessionPlugins({ pluginDirs, baseDir: cwd })\n}\n\n/**\n * Get all currently loaded plugins\n */\nexport function getLoadedPlugins(): SessionPlugin[] {\n return getSessionPlugins()\n}\n\n/**\n * Check if any plugins are loaded\n */\nexport function hasLoadedPlugins(): boolean {\n return getSessionPlugins().length > 0\n}\n"],
5
+ "mappings": "AAOA,SAAS,YAAY,cAAc,gBAAgB;AACnD,SAAS,eAAe;AACxB,SAAS,MAAM,eAAe;AAE9B,SAAS,QAAQ,eAAe;AAChC,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,4BAA4B;AAKrC,SAAS,WAAW,OAAuB;AACzC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,YAAY,IAAK,QAAO,QAAQ;AACpC,MAAI,QAAQ,WAAW,IAAI,KAAK,QAAQ,WAAW,KAAK,GAAG;AACzD,WAAO,KAAK,QAAQ,GAAG,QAAQ,MAAM,CAAC,CAAC;AAAA,EACzC;AACA,SAAO;AACT;AAKA,SAAS,aAAa,OAAwB;AAC5C,SAAO,UAAU,KAAK,KAAK;AAC7B;AAKA,eAAe,sBACb,YACA,SACmB;AACnB,QAAM,MAAgB,CAAC;AAEvB,aAAW,OAAO,YAAY;AAC5B,UAAM,UAAU,OAAO,OAAO,EAAE,EAAE,KAAK;AACvC,QAAI,CAAC,QAAS;AAEd,UAAM,WAAW,WAAW,OAAO;AACnC,UAAM,MAAM,QAAQ,SAAS,QAAQ;AAErC,QAAI,aAAa,OAAO,KAAK,aAAa,QAAQ,GAAG;AACnD,YAAM,gBACJ,aAAa,UAAU,CAAC,UAAU,OAAO,IAAI,CAAC,OAAO;AACvD,UAAI,UAAU;AAEd,iBAAW,WAAW,eAAe;AACnC,YAAI;AACF,gBAAM,UAAU,MAAM,QAAQ,SAAS;AAAA,YACrC,KAAK;AAAA,YACL,UAAU;AAAA,YACV,OAAO;AAAA,YACP,QAAQ,QAAQ,aAAa;AAAA,UAC/B,CAAC;AAED,gBAAM,OAAO,QAAQ,OAAO,WAAS;AACnC,gBAAI;AACF,qBAAO,WAAW,KAAK,KAAK,SAAS,KAAK,EAAE,YAAY;AAAA,YAC1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,KAAK,kBAAkB,GAAG,CAAC;AAAA,IACrC,SAAS,KAAK;AACZ,aAAO,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,IAC9D;AAAA,EACF;AAGA,oBAAkB,OAAO;AAGzB,MAAI;AAEF,UAAM,EAAE,qBAAqB,IAAI,MAAM,OAAO,0BAA0B;AACxE,yBAAqB;AAGrB,UAAM,EAAE,YAAY,IAAI,MAAM,OAAO,WAAW;AAC/C,IAAC,YAAoB,OAAO,QAAQ;AAGrC,UAAM,EAAE,YAAY,YAAY,IAAI,MAAM,OAAO,qBAAqB;AACrE,IAAC,WAAmB,OAAO,QAAQ;AACnC,IAAC,YAAoB,OAAO,QAAQ;AAAA,EACvC,QAAQ;AAAA,EAER;AAEA,SAAO,EAAE,SAAS,OAAO;AAC3B;AASA,eAAsB,qBAGnB;AACD,QAAM,OAAO,QAAQ;AACrB,QAAM,MAAM,OAAO;AAEnB,QAAM,aAAa;AAAA;AAAA,IAEjB,KAAK,MAAM,UAAU,SAAS;AAAA;AAAA,IAE9B,KAAK,KAAK,UAAU,SAAS;AAAA,EAC/B,EAAE,OAAO,SAAO,WAAW,GAAG,CAAC;AAE/B,SAAO,wBAAwB,EAAE,YAAY,SAAS,IAAI,CAAC;AAC7D;AAKO,SAAS,mBAAoC;AAClD,SAAO,kBAAkB;AAC3B;AAKO,SAAS,mBAA4B;AAC1C,SAAO,kBAAkB,EAAE,SAAS;AACtC;",
6
6
  "names": []
7
7
  }
@@ -118,16 +118,18 @@ function validatePluginDirectory(rootDir) {
118
118
  return { isValid: false, errors, warnings };
119
119
  }
120
120
  const mintoManifest = join(resolvedPath, ".minto-plugin", "plugin.json");
121
+ const claudeManifest = join(resolvedPath, ".claude-plugin", "plugin.json");
121
122
  const rootManifest = join(resolvedPath, "plugin.json");
122
123
  const hasMintoManifest = existsSync(mintoManifest);
124
+ const hasClaudeManifest = existsSync(claudeManifest);
123
125
  const hasRootManifest = existsSync(rootManifest);
124
- if (!hasMintoManifest && !hasRootManifest) {
126
+ if (!hasMintoManifest && !hasClaudeManifest && !hasRootManifest) {
125
127
  errors.push(
126
128
  "No plugin manifest found. Expected .minto-plugin/plugin.json or plugin.json"
127
129
  );
128
130
  return { isValid: false, errors, warnings };
129
131
  }
130
- const manifestPath = hasMintoManifest ? mintoManifest : rootManifest;
132
+ const manifestPath = hasMintoManifest ? mintoManifest : hasClaudeManifest ? claudeManifest : rootManifest;
131
133
  try {
132
134
  const content = readFileSync(manifestPath, "utf-8");
133
135
  const data = JSON.parse(content);
@@ -193,7 +195,12 @@ function validateMarketplacePath(path) {
193
195
  return { isValid: false, errors, warnings };
194
196
  }
195
197
  const mintoManifest = join(resolvedPath, ".minto-plugin", "marketplace.json");
196
- if (!existsSync(mintoManifest)) {
198
+ const claudeManifest = join(
199
+ resolvedPath,
200
+ ".claude-plugin",
201
+ "marketplace.json"
202
+ );
203
+ if (!existsSync(mintoManifest) && !existsSync(claudeManifest)) {
197
204
  errors.push(
198
205
  "No marketplace manifest found. Expected .minto-plugin/marketplace.json"
199
206
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/services/plugins/pluginValidation.ts"],
4
- "sourcesContent": ["/**\n * Plugin Validation\n *\n * Validates plugin manifests and configurations.\n * Compatible with Claude Code CLI plugin specification.\n */\n\nimport { z } from 'zod'\nimport { existsSync, readFileSync, statSync } from 'fs'\nimport { join, resolve } from 'path'\n\n/**\n * Author schema (can be string or object)\n */\nconst AuthorSchema = z.union([\n z.string(),\n z.object({\n name: z.string().optional(),\n email: z.string().email().optional(),\n url: z.string().url().optional(),\n }),\n])\n\n/**\n * Hooks configuration schema\n */\nconst HooksConfigSchema = z.union([\n z.string(),\n z.array(z.string()),\n z.record(\n z.object({\n command: z.string().optional(),\n script: z.string().optional(),\n timeout: z.number().optional(),\n blocking: z.boolean().optional(),\n }),\n ),\n])\n\n/**\n * MCP Servers configuration schema\n */\nconst McpServersConfigSchema = z.union([\n z.string(),\n z.array(z.string()),\n z.record(\n z.object({\n command: z.string().optional(),\n args: z.array(z.string()).optional(),\n env: z.record(z.string()).optional(),\n type: z.enum(['stdio', 'http', 'sse']).optional(),\n url: z.string().optional(),\n headers: z.record(z.string()).optional(),\n timeout: z.number().optional(),\n }),\n ),\n])\n\n/**\n * LSP Servers configuration schema (Claude Code CLI specific)\n */\nconst LspServersConfigSchema = z.union([\n z.string(),\n z.array(z.string()),\n z.record(\n z.object({\n command: z.string(),\n args: z.array(z.string()).optional(),\n rootPath: z.string().optional(),\n filePatterns: z.array(z.string()).optional(),\n }),\n ),\n])\n\n/**\n * Minimal plugin manifest schema for loading\n * More permissive than full schema to allow partial manifests\n */\nexport const PluginManifestSchema = z\n .object({\n name: z.string().min(1),\n })\n .passthrough()\n\nexport type PluginManifestBasic = z.infer<typeof PluginManifestSchema>\n\n/**\n * Full Claude Code CLI plugin manifest schema\n * Used for strict validation\n */\nexport const FullPluginManifestSchema = z.object({\n // Required field\n name: z\n .string()\n .min(1)\n .regex(\n /^[a-z0-9-]+$/,\n 'Plugin name must be lowercase alphanumeric with hyphens',\n ),\n\n // Metadata fields (Claude Code CLI specification)\n version: z\n .string()\n .regex(/^\\d+\\.\\d+\\.\\d+$/, 'Version must follow semver format (e.g., 1.0.0)')\n .optional(),\n description: z.string().optional(),\n author: AuthorSchema.optional(),\n homepage: z.string().url().optional(),\n repository: z.string().optional(), // Can be URL or \"owner/repo\"\n license: z.string().optional(),\n keywords: z.array(z.string()).optional(),\n\n // Component path fields\n commands: z.union([z.string(), z.array(z.string())]).optional(),\n agents: z.union([z.string(), z.array(z.string())]).optional(),\n skills: z.union([z.string(), z.array(z.string())]).optional(),\n hooks: HooksConfigSchema.optional(),\n mcpServers: McpServersConfigSchema.optional(),\n outputStyles: z.union([z.string(), z.array(z.string())]).optional(),\n lspServers: LspServersConfigSchema.optional(), // Claude Code CLI specific\n\n // Engine requirements\n engines: z\n .object({\n minto: z.string().optional(),\n 'claude-code': z.string().optional(),\n node: z.string().optional(),\n })\n .optional(),\n\n // Plugin-specific configuration schema\n configSchema: z.record(z.any()).optional(),\n\n // Dependencies\n dependencies: z.record(z.string()).optional(),\n})\n\nexport type FullPluginManifest = z.infer<typeof FullPluginManifestSchema>\n\n/**\n * Validation result type\n */\nexport interface ValidationResult {\n isValid: boolean\n errors: string[]\n warnings: string[]\n}\n\n/**\n * Validate a plugin manifest (permissive)\n */\nexport function validatePluginManifest(\n manifest: unknown,\n):\n | { success: true; data: PluginManifestBasic }\n | { success: false; error: z.ZodError } {\n const result = PluginManifestSchema.safeParse(manifest)\n if (result.success) {\n return { success: true, data: result.data }\n }\n return { success: false, error: result.error }\n}\n\n/**\n * Validate a plugin manifest (strict - full Claude Code CLI specification)\n */\nexport function validatePluginManifestStrict(\n manifest: unknown,\n):\n | { success: true; data: FullPluginManifest }\n | { success: false; error: z.ZodError } {\n const result = FullPluginManifestSchema.safeParse(manifest)\n if (result.success) {\n return { success: true, data: result.data }\n }\n return { success: false, error: result.error }\n}\n\n/**\n * Validate a plugin directory structure\n */\nexport function validatePluginDirectory(rootDir: string): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n\n // Resolve path\n const resolvedPath = resolve(rootDir)\n\n // Check directory exists\n if (!existsSync(resolvedPath)) {\n errors.push(`Directory does not exist: ${resolvedPath}`)\n return { isValid: false, errors, warnings }\n }\n\n // Check it's a directory\n try {\n if (!statSync(resolvedPath).isDirectory()) {\n errors.push(`Path is not a directory: ${resolvedPath}`)\n return { isValid: false, errors, warnings }\n }\n } catch {\n errors.push(`Cannot access path: ${resolvedPath}`)\n return { isValid: false, errors, warnings }\n }\n\n // Check for manifest file\n const mintoManifest = join(resolvedPath, '.minto-plugin', 'plugin.json')\n const rootManifest = join(resolvedPath, 'plugin.json')\n\n const hasMintoManifest = existsSync(mintoManifest)\n const hasRootManifest = existsSync(rootManifest)\n\n if (!hasMintoManifest && !hasRootManifest) {\n errors.push(\n 'No plugin manifest found. Expected .minto-plugin/plugin.json or plugin.json',\n )\n return { isValid: false, errors, warnings }\n }\n\n // Prefer .minto-plugin manifest if exists\n const manifestPath = hasMintoManifest ? mintoManifest : rootManifest\n\n // Validate manifest contents\n try {\n const content = readFileSync(manifestPath, 'utf-8')\n const data = JSON.parse(content)\n\n // Permissive validation first\n const basicResult = validatePluginManifest(data)\n if (basicResult.success === false) {\n errors.push(`Invalid manifest: ${basicResult.error.message}`)\n return { isValid: false, errors, warnings }\n }\n\n // Check for recommended fields\n if (!data.version) {\n warnings.push('Manifest is missing recommended field: version')\n }\n if (!data.description) {\n warnings.push('Manifest is missing recommended field: description')\n }\n\n // Validate version format if present\n if (data.version && !/^\\d+\\.\\d+\\.\\d+$/.test(data.version)) {\n warnings.push(\n `Version \"${data.version}\" does not follow semver format (X.Y.Z)`,\n )\n }\n\n // Validate name format\n if (data.name && !/^[a-z0-9-]+$/.test(data.name)) {\n warnings.push(\n `Name \"${data.name}\" should be lowercase alphanumeric with hyphens`,\n )\n }\n\n // Check component paths exist\n const componentChecks = [\n { field: 'commands', paths: normalizeToArray(data.commands) },\n { field: 'agents', paths: normalizeToArray(data.agents) },\n { field: 'skills', paths: normalizeToArray(data.skills) },\n { field: 'outputStyles', paths: normalizeToArray(data.outputStyles) },\n ]\n\n for (const check of componentChecks) {\n for (const path of check.paths) {\n const fullPath = join(resolvedPath, path)\n if (!existsSync(fullPath)) {\n warnings.push(`${check.field} path does not exist: ${path}`)\n }\n }\n }\n } catch (error) {\n if (error instanceof SyntaxError) {\n errors.push(`Invalid JSON in manifest: ${error.message}`)\n } else {\n errors.push(\n `Error reading manifest: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n return { isValid: false, errors, warnings }\n }\n\n return { isValid: errors.length === 0, errors, warnings }\n}\n\n/**\n * Normalize string or array to array\n */\nfunction normalizeToArray(value: unknown): string[] {\n if (!value) return []\n if (typeof value === 'string') return [value]\n if (Array.isArray(value)) return value.filter(v => typeof v === 'string')\n return []\n}\n\n/**\n * Validate marketplace manifest path\n */\nexport function validateMarketplacePath(path: string): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n\n const resolvedPath = resolve(path)\n\n if (!existsSync(resolvedPath)) {\n errors.push(`Marketplace path does not exist: ${resolvedPath}`)\n return { isValid: false, errors, warnings }\n }\n\n // Check for marketplace manifest\n const mintoManifest = join(resolvedPath, '.minto-plugin', 'marketplace.json')\n\n if (!existsSync(mintoManifest)) {\n errors.push(\n 'No marketplace manifest found. Expected .minto-plugin/marketplace.json',\n )\n }\n\n return { isValid: errors.length === 0, errors, warnings }\n}\n\n/**\n * Check if a manifest is valid for loading (permissive)\n */\nexport function isValidManifest(data: unknown): boolean {\n return validatePluginManifest(data).success\n}\n\n/**\n * Check if a manifest is strictly valid\n */\nexport function isStrictlyValidManifest(data: unknown): boolean {\n return validatePluginManifestStrict(data).success\n}\n"],
5
- "mappings": "AAOA,SAAS,SAAS;AAClB,SAAS,YAAY,cAAc,gBAAgB;AACnD,SAAS,MAAM,eAAe;AAK9B,MAAM,eAAe,EAAE,MAAM;AAAA,EAC3B,EAAE,OAAO;AAAA,EACT,EAAE,OAAO;AAAA,IACP,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS;AAAA,IACnC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EACjC,CAAC;AACH,CAAC;AAKD,MAAM,oBAAoB,EAAE,MAAM;AAAA,EAChC,EAAE,OAAO;AAAA,EACT,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAClB,EAAE;AAAA,IACA,EAAE,OAAO;AAAA,MACP,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,MAC7B,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,MAC7B,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,IACjC,CAAC;AAAA,EACH;AACF,CAAC;AAKD,MAA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A2B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,MACnF;AAAA,IACF;AACA,WAAO,EAAE,SAAS,OAAO,QAAQ,SAAS;AAAA,EAC5C;AAEA,SAAO,EAAE,SAAS,OAAO,WAAW,GAAG,QAAQ,SAAS;AAC1D;AAKA,SAAS,iBAAiB,OAA0B;AAClD,MAAI,CAAC,MAAO,QAAO,CAAC;AACpB,MAAI,OAAO,UAAU,SAAU,QAAO,CAAC,KAAK;AAC5C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,OAAO,OAAK,OAAO,MAAM,QAAQ;AACxE,SAAO,CAAC;AACV;AAKO,SAAS,wBAAwB,MAAgC;AACtE,QAAM,SAAmB,CAAC;AAC1B,QAAM,WAAqB,CAAC;AAE5B,QAAM,eAAe,QAAQ,IAAI;AAEjC,MAAI,CAAC,WAAW,YAAY,GAAG;AAC7B,WAAO,KAAK,oCAAoC,YAAY,EAAE;AAC9D,WAAO,EAAE,SAAS,OAAO,QAAQ,SAAS;AAAA,EAC5C;AAGA,QAAM,gBAAgB,KAAK,cAAc,iBAAiB,kBAAkB;AAE5E,MAAI,CAAC,WAAW,aAAa,GAAG;AAC9B,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,OAAO,WAAW,GAAG,QAAQ,SAAS;AAC1D;AAKO,SAAS,gBAAgB,MAAwB;AACtD,SAAO,uBAAuB,IAAI,EAAE;AACtC;AAKO,SAAS,wBAAwB,MAAwB;AAC9D,SAAO,6BAA6B,IAAI,EAAE;AAC5C;",
4
+ "sourcesContent": ["/**\n * Plugin Validation\n *\n * Validates plugin manifests and configurations.\n * Compatible with Claude Code CLI plugin specification.\n */\n\nimport { z } from 'zod'\nimport { existsSync, readFileSync, statSync } from 'fs'\nimport { join, resolve } from 'path'\n\n/**\n * Author schema (can be string or object)\n */\nconst AuthorSchema = z.union([\n z.string(),\n z.object({\n name: z.string().optional(),\n email: z.string().email().optional(),\n url: z.string().url().optional(),\n }),\n])\n\n/**\n * Hooks configuration schema\n */\nconst HooksConfigSchema = z.union([\n z.string(),\n z.array(z.string()),\n z.record(\n z.object({\n command: z.string().optional(),\n script: z.string().optional(),\n timeout: z.number().optional(),\n blocking: z.boolean().optional(),\n }),\n ),\n])\n\n/**\n * MCP Servers configuration schema\n */\nconst McpServersConfigSchema = z.union([\n z.string(),\n z.array(z.string()),\n z.record(\n z.object({\n command: z.string().optional(),\n args: z.array(z.string()).optional(),\n env: z.record(z.string()).optional(),\n type: z.enum(['stdio', 'http', 'sse']).optional(),\n url: z.string().optional(),\n headers: z.record(z.string()).optional(),\n timeout: z.number().optional(),\n }),\n ),\n])\n\n/**\n * LSP Servers configuration schema (Claude Code CLI specific)\n */\nconst LspServersConfigSchema = z.union([\n z.string(),\n z.array(z.string()),\n z.record(\n z.object({\n command: z.string(),\n args: z.array(z.string()).optional(),\n rootPath: z.string().optional(),\n filePatterns: z.array(z.string()).optional(),\n }),\n ),\n])\n\n/**\n * Minimal plugin manifest schema for loading\n * More permissive than full schema to allow partial manifests\n */\nexport const PluginManifestSchema = z\n .object({\n name: z.string().min(1),\n })\n .passthrough()\n\nexport type PluginManifestBasic = z.infer<typeof PluginManifestSchema>\n\n/**\n * Full Claude Code CLI plugin manifest schema\n * Used for strict validation\n */\nexport const FullPluginManifestSchema = z.object({\n // Required field\n name: z\n .string()\n .min(1)\n .regex(\n /^[a-z0-9-]+$/,\n 'Plugin name must be lowercase alphanumeric with hyphens',\n ),\n\n // Metadata fields (Claude Code CLI specification)\n version: z\n .string()\n .regex(/^\\d+\\.\\d+\\.\\d+$/, 'Version must follow semver format (e.g., 1.0.0)')\n .optional(),\n description: z.string().optional(),\n author: AuthorSchema.optional(),\n homepage: z.string().url().optional(),\n repository: z.string().optional(), // Can be URL or \"owner/repo\"\n license: z.string().optional(),\n keywords: z.array(z.string()).optional(),\n\n // Component path fields\n commands: z.union([z.string(), z.array(z.string())]).optional(),\n agents: z.union([z.string(), z.array(z.string())]).optional(),\n skills: z.union([z.string(), z.array(z.string())]).optional(),\n hooks: HooksConfigSchema.optional(),\n mcpServers: McpServersConfigSchema.optional(),\n outputStyles: z.union([z.string(), z.array(z.string())]).optional(),\n lspServers: LspServersConfigSchema.optional(), // Claude Code CLI specific\n\n // Engine requirements\n engines: z\n .object({\n minto: z.string().optional(),\n 'claude-code': z.string().optional(),\n node: z.string().optional(),\n })\n .optional(),\n\n // Plugin-specific configuration schema\n configSchema: z.record(z.any()).optional(),\n\n // Dependencies\n dependencies: z.record(z.string()).optional(),\n})\n\nexport type FullPluginManifest = z.infer<typeof FullPluginManifestSchema>\n\n/**\n * Validation result type\n */\nexport interface ValidationResult {\n isValid: boolean\n errors: string[]\n warnings: string[]\n}\n\n/**\n * Validate a plugin manifest (permissive)\n */\nexport function validatePluginManifest(\n manifest: unknown,\n):\n | { success: true; data: PluginManifestBasic }\n | { success: false; error: z.ZodError } {\n const result = PluginManifestSchema.safeParse(manifest)\n if (result.success) {\n return { success: true, data: result.data }\n }\n return { success: false, error: result.error }\n}\n\n/**\n * Validate a plugin manifest (strict - full Claude Code CLI specification)\n */\nexport function validatePluginManifestStrict(\n manifest: unknown,\n):\n | { success: true; data: FullPluginManifest }\n | { success: false; error: z.ZodError } {\n const result = FullPluginManifestSchema.safeParse(manifest)\n if (result.success) {\n return { success: true, data: result.data }\n }\n return { success: false, error: result.error }\n}\n\n/**\n * Validate a plugin directory structure\n */\nexport function validatePluginDirectory(rootDir: string): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n\n // Resolve path\n const resolvedPath = resolve(rootDir)\n\n // Check directory exists\n if (!existsSync(resolvedPath)) {\n errors.push(`Directory does not exist: ${resolvedPath}`)\n return { isValid: false, errors, warnings }\n }\n\n // Check it's a directory\n try {\n if (!statSync(resolvedPath).isDirectory()) {\n errors.push(`Path is not a directory: ${resolvedPath}`)\n return { isValid: false, errors, warnings }\n }\n } catch {\n errors.push(`Cannot access path: ${resolvedPath}`)\n return { isValid: false, errors, warnings }\n }\n\n // Check for manifest file (.minto-plugin, .claude-plugin, or root)\n const mintoManifest = join(resolvedPath, '.minto-plugin', 'plugin.json')\n const claudeManifest = join(resolvedPath, '.claude-plugin', 'plugin.json')\n const rootManifest = join(resolvedPath, 'plugin.json')\n\n const hasMintoManifest = existsSync(mintoManifest)\n const hasClaudeManifest = existsSync(claudeManifest)\n const hasRootManifest = existsSync(rootManifest)\n\n if (!hasMintoManifest && !hasClaudeManifest && !hasRootManifest) {\n errors.push(\n 'No plugin manifest found. Expected .minto-plugin/plugin.json or plugin.json',\n )\n return { isValid: false, errors, warnings }\n }\n\n // Prefer .minto-plugin > .claude-plugin > root manifest\n const manifestPath = hasMintoManifest\n ? mintoManifest\n : hasClaudeManifest\n ? claudeManifest\n : rootManifest\n\n // Validate manifest contents\n try {\n const content = readFileSync(manifestPath, 'utf-8')\n const data = JSON.parse(content)\n\n // Permissive validation first\n const basicResult = validatePluginManifest(data)\n if (basicResult.success === false) {\n errors.push(`Invalid manifest: ${basicResult.error.message}`)\n return { isValid: false, errors, warnings }\n }\n\n // Check for recommended fields\n if (!data.version) {\n warnings.push('Manifest is missing recommended field: version')\n }\n if (!data.description) {\n warnings.push('Manifest is missing recommended field: description')\n }\n\n // Validate version format if present\n if (data.version && !/^\\d+\\.\\d+\\.\\d+$/.test(data.version)) {\n warnings.push(\n `Version \"${data.version}\" does not follow semver format (X.Y.Z)`,\n )\n }\n\n // Validate name format\n if (data.name && !/^[a-z0-9-]+$/.test(data.name)) {\n warnings.push(\n `Name \"${data.name}\" should be lowercase alphanumeric with hyphens`,\n )\n }\n\n // Check component paths exist\n const componentChecks = [\n { field: 'commands', paths: normalizeToArray(data.commands) },\n { field: 'agents', paths: normalizeToArray(data.agents) },\n { field: 'skills', paths: normalizeToArray(data.skills) },\n { field: 'outputStyles', paths: normalizeToArray(data.outputStyles) },\n ]\n\n for (const check of componentChecks) {\n for (const path of check.paths) {\n const fullPath = join(resolvedPath, path)\n if (!existsSync(fullPath)) {\n warnings.push(`${check.field} path does not exist: ${path}`)\n }\n }\n }\n } catch (error) {\n if (error instanceof SyntaxError) {\n errors.push(`Invalid JSON in manifest: ${error.message}`)\n } else {\n errors.push(\n `Error reading manifest: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n return { isValid: false, errors, warnings }\n }\n\n return { isValid: errors.length === 0, errors, warnings }\n}\n\n/**\n * Normalize string or array to array\n */\nfunction normalizeToArray(value: unknown): string[] {\n if (!value) return []\n if (typeof value === 'string') return [value]\n if (Array.isArray(value)) return value.filter(v => typeof v === 'string')\n return []\n}\n\n/**\n * Validate marketplace manifest path\n */\nexport function validateMarketplacePath(path: string): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n\n const resolvedPath = resolve(path)\n\n if (!existsSync(resolvedPath)) {\n errors.push(`Marketplace path does not exist: ${resolvedPath}`)\n return { isValid: false, errors, warnings }\n }\n\n // Check for marketplace manifest (.minto-plugin or .claude-plugin)\n const mintoManifest = join(resolvedPath, '.minto-plugin', 'marketplace.json')\n const claudeManifest = join(\n resolvedPath,\n '.claude-plugin',\n 'marketplace.json',\n )\n\n if (!existsSync(mintoManifest) && !existsSync(claudeManifest)) {\n errors.push(\n 'No marketplace manifest found. Expected .minto-plugin/marketplace.json',\n )\n }\n\n return { isValid: errors.length === 0, errors, warnings }\n}\n\n/**\n * Check if a manifest is valid for loading (permissive)\n */\nexport function isValidManifest(data: unknown): boolean {\n return validatePluginManifest(data).success\n}\n\n/**\n * Check if a manifest is strictly valid\n */\nexport function isStrictlyValidManifest(data: unknown): boolean {\n return validatePluginManifestStrict(data).success\n}\n"],
5
+ "mappings": "AAOA,SAAS,SAAS;AAClB,SAAS,YAAY,cAAc,gBAAgB;AACnD,SAAS,MAAM,eAAe;AAK9B,MAAM,eAAe,EAAE,MAAM;AAAA,EAC3B,EAAE,OAAO;AAAA,EACT,EAAE,OAAO;AAAA,IACP,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,OA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,EAC5C;AAGA,QAAM,gBAAgB,KAAK,cAAc,iBAAiB,kBAAkB;AAC5E,QAAM,iBAAiB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,CAAC,WAAW,aAAa,KAAK,CAAC,WAAW,cAAc,GAAG;AAC7D,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,SAAS,OAAO,WAAW,GAAG,QAAQ,SAAS;AAC1D;AAKO,SAAS,gBAAgB,MAAwB;AACtD,SAAO,uBAAuB,IAAI,EAAE;AACtC;AAKO,SAAS,wBAAwB,MAAwB;AAC9D,SAAO,6BAA6B,IAAI,EAAE;AAC5C;",
6
6
  "names": []
7
7
  }
@@ -132,7 +132,8 @@ async function fetchGitHubMarketplace(repo, ref, path) {
132
132
  const url = `https://github.com/${repo}.git`;
133
133
  const tempDir = await cloneGitRepo(url, ref);
134
134
  try {
135
- const manifestPath = path ? join(tempDir, path, ".minto-plugin", "marketplace.json") : join(tempDir, ".minto-plugin", "marketplace.json");
135
+ const baseDir = path ? join(tempDir, path) : tempDir;
136
+ const manifestPath = resolveManifestPath(baseDir, "marketplace.json");
136
137
  return loadManifestFromPath(manifestPath);
137
138
  } finally {
138
139
  try {
@@ -144,7 +145,8 @@ async function fetchGitHubMarketplace(repo, ref, path) {
144
145
  async function fetchGitMarketplace(url, ref, path) {
145
146
  const tempDir = await cloneGitRepo(url, ref);
146
147
  try {
147
- const manifestPath = path ? join(tempDir, path, ".minto-plugin", "marketplace.json") : join(tempDir, ".minto-plugin", "marketplace.json");
148
+ const baseDir = path ? join(tempDir, path) : tempDir;
149
+ const manifestPath = resolveManifestPath(baseDir, "marketplace.json");
148
150
  return loadManifestFromPath(manifestPath);
149
151
  } finally {
150
152
  try {
@@ -212,10 +214,8 @@ async function fetchNpmMarketplace(packageName, version) {
212
214
  "NPM_ERROR" /* NPM_ERROR */
213
215
  );
214
216
  }
215
- const manifestPath = join(
216
- tempDir,
217
- "package",
218
- ".minto-plugin",
217
+ const manifestPath = resolveManifestPath(
218
+ join(tempDir, "package"),
219
219
  "marketplace.json"
220
220
  );
221
221
  return loadManifestFromPath(manifestPath);
@@ -237,9 +237,16 @@ function fetchDirectoryMarketplace(dirPath) {
237
237
  } else if (!isAbsolute(dirPath)) {
238
238
  resolvedPath = resolve(getCwd(), dirPath);
239
239
  }
240
- const manifestPath = join(resolvedPath, ".minto-plugin", "marketplace.json");
240
+ const manifestPath = resolveManifestPath(resolvedPath, "marketplace.json");
241
241
  return loadManifestFromPath(manifestPath);
242
242
  }
243
+ function resolveManifestPath(baseDir, filename) {
244
+ const mintoPath = join(baseDir, ".minto-plugin", filename);
245
+ if (existsSync(mintoPath)) return mintoPath;
246
+ const claudePath = join(baseDir, ".claude-plugin", filename);
247
+ if (existsSync(claudePath)) return claudePath;
248
+ return mintoPath;
249
+ }
243
250
  function loadManifestFromPath(manifestPath) {
244
251
  if (!existsSync(manifestPath)) {
245
252
  throw new SkillMarketplaceError(
@@ -524,8 +531,9 @@ function validatePluginPath(path) {
524
531
  return { isValid: false, errors };
525
532
  }
526
533
  const mintoManifest = join(resolvedPath, ".minto-plugin", "plugin.json");
534
+ const claudeManifest = join(resolvedPath, ".claude-plugin", "plugin.json");
527
535
  const rootManifest = join(resolvedPath, "plugin.json");
528
- if (!existsSync(mintoManifest) && !existsSync(rootManifest)) {
536
+ if (!existsSync(mintoManifest) && !existsSync(claudeManifest) && !existsSync(rootManifest)) {
529
537
  errors.push(
530
538
  "No plugin manifest found. Expected .minto-plugin/plugin.json or plugin.json"
531
539
  );