claudeup 1.7.0 → 3.3.0

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 (302) hide show
  1. package/bin/claudeup.js +20 -2
  2. package/package.json +10 -19
  3. package/src/data/cli-tools.js +123 -0
  4. package/src/data/cli-tools.ts +140 -0
  5. package/{dist → src}/data/marketplaces.js +23 -24
  6. package/src/data/marketplaces.ts +95 -0
  7. package/src/data/mcp-servers.js +509 -0
  8. package/src/data/mcp-servers.ts +526 -0
  9. package/src/data/statuslines.js +159 -0
  10. package/src/data/statuslines.ts +188 -0
  11. package/src/index.js +4 -0
  12. package/src/index.ts +5 -0
  13. package/{dist → src}/main.js +46 -47
  14. package/src/main.tsx +145 -0
  15. package/src/opentui.d.ts +191 -0
  16. package/src/prerunner/index.js +87 -0
  17. package/src/prerunner/index.ts +124 -0
  18. package/{dist → src}/services/claude-runner.js +9 -10
  19. package/src/services/claude-runner.ts +31 -0
  20. package/{dist → src}/services/claude-settings.js +72 -33
  21. package/src/services/claude-settings.ts +934 -0
  22. package/src/services/local-marketplace.js +339 -0
  23. package/src/services/local-marketplace.ts +489 -0
  24. package/{dist → src}/services/mcp-registry.js +13 -14
  25. package/src/services/mcp-registry.ts +105 -0
  26. package/{dist → src}/services/plugin-manager.js +61 -13
  27. package/src/services/plugin-manager.ts +693 -0
  28. package/{dist → src}/services/plugin-mcp-config.js +19 -18
  29. package/src/services/plugin-mcp-config.ts +242 -0
  30. package/{dist → src}/services/update-cache.js +7 -8
  31. package/src/services/update-cache.ts +78 -0
  32. package/{dist → src}/services/version-check.js +15 -14
  33. package/src/services/version-check.ts +122 -0
  34. package/src/types/index.js +1 -0
  35. package/src/types/index.ts +141 -0
  36. package/src/ui/App.js +213 -0
  37. package/src/ui/App.tsx +359 -0
  38. package/src/ui/components/CategoryHeader.js +9 -0
  39. package/src/ui/components/CategoryHeader.tsx +41 -0
  40. package/{dist → src}/ui/components/ScrollableList.js +19 -6
  41. package/src/ui/components/ScrollableList.tsx +98 -0
  42. package/src/ui/components/SearchInput.js +19 -0
  43. package/src/ui/components/SearchInput.tsx +56 -0
  44. package/src/ui/components/StyledText.js +39 -0
  45. package/src/ui/components/StyledText.tsx +70 -0
  46. package/src/ui/components/TabBar.js +38 -0
  47. package/src/ui/components/TabBar.tsx +88 -0
  48. package/src/ui/components/layout/Panel.js +6 -0
  49. package/src/ui/components/layout/Panel.tsx +62 -0
  50. package/src/ui/components/layout/ProgressBar.js +14 -0
  51. package/src/ui/components/layout/ProgressBar.tsx +47 -0
  52. package/src/ui/components/layout/ScopeTabs.js +6 -0
  53. package/src/ui/components/layout/ScopeTabs.tsx +53 -0
  54. package/src/ui/components/layout/ScreenLayout.js +21 -0
  55. package/src/ui/components/layout/ScreenLayout.tsx +147 -0
  56. package/src/ui/components/layout/index.js +4 -0
  57. package/src/ui/components/layout/index.ts +4 -0
  58. package/src/ui/components/modals/ConfirmModal.js +14 -0
  59. package/src/ui/components/modals/ConfirmModal.tsx +59 -0
  60. package/src/ui/components/modals/InputModal.js +16 -0
  61. package/src/ui/components/modals/InputModal.tsx +68 -0
  62. package/src/ui/components/modals/LoadingModal.js +14 -0
  63. package/src/ui/components/modals/LoadingModal.tsx +40 -0
  64. package/src/ui/components/modals/MessageModal.js +16 -0
  65. package/src/ui/components/modals/MessageModal.tsx +64 -0
  66. package/src/ui/components/modals/ModalContainer.js +56 -0
  67. package/src/ui/components/modals/ModalContainer.tsx +104 -0
  68. package/src/ui/components/modals/SelectModal.js +26 -0
  69. package/src/ui/components/modals/SelectModal.tsx +82 -0
  70. package/src/ui/components/modals/index.js +6 -0
  71. package/src/ui/components/modals/index.ts +6 -0
  72. package/src/ui/hooks/index.js +3 -0
  73. package/src/ui/hooks/index.ts +3 -0
  74. package/{dist → src}/ui/hooks/useAsyncData.js +21 -22
  75. package/src/ui/hooks/useAsyncData.ts +127 -0
  76. package/src/ui/hooks/useKeyboard.js +13 -0
  77. package/src/ui/hooks/useKeyboard.ts +26 -0
  78. package/src/ui/hooks/useKeyboardHandler.js +39 -0
  79. package/src/ui/hooks/useKeyboardHandler.ts +63 -0
  80. package/{dist → src}/ui/screens/CliToolsScreen.js +60 -54
  81. package/src/ui/screens/CliToolsScreen.tsx +468 -0
  82. package/src/ui/screens/EnvVarsScreen.js +154 -0
  83. package/src/ui/screens/EnvVarsScreen.tsx +269 -0
  84. package/{dist → src}/ui/screens/McpRegistryScreen.js +56 -55
  85. package/src/ui/screens/McpRegistryScreen.tsx +331 -0
  86. package/{dist → src}/ui/screens/McpScreen.js +46 -47
  87. package/src/ui/screens/McpScreen.tsx +392 -0
  88. package/src/ui/screens/ModelSelectorScreen.js +292 -0
  89. package/src/ui/screens/ModelSelectorScreen.tsx +441 -0
  90. package/{dist → src}/ui/screens/PluginsScreen.js +305 -293
  91. package/src/ui/screens/PluginsScreen.tsx +1231 -0
  92. package/src/ui/screens/StatusLineScreen.js +200 -0
  93. package/src/ui/screens/StatusLineScreen.tsx +411 -0
  94. package/src/ui/screens/index.js +7 -0
  95. package/src/ui/screens/index.ts +7 -0
  96. package/src/ui/state/AnimationContext.js +34 -0
  97. package/src/ui/state/AnimationContext.tsx +76 -0
  98. package/{dist → src}/ui/state/AppContext.js +31 -32
  99. package/src/ui/state/AppContext.tsx +235 -0
  100. package/{dist → src}/ui/state/DimensionsContext.js +16 -17
  101. package/src/ui/state/DimensionsContext.tsx +144 -0
  102. package/{dist → src}/ui/state/reducer.js +89 -90
  103. package/src/ui/state/reducer.ts +467 -0
  104. package/src/ui/state/types.js +1 -0
  105. package/src/ui/state/types.ts +273 -0
  106. package/{dist → src}/utils/command-utils.js +3 -4
  107. package/src/utils/command-utils.ts +20 -0
  108. package/{dist → src}/utils/fuzzy-search.js +2 -3
  109. package/src/utils/fuzzy-search.ts +138 -0
  110. package/{dist → src}/utils/string-utils.js +6 -6
  111. package/src/utils/string-utils.ts +88 -0
  112. package/dist/data/cli-tools.d.ts +0 -13
  113. package/dist/data/cli-tools.d.ts.map +0 -1
  114. package/dist/data/cli-tools.js +0 -124
  115. package/dist/data/cli-tools.js.map +0 -1
  116. package/dist/data/marketplaces.d.ts +0 -6
  117. package/dist/data/marketplaces.d.ts.map +0 -1
  118. package/dist/data/marketplaces.js.map +0 -1
  119. package/dist/data/mcp-servers.d.ts +0 -8
  120. package/dist/data/mcp-servers.d.ts.map +0 -1
  121. package/dist/data/mcp-servers.js +0 -503
  122. package/dist/data/mcp-servers.js.map +0 -1
  123. package/dist/data/statuslines.d.ts +0 -10
  124. package/dist/data/statuslines.d.ts.map +0 -1
  125. package/dist/data/statuslines.js +0 -160
  126. package/dist/data/statuslines.js.map +0 -1
  127. package/dist/index.d.ts +0 -3
  128. package/dist/index.d.ts.map +0 -1
  129. package/dist/index.js +0 -90
  130. package/dist/index.js.map +0 -1
  131. package/dist/main.d.ts +0 -3
  132. package/dist/main.d.ts.map +0 -1
  133. package/dist/main.js.map +0 -1
  134. package/dist/prerunner/index.d.ts +0 -7
  135. package/dist/prerunner/index.d.ts.map +0 -1
  136. package/dist/prerunner/index.js +0 -64
  137. package/dist/prerunner/index.js.map +0 -1
  138. package/dist/services/claude-runner.d.ts +0 -7
  139. package/dist/services/claude-runner.d.ts.map +0 -1
  140. package/dist/services/claude-runner.js.map +0 -1
  141. package/dist/services/claude-settings.d.ts +0 -73
  142. package/dist/services/claude-settings.d.ts.map +0 -1
  143. package/dist/services/claude-settings.js.map +0 -1
  144. package/dist/services/local-marketplace.d.ts +0 -111
  145. package/dist/services/local-marketplace.d.ts.map +0 -1
  146. package/dist/services/local-marketplace.js +0 -599
  147. package/dist/services/local-marketplace.js.map +0 -1
  148. package/dist/services/mcp-registry.d.ts +0 -10
  149. package/dist/services/mcp-registry.d.ts.map +0 -1
  150. package/dist/services/mcp-registry.js.map +0 -1
  151. package/dist/services/plugin-manager.d.ts +0 -65
  152. package/dist/services/plugin-manager.d.ts.map +0 -1
  153. package/dist/services/plugin-manager.js.map +0 -1
  154. package/dist/services/plugin-mcp-config.d.ts +0 -52
  155. package/dist/services/plugin-mcp-config.d.ts.map +0 -1
  156. package/dist/services/plugin-mcp-config.js.map +0 -1
  157. package/dist/services/update-cache.d.ts +0 -16
  158. package/dist/services/update-cache.d.ts.map +0 -1
  159. package/dist/services/update-cache.js.map +0 -1
  160. package/dist/services/version-check.d.ts +0 -20
  161. package/dist/services/version-check.d.ts.map +0 -1
  162. package/dist/services/version-check.js.map +0 -1
  163. package/dist/types/index.d.ts +0 -105
  164. package/dist/types/index.d.ts.map +0 -1
  165. package/dist/types/index.js +0 -2
  166. package/dist/types/index.js.map +0 -1
  167. package/dist/ui/InkApp.d.ts +0 -5
  168. package/dist/ui/InkApp.d.ts.map +0 -1
  169. package/dist/ui/InkApp.js +0 -188
  170. package/dist/ui/InkApp.js.map +0 -1
  171. package/dist/ui/components/CategoryHeader.d.ts +0 -16
  172. package/dist/ui/components/CategoryHeader.d.ts.map +0 -1
  173. package/dist/ui/components/CategoryHeader.js +0 -11
  174. package/dist/ui/components/CategoryHeader.js.map +0 -1
  175. package/dist/ui/components/ScrollableList.d.ts +0 -16
  176. package/dist/ui/components/ScrollableList.d.ts.map +0 -1
  177. package/dist/ui/components/ScrollableList.js.map +0 -1
  178. package/dist/ui/components/SearchInput.d.ts +0 -18
  179. package/dist/ui/components/SearchInput.d.ts.map +0 -1
  180. package/dist/ui/components/SearchInput.js +0 -30
  181. package/dist/ui/components/SearchInput.js.map +0 -1
  182. package/dist/ui/components/TabBar.d.ts +0 -8
  183. package/dist/ui/components/TabBar.d.ts.map +0 -1
  184. package/dist/ui/components/TabBar.js +0 -18
  185. package/dist/ui/components/TabBar.js.map +0 -1
  186. package/dist/ui/components/layout/Footer.d.ts +0 -14
  187. package/dist/ui/components/layout/Footer.d.ts.map +0 -1
  188. package/dist/ui/components/layout/Footer.js +0 -23
  189. package/dist/ui/components/layout/Footer.js.map +0 -1
  190. package/dist/ui/components/layout/Header.d.ts +0 -4
  191. package/dist/ui/components/layout/Header.d.ts.map +0 -1
  192. package/dist/ui/components/layout/Header.js +0 -25
  193. package/dist/ui/components/layout/Header.js.map +0 -1
  194. package/dist/ui/components/layout/Panel.d.ts +0 -22
  195. package/dist/ui/components/layout/Panel.d.ts.map +0 -1
  196. package/dist/ui/components/layout/Panel.js +0 -8
  197. package/dist/ui/components/layout/Panel.js.map +0 -1
  198. package/dist/ui/components/layout/ProgressBar.d.ts +0 -12
  199. package/dist/ui/components/layout/ProgressBar.d.ts.map +0 -1
  200. package/dist/ui/components/layout/ProgressBar.js +0 -16
  201. package/dist/ui/components/layout/ProgressBar.js.map +0 -1
  202. package/dist/ui/components/layout/ScopeTabs.d.ts +0 -12
  203. package/dist/ui/components/layout/ScopeTabs.d.ts.map +0 -1
  204. package/dist/ui/components/layout/ScopeTabs.js +0 -8
  205. package/dist/ui/components/layout/ScopeTabs.js.map +0 -1
  206. package/dist/ui/components/layout/ScreenLayout.d.ts +0 -30
  207. package/dist/ui/components/layout/ScreenLayout.d.ts.map +0 -1
  208. package/dist/ui/components/layout/ScreenLayout.js +0 -23
  209. package/dist/ui/components/layout/ScreenLayout.js.map +0 -1
  210. package/dist/ui/components/layout/index.d.ts +0 -7
  211. package/dist/ui/components/layout/index.d.ts.map +0 -1
  212. package/dist/ui/components/layout/index.js +0 -7
  213. package/dist/ui/components/layout/index.js.map +0 -1
  214. package/dist/ui/components/modals/ConfirmModal.d.ts +0 -14
  215. package/dist/ui/components/modals/ConfirmModal.d.ts.map +0 -1
  216. package/dist/ui/components/modals/ConfirmModal.js +0 -15
  217. package/dist/ui/components/modals/ConfirmModal.js.map +0 -1
  218. package/dist/ui/components/modals/InputModal.d.ts +0 -16
  219. package/dist/ui/components/modals/InputModal.d.ts.map +0 -1
  220. package/dist/ui/components/modals/InputModal.js +0 -23
  221. package/dist/ui/components/modals/InputModal.js.map +0 -1
  222. package/dist/ui/components/modals/LoadingModal.d.ts +0 -8
  223. package/dist/ui/components/modals/LoadingModal.d.ts.map +0 -1
  224. package/dist/ui/components/modals/LoadingModal.js +0 -8
  225. package/dist/ui/components/modals/LoadingModal.js.map +0 -1
  226. package/dist/ui/components/modals/MessageModal.d.ts +0 -14
  227. package/dist/ui/components/modals/MessageModal.d.ts.map +0 -1
  228. package/dist/ui/components/modals/MessageModal.js +0 -17
  229. package/dist/ui/components/modals/MessageModal.js.map +0 -1
  230. package/dist/ui/components/modals/ModalContainer.d.ts +0 -7
  231. package/dist/ui/components/modals/ModalContainer.d.ts.map +0 -1
  232. package/dist/ui/components/modals/ModalContainer.js +0 -38
  233. package/dist/ui/components/modals/ModalContainer.js.map +0 -1
  234. package/dist/ui/components/modals/SelectModal.d.ts +0 -17
  235. package/dist/ui/components/modals/SelectModal.d.ts.map +0 -1
  236. package/dist/ui/components/modals/SelectModal.js +0 -33
  237. package/dist/ui/components/modals/SelectModal.js.map +0 -1
  238. package/dist/ui/components/modals/index.d.ts +0 -7
  239. package/dist/ui/components/modals/index.d.ts.map +0 -1
  240. package/dist/ui/components/modals/index.js +0 -7
  241. package/dist/ui/components/modals/index.js.map +0 -1
  242. package/dist/ui/hooks/index.d.ts +0 -3
  243. package/dist/ui/hooks/index.d.ts.map +0 -1
  244. package/dist/ui/hooks/index.js +0 -3
  245. package/dist/ui/hooks/index.js.map +0 -1
  246. package/dist/ui/hooks/useAsyncData.d.ts +0 -40
  247. package/dist/ui/hooks/useAsyncData.d.ts.map +0 -1
  248. package/dist/ui/hooks/useAsyncData.js.map +0 -1
  249. package/dist/ui/hooks/useKeyboardNavigation.d.ts +0 -27
  250. package/dist/ui/hooks/useKeyboardNavigation.d.ts.map +0 -1
  251. package/dist/ui/hooks/useKeyboardNavigation.js +0 -82
  252. package/dist/ui/hooks/useKeyboardNavigation.js.map +0 -1
  253. package/dist/ui/screens/CliToolsScreen.d.ts +0 -4
  254. package/dist/ui/screens/CliToolsScreen.d.ts.map +0 -1
  255. package/dist/ui/screens/CliToolsScreen.js.map +0 -1
  256. package/dist/ui/screens/EnvVarsScreen.d.ts +0 -4
  257. package/dist/ui/screens/EnvVarsScreen.d.ts.map +0 -1
  258. package/dist/ui/screens/EnvVarsScreen.js +0 -145
  259. package/dist/ui/screens/EnvVarsScreen.js.map +0 -1
  260. package/dist/ui/screens/McpRegistryScreen.d.ts +0 -4
  261. package/dist/ui/screens/McpRegistryScreen.d.ts.map +0 -1
  262. package/dist/ui/screens/McpRegistryScreen.js.map +0 -1
  263. package/dist/ui/screens/McpScreen.d.ts +0 -4
  264. package/dist/ui/screens/McpScreen.d.ts.map +0 -1
  265. package/dist/ui/screens/McpScreen.js.map +0 -1
  266. package/dist/ui/screens/ModelSelectorScreen.d.ts +0 -4
  267. package/dist/ui/screens/ModelSelectorScreen.d.ts.map +0 -1
  268. package/dist/ui/screens/ModelSelectorScreen.js +0 -143
  269. package/dist/ui/screens/ModelSelectorScreen.js.map +0 -1
  270. package/dist/ui/screens/PluginsScreen.d.ts +0 -4
  271. package/dist/ui/screens/PluginsScreen.d.ts.map +0 -1
  272. package/dist/ui/screens/PluginsScreen.js.map +0 -1
  273. package/dist/ui/screens/StatusLineScreen.d.ts +0 -4
  274. package/dist/ui/screens/StatusLineScreen.d.ts.map +0 -1
  275. package/dist/ui/screens/StatusLineScreen.js +0 -197
  276. package/dist/ui/screens/StatusLineScreen.js.map +0 -1
  277. package/dist/ui/screens/index.d.ts +0 -8
  278. package/dist/ui/screens/index.d.ts.map +0 -1
  279. package/dist/ui/screens/index.js +0 -8
  280. package/dist/ui/screens/index.js.map +0 -1
  281. package/dist/ui/state/AppContext.d.ts +0 -40
  282. package/dist/ui/state/AppContext.d.ts.map +0 -1
  283. package/dist/ui/state/AppContext.js.map +0 -1
  284. package/dist/ui/state/DimensionsContext.d.ts +0 -27
  285. package/dist/ui/state/DimensionsContext.d.ts.map +0 -1
  286. package/dist/ui/state/DimensionsContext.js.map +0 -1
  287. package/dist/ui/state/reducer.d.ts +0 -4
  288. package/dist/ui/state/reducer.d.ts.map +0 -1
  289. package/dist/ui/state/reducer.js.map +0 -1
  290. package/dist/ui/state/types.d.ts +0 -266
  291. package/dist/ui/state/types.d.ts.map +0 -1
  292. package/dist/ui/state/types.js +0 -2
  293. package/dist/ui/state/types.js.map +0 -1
  294. package/dist/utils/command-utils.d.ts +0 -8
  295. package/dist/utils/command-utils.d.ts.map +0 -1
  296. package/dist/utils/command-utils.js.map +0 -1
  297. package/dist/utils/fuzzy-search.d.ts +0 -33
  298. package/dist/utils/fuzzy-search.d.ts.map +0 -1
  299. package/dist/utils/fuzzy-search.js.map +0 -1
  300. package/dist/utils/string-utils.d.ts +0 -24
  301. package/dist/utils/string-utils.d.ts.map +0 -1
  302. package/dist/utils/string-utils.js.map +0 -1
@@ -0,0 +1,339 @@
1
+ import fs from "fs-extra";
2
+ import path from "node:path";
3
+ import os from "node:os";
4
+ import { execSync } from "node:child_process";
5
+ const CLAUDE_PLUGINS_DIR = path.join(os.homedir(), ".claude", "plugins", "marketplaces");
6
+ const KNOWN_MARKETPLACES_FILE = path.join(os.homedir(), ".claude", "plugins", "known_marketplaces.json");
7
+ /**
8
+ * Read known_marketplaces.json (Claude Code's internal marketplace tracking)
9
+ */
10
+ async function readKnownMarketplaces() {
11
+ try {
12
+ if (await fs.pathExists(KNOWN_MARKETPLACES_FILE)) {
13
+ return await fs.readJson(KNOWN_MARKETPLACES_FILE);
14
+ }
15
+ }
16
+ catch {
17
+ // Return empty if can't read
18
+ }
19
+ return {};
20
+ }
21
+ /**
22
+ * Get git remote URL from a marketplace directory
23
+ */
24
+ function getGitRemote(marketplacePath) {
25
+ try {
26
+ const gitDir = path.join(marketplacePath, ".git");
27
+ if (!fs.existsSync(gitDir))
28
+ return undefined;
29
+ const result = execSync("git remote get-url origin", {
30
+ cwd: marketplacePath,
31
+ encoding: "utf-8",
32
+ timeout: 5000,
33
+ }).trim();
34
+ // Convert SSH URL to HTTPS format: git@github.com:user/repo.git -> user/repo
35
+ if (result.startsWith("git@github.com:")) {
36
+ return result.replace("git@github.com:", "").replace(/\.git$/, "");
37
+ }
38
+ // HTTPS URL: https://github.com/user/repo -> user/repo
39
+ if (result.includes("github.com")) {
40
+ const match = result.match(/github\.com[/:]([^/]+\/[^/\s.]+)/);
41
+ if (match)
42
+ return match[1].replace(/\.git$/, "");
43
+ }
44
+ return undefined;
45
+ }
46
+ catch {
47
+ return undefined;
48
+ }
49
+ }
50
+ /**
51
+ * Scan a single marketplace directory and return marketplace info
52
+ */
53
+ async function scanSingleMarketplace(marketplacePath, marketplaceName) {
54
+ const manifestPath = path.join(marketplacePath, ".claude-plugin", "marketplace.json");
55
+ if (!(await fs.pathExists(manifestPath)))
56
+ return null;
57
+ try {
58
+ const manifest = await fs.readJson(manifestPath);
59
+ const gitRepo = getGitRemote(marketplacePath);
60
+ const plugins = [];
61
+ const validManifestPlugins = [];
62
+ let manifestModified = false;
63
+ if (manifest.plugins && Array.isArray(manifest.plugins)) {
64
+ for (const plugin of manifest.plugins) {
65
+ // Try to scan plugin directory for component counts
66
+ let agents = [];
67
+ let commands = [];
68
+ let skills = [];
69
+ let mcpServers = [];
70
+ // Handle both string sources (local paths) and object sources (remote URLs)
71
+ const sourceStr = typeof plugin.source === "string" ? plugin.source : null;
72
+ if (sourceStr) {
73
+ const pluginPath = path.join(marketplacePath, sourceStr.replace("./", ""));
74
+ // Remove plugins whose source directory doesn't exist
75
+ if (!(await fs.pathExists(pluginPath))) {
76
+ manifestModified = true;
77
+ continue;
78
+ }
79
+ try {
80
+ // Scan for agents
81
+ const agentsDir = path.join(pluginPath, "agents");
82
+ if (await fs.pathExists(agentsDir)) {
83
+ const agentFiles = await fs.readdir(agentsDir);
84
+ agents = agentFiles
85
+ .filter((f) => f.endsWith(".md"))
86
+ .map((f) => f.replace(".md", ""));
87
+ }
88
+ // Scan for commands
89
+ const commandsDir = path.join(pluginPath, "commands");
90
+ if (await fs.pathExists(commandsDir)) {
91
+ const cmdFiles = await fs.readdir(commandsDir);
92
+ commands = cmdFiles
93
+ .filter((f) => f.endsWith(".md"))
94
+ .map((f) => f.replace(".md", ""));
95
+ }
96
+ // Scan for skills
97
+ const skillsDir = path.join(pluginPath, "skills");
98
+ if (await fs.pathExists(skillsDir)) {
99
+ const skillFiles = await fs.readdir(skillsDir);
100
+ skills = skillFiles.filter((f) => f.endsWith(".md") ||
101
+ fs.statSync(path.join(skillsDir, f)).isDirectory());
102
+ }
103
+ // Scan for MCP servers
104
+ const mcpDir = path.join(pluginPath, "mcp-servers");
105
+ if (await fs.pathExists(mcpDir)) {
106
+ const mcpFiles = await fs.readdir(mcpDir);
107
+ mcpServers = mcpFiles
108
+ .filter((f) => f.endsWith(".json"))
109
+ .map((f) => f.replace(".json", ""));
110
+ }
111
+ }
112
+ catch {
113
+ // Ignore scan errors
114
+ }
115
+ }
116
+ validManifestPlugins.push(plugin);
117
+ plugins.push({
118
+ name: plugin.name,
119
+ version: plugin.version || "0.0.0",
120
+ description: plugin.description || "",
121
+ source: plugin.source,
122
+ category: plugin.category,
123
+ author: plugin.author,
124
+ strict: plugin.strict,
125
+ lspServers: plugin.lspServers,
126
+ agents,
127
+ commands,
128
+ skills,
129
+ mcpServers,
130
+ });
131
+ }
132
+ }
133
+ // Update marketplace.json if we removed invalid plugins
134
+ if (manifestModified) {
135
+ manifest.plugins = validManifestPlugins;
136
+ await fs.writeJson(manifestPath, manifest, { spaces: 2 });
137
+ }
138
+ return {
139
+ name: manifest.name || marketplaceName,
140
+ description: manifest.description || manifest.metadata?.description || "",
141
+ plugins,
142
+ gitRepo,
143
+ };
144
+ }
145
+ catch {
146
+ return null;
147
+ }
148
+ }
149
+ /**
150
+ * Scan local marketplace cache and return marketplace info
151
+ * Includes both:
152
+ * - Marketplaces in ~/.claude/plugins/marketplaces/
153
+ * - Directory-based marketplaces from known_marketplaces.json
154
+ */
155
+ export async function scanLocalMarketplaces() {
156
+ const marketplaces = new Map();
157
+ // 1. Scan marketplaces from the standard directory
158
+ if (await fs.pathExists(CLAUDE_PLUGINS_DIR)) {
159
+ try {
160
+ const entries = await fs.readdir(CLAUDE_PLUGINS_DIR, {
161
+ withFileTypes: true,
162
+ });
163
+ for (const entry of entries) {
164
+ if (!entry.isDirectory())
165
+ continue;
166
+ const marketplacePath = path.join(CLAUDE_PLUGINS_DIR, entry.name);
167
+ const marketplace = await scanSingleMarketplace(marketplacePath, entry.name);
168
+ if (marketplace) {
169
+ marketplaces.set(entry.name, marketplace);
170
+ }
171
+ }
172
+ }
173
+ catch {
174
+ // Ignore read errors
175
+ }
176
+ }
177
+ // 2. Add directory-based marketplaces from known_marketplaces.json
178
+ try {
179
+ const known = await readKnownMarketplaces();
180
+ for (const [name, entry] of Object.entries(known)) {
181
+ // Only add if it's a directory source AND not already in the map
182
+ if (entry.source.source === "directory" &&
183
+ entry.installLocation &&
184
+ !marketplaces.has(name)) {
185
+ if (await fs.pathExists(entry.installLocation)) {
186
+ const marketplace = await scanSingleMarketplace(entry.installLocation, name);
187
+ if (marketplace) {
188
+ marketplaces.set(name, marketplace);
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
194
+ catch {
195
+ // Ignore errors reading known_marketplaces
196
+ }
197
+ return marketplaces;
198
+ }
199
+ /**
200
+ * Get a specific local marketplace by name
201
+ */
202
+ export async function getLocalMarketplace(name) {
203
+ const marketplaces = await scanLocalMarketplaces();
204
+ return marketplaces.get(name);
205
+ }
206
+ /**
207
+ * Check if a marketplace exists in local cache
208
+ */
209
+ export async function hasLocalMarketplace(name) {
210
+ const marketplacePath = path.join(CLAUDE_PLUGINS_DIR, name);
211
+ const manifestPath = path.join(marketplacePath, ".claude-plugin", "marketplace.json");
212
+ return fs.pathExists(manifestPath);
213
+ }
214
+ /**
215
+ * Repair a plugin's plugin.json by adding missing agents/commands/skills arrays
216
+ * based on what files exist on disk.
217
+ *
218
+ * This fixes plugins where the author forgot to add the arrays to plugin.json,
219
+ * causing Claude Code to not load the agents/commands even though files exist.
220
+ */
221
+ export async function repairPluginJson(pluginPath) {
222
+ const pluginJsonPath = path.join(pluginPath, ".claude-plugin", "plugin.json");
223
+ const pluginName = path.basename(pluginPath);
224
+ const result = {
225
+ repaired: false,
226
+ pluginName,
227
+ added: { agents: [], commands: [], skills: [] },
228
+ };
229
+ if (!(await fs.pathExists(pluginJsonPath))) {
230
+ return result;
231
+ }
232
+ try {
233
+ const pluginJson = await fs.readJson(pluginJsonPath);
234
+ let modified = false;
235
+ // Scan and add agents if array is missing
236
+ const agentsDir = path.join(pluginPath, "agents");
237
+ if (await fs.pathExists(agentsDir)) {
238
+ const files = (await fs.readdir(agentsDir))
239
+ .filter((f) => f.endsWith(".md"))
240
+ .map((f) => `./agents/${f}`);
241
+ if (files.length > 0 && !pluginJson.agents) {
242
+ pluginJson.agents = files;
243
+ result.added.agents = files;
244
+ modified = true;
245
+ }
246
+ }
247
+ // Scan and add commands if array is missing
248
+ const commandsDir = path.join(pluginPath, "commands");
249
+ if (await fs.pathExists(commandsDir)) {
250
+ const files = (await fs.readdir(commandsDir))
251
+ .filter((f) => f.endsWith(".md"))
252
+ .map((f) => `./commands/${f}`);
253
+ if (files.length > 0 && !pluginJson.commands) {
254
+ pluginJson.commands = files;
255
+ result.added.commands = files;
256
+ modified = true;
257
+ }
258
+ }
259
+ // Scan and add skills if array is missing
260
+ const skillsDir = path.join(pluginPath, "skills");
261
+ if (await fs.pathExists(skillsDir)) {
262
+ const entries = await fs.readdir(skillsDir, { withFileTypes: true });
263
+ const skills = entries
264
+ .filter((e) => e.isDirectory() || e.name.endsWith(".md"))
265
+ .map((e) => `./skills/${e.name}`);
266
+ if (skills.length > 0 && !pluginJson.skills) {
267
+ pluginJson.skills = skills;
268
+ result.added.skills = skills;
269
+ modified = true;
270
+ }
271
+ }
272
+ if (modified) {
273
+ await fs.writeJson(pluginJsonPath, pluginJson, { spaces: 2 });
274
+ result.repaired = true;
275
+ }
276
+ }
277
+ catch {
278
+ // Ignore repair errors for individual plugins
279
+ }
280
+ return result;
281
+ }
282
+ /**
283
+ * Repair all plugins in a marketplace
284
+ */
285
+ export async function repairMarketplacePlugins(marketplaceName) {
286
+ const result = {
287
+ marketplace: marketplaceName,
288
+ repaired: [],
289
+ };
290
+ const marketplacePath = path.join(CLAUDE_PLUGINS_DIR, marketplaceName);
291
+ const manifestPath = path.join(marketplacePath, ".claude-plugin", "marketplace.json");
292
+ if (!(await fs.pathExists(manifestPath))) {
293
+ return result;
294
+ }
295
+ try {
296
+ const manifest = await fs.readJson(manifestPath);
297
+ if (manifest.plugins && Array.isArray(manifest.plugins)) {
298
+ for (const plugin of manifest.plugins) {
299
+ if (plugin.source) {
300
+ const pluginPath = path.join(marketplacePath, plugin.source.replace("./", ""));
301
+ const repairResult = await repairPluginJson(pluginPath);
302
+ if (repairResult.repaired) {
303
+ result.repaired.push(repairResult);
304
+ }
305
+ }
306
+ }
307
+ }
308
+ }
309
+ catch {
310
+ // Ignore errors
311
+ }
312
+ return result;
313
+ }
314
+ /**
315
+ * Repair all plugins in all marketplaces
316
+ */
317
+ export async function repairAllMarketplaces() {
318
+ const results = [];
319
+ if (!(await fs.pathExists(CLAUDE_PLUGINS_DIR))) {
320
+ return results;
321
+ }
322
+ try {
323
+ const entries = await fs.readdir(CLAUDE_PLUGINS_DIR, {
324
+ withFileTypes: true,
325
+ });
326
+ for (const entry of entries) {
327
+ if (!entry.isDirectory())
328
+ continue;
329
+ const repairResult = await repairMarketplacePlugins(entry.name);
330
+ if (repairResult.repaired.length > 0) {
331
+ results.push(repairResult);
332
+ }
333
+ }
334
+ }
335
+ catch {
336
+ // Return empty on error
337
+ }
338
+ return results;
339
+ }