@monoes/monomindcli 1.15.6 → 1.16.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 (164) hide show
  1. package/.claude/agents/github/repo-architect.md +1 -1
  2. package/.claude/agents/specialists/integration-architect.md +6 -6
  3. package/.claude/commands/hive-mind/hive-mind-init.md +1 -1
  4. package/.claude/commands/hive-mind/hive-mind-memory.md +1 -1
  5. package/.claude/commands/mastermind/brain.md +11 -11
  6. package/.claude/commands/mastermind/master.md +4 -4
  7. package/.claude/commands/mastermind/memory.md +6 -6
  8. package/.claude/commands/memory/README.md +4 -4
  9. package/.claude/commands/truth/start.md +3 -3
  10. package/.claude/helpers/extras-registry.json +2 -2
  11. package/.claude/helpers/skill-registry.json +26 -26
  12. package/.claude/helpers/statusline.cjs +8 -8
  13. package/.claude/skills/agentic-jujutsu/SKILL.md +3 -3
  14. package/.claude/skills/mastermind/_protocol.md +8 -8
  15. package/README.md +6 -6
  16. package/dist/src/__tests__/browse-analyzer.test.js +18 -1
  17. package/dist/src/__tests__/browse-analyzer.test.js.map +1 -1
  18. package/dist/src/commands/agent.js +2 -2
  19. package/dist/src/commands/agent.js.map +1 -1
  20. package/dist/src/commands/autopilot.js +1 -1
  21. package/dist/src/commands/autopilot.js.map +1 -1
  22. package/dist/src/commands/completions.d.ts.map +1 -1
  23. package/dist/src/commands/completions.js +2 -21
  24. package/dist/src/commands/completions.js.map +1 -1
  25. package/dist/src/commands/config.js +1 -1
  26. package/dist/src/commands/hive-mind.js +1 -1
  27. package/dist/src/commands/hooks-coverage-commands.js +31 -31
  28. package/dist/src/commands/hooks-coverage-commands.js.map +1 -1
  29. package/dist/src/commands/hooks-routing-commands.js +1 -1
  30. package/dist/src/commands/hooks-routing-commands.js.map +1 -1
  31. package/dist/src/commands/hooks.js +1 -1
  32. package/dist/src/commands/hooks.js.map +1 -1
  33. package/dist/src/commands/index.d.ts +0 -1
  34. package/dist/src/commands/index.d.ts.map +1 -1
  35. package/dist/src/commands/index.js +0 -4
  36. package/dist/src/commands/index.js.map +1 -1
  37. package/dist/src/commands/init.js +8 -8
  38. package/dist/src/commands/init.js.map +1 -1
  39. package/dist/src/commands/memory.d.ts +1 -1
  40. package/dist/src/commands/memory.d.ts.map +1 -1
  41. package/dist/src/commands/memory.js +138 -28
  42. package/dist/src/commands/memory.js.map +1 -1
  43. package/dist/src/commands/migrate.js +2 -2
  44. package/dist/src/commands/neural.js +1 -1
  45. package/dist/src/commands/neural.js.map +1 -1
  46. package/dist/src/commands/swarm.js +1 -1
  47. package/dist/src/commands/swarm.js.map +1 -1
  48. package/dist/src/config-adapter.d.ts.map +1 -1
  49. package/dist/src/config-adapter.js +8 -8
  50. package/dist/src/config-adapter.js.map +1 -1
  51. package/dist/src/index.js +1 -1
  52. package/dist/src/index.js.map +1 -1
  53. package/dist/src/init/claudemd-generator.js +2 -2
  54. package/dist/src/init/executor.js +16 -16
  55. package/dist/src/init/executor.js.map +1 -1
  56. package/dist/src/init/shared-instructions-generator.d.ts +1 -1
  57. package/dist/src/init/shared-instructions-generator.js +1 -1
  58. package/dist/src/init/statusline-generator.d.ts +1 -1
  59. package/dist/src/init/statusline-generator.js +8 -8
  60. package/dist/src/init/types.d.ts +3 -3
  61. package/dist/src/init/types.d.ts.map +1 -1
  62. package/dist/src/init/types.js +3 -3
  63. package/dist/src/init/types.js.map +1 -1
  64. package/dist/src/mcp-client.d.ts.map +1 -1
  65. package/dist/src/mcp-client.js +1 -8
  66. package/dist/src/mcp-client.js.map +1 -1
  67. package/dist/src/mcp-tools/autopilot-tools.js +3 -3
  68. package/dist/src/mcp-tools/autopilot-tools.js.map +1 -1
  69. package/dist/src/mcp-tools/daa-tools.js +13 -13
  70. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  71. package/dist/src/mcp-tools/guidance-tools.js +4 -4
  72. package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
  73. package/dist/src/mcp-tools/hive-mind-tools.js +4 -4
  74. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  75. package/dist/src/mcp-tools/hooks-intelligence.d.ts.map +1 -1
  76. package/dist/src/mcp-tools/hooks-intelligence.js +1 -0
  77. package/dist/src/mcp-tools/hooks-intelligence.js.map +1 -1
  78. package/dist/src/mcp-tools/hooks-routing.js +23 -23
  79. package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
  80. package/dist/src/mcp-tools/index.d.ts +0 -1
  81. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  82. package/dist/src/mcp-tools/index.js +0 -2
  83. package/dist/src/mcp-tools/index.js.map +1 -1
  84. package/dist/src/mcp-tools/memory-tools.d.ts +22 -6
  85. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  86. package/dist/src/mcp-tools/memory-tools.js +553 -505
  87. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  88. package/dist/src/mcp-tools/progress-tools.js +1 -1
  89. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  90. package/dist/src/mcp-tools/system-tools.js +5 -5
  91. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  92. package/dist/src/mcp-tools/transfer-tools.d.ts +1 -1
  93. package/dist/src/mcp-tools/transfer-tools.d.ts.map +1 -1
  94. package/dist/src/mcp-tools/transfer-tools.js +1 -156
  95. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  96. package/dist/src/memory/embedding-operations.js +3 -3
  97. package/dist/src/memory/embedding-operations.js.map +1 -1
  98. package/dist/src/memory/hnsw-operations.js +5 -5
  99. package/dist/src/memory/hnsw-operations.js.map +1 -1
  100. package/dist/src/memory/intelligence.js +2 -2
  101. package/dist/src/memory/intelligence.js.map +1 -1
  102. package/dist/src/memory/memory-bridge.d.ts +86 -234
  103. package/dist/src/memory/memory-bridge.d.ts.map +1 -1
  104. package/dist/src/memory/memory-bridge.js +455 -1702
  105. package/dist/src/memory/memory-bridge.js.map +1 -1
  106. package/dist/src/memory/memory-crud.js +3 -3
  107. package/dist/src/memory/memory-crud.js.map +1 -1
  108. package/dist/src/memory/memory-initializer.d.ts +1 -1
  109. package/dist/src/memory/memory-initializer.js +5 -5
  110. package/dist/src/memory/memory-initializer.js.map +1 -1
  111. package/dist/src/memory/memory-read.js +4 -4
  112. package/dist/src/memory/memory-read.js.map +1 -1
  113. package/dist/src/suggest.js +0 -1
  114. package/dist/src/suggest.js.map +1 -1
  115. package/dist/src/types.d.ts +1 -1
  116. package/dist/src/ui/dashboard.html +41 -5
  117. package/dist/src/ui/orgs.html +91 -5
  118. package/dist/src/ui/server.mjs +44 -0
  119. package/dist/src/update/validator.d.ts.map +1 -1
  120. package/dist/src/update/validator.js +1 -3
  121. package/dist/src/update/validator.js.map +1 -1
  122. package/dist/tsconfig.tsbuildinfo +1 -1
  123. package/package.json +4 -4
  124. package/dist/src/commands/plugins.d.ts +0 -11
  125. package/dist/src/commands/plugins.d.ts.map +0 -1
  126. package/dist/src/commands/plugins.js +0 -799
  127. package/dist/src/commands/plugins.js.map +0 -1
  128. package/dist/src/plugins/manager.d.ts +0 -133
  129. package/dist/src/plugins/manager.d.ts.map +0 -1
  130. package/dist/src/plugins/manager.js +0 -498
  131. package/dist/src/plugins/manager.js.map +0 -1
  132. package/dist/src/plugins/store/discovery.d.ts +0 -88
  133. package/dist/src/plugins/store/discovery.d.ts.map +0 -1
  134. package/dist/src/plugins/store/discovery.js +0 -650
  135. package/dist/src/plugins/store/discovery.js.map +0 -1
  136. package/dist/src/plugins/store/index.d.ts +0 -76
  137. package/dist/src/plugins/store/index.d.ts.map +0 -1
  138. package/dist/src/plugins/store/index.js +0 -141
  139. package/dist/src/plugins/store/index.js.map +0 -1
  140. package/dist/src/plugins/store/search.d.ts +0 -46
  141. package/dist/src/plugins/store/search.d.ts.map +0 -1
  142. package/dist/src/plugins/store/search.js +0 -231
  143. package/dist/src/plugins/store/search.js.map +0 -1
  144. package/dist/src/plugins/store/types.d.ts +0 -274
  145. package/dist/src/plugins/store/types.d.ts.map +0 -1
  146. package/dist/src/plugins/store/types.js +0 -7
  147. package/dist/src/plugins/store/types.js.map +0 -1
  148. package/dist/src/plugins/tests/demo-plugin-store.d.ts +0 -7
  149. package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +0 -1
  150. package/dist/src/plugins/tests/demo-plugin-store.js +0 -126
  151. package/dist/src/plugins/tests/demo-plugin-store.js.map +0 -1
  152. package/dist/src/plugins/tests/standalone-test.d.ts +0 -12
  153. package/dist/src/plugins/tests/standalone-test.d.ts.map +0 -1
  154. package/dist/src/plugins/tests/standalone-test.js +0 -188
  155. package/dist/src/plugins/tests/standalone-test.js.map +0 -1
  156. package/dist/src/plugins/tests/test-plugin-store.d.ts +0 -7
  157. package/dist/src/plugins/tests/test-plugin-store.d.ts.map +0 -1
  158. package/dist/src/plugins/tests/test-plugin-store.js +0 -206
  159. package/dist/src/plugins/tests/test-plugin-store.js.map +0 -1
  160. package/dist/src/services/registry-api.d.ts +0 -58
  161. package/dist/src/services/registry-api.d.ts.map +0 -1
  162. package/dist/src/services/registry-api.js +0 -199
  163. package/dist/src/services/registry-api.js.map +0 -1
  164. package/scripts/publish-registry.ts +0 -339
@@ -1,799 +0,0 @@
1
- /**
2
- * CLI Plugins Command
3
- * Plugin management, installation, and lifecycle
4
- * Now uses IPFS-based decentralized registry for discovery
5
- *
6
- * github.com/monoes/monomind
7
- */
8
- import { output } from '../output.js';
9
- import { createPluginDiscoveryService, searchPlugins, getPluginSearchSuggestions, getFeaturedPlugins, getOfficialPlugins, } from '../plugins/store/index.js';
10
- import { getPluginManager } from '../plugins/manager.js';
11
- import { getBulkRatings } from '../services/registry-api.js';
12
- // List subcommand - Now uses IPFS-based registry
13
- const listCommand = {
14
- name: 'list',
15
- description: 'List installed and available plugins from IPFS registry',
16
- options: [
17
- { name: 'installed', short: 'i', type: 'boolean', description: 'Show only installed plugins' },
18
- { name: 'available', short: 'a', type: 'boolean', description: 'Show available plugins from registry' },
19
- { name: 'category', short: 'c', type: 'string', description: 'Filter by category' },
20
- { name: 'type', short: 't', type: 'string', description: 'Filter by plugin type' },
21
- { name: 'official', short: 'o', type: 'boolean', description: 'Show only official plugins' },
22
- { name: 'featured', short: 'f', type: 'boolean', description: 'Show featured plugins' },
23
- { name: 'registry', short: 'r', type: 'string', description: 'Registry to use (default: monomind-official)' },
24
- ],
25
- examples: [
26
- { command: 'monomind plugins list', description: 'List all plugins from registry' },
27
- { command: 'monomind plugins list --installed', description: 'List installed only' },
28
- { command: 'monomind plugins list --official', description: 'List official plugins' },
29
- { command: 'monomind plugins list --category security', description: 'List security plugins' },
30
- ],
31
- action: async (ctx) => {
32
- const installedOnly = ctx.flags.installed;
33
- const category = ctx.flags.category;
34
- const type = ctx.flags.type;
35
- const official = ctx.flags.official;
36
- const featured = ctx.flags.featured;
37
- const registryName = ctx.flags.registry;
38
- // For installed-only, read from local manifest
39
- if (installedOnly) {
40
- output.writeln();
41
- output.writeln(output.bold('Installed Plugins'));
42
- output.writeln(output.dim('─'.repeat(60)));
43
- try {
44
- const manager = getPluginManager();
45
- await manager.initialize();
46
- const installed = await manager.getInstalled();
47
- if (installed.length === 0) {
48
- output.writeln(output.dim('No plugins installed.'));
49
- output.writeln();
50
- output.writeln(output.dim('Run "monomind plugins list" to see available plugins'));
51
- output.writeln(output.dim('Run "monomind plugins install -n <plugin>" to install'));
52
- return { success: true };
53
- }
54
- output.printTable({
55
- columns: [
56
- { key: 'name', header: 'Plugin', width: 38 },
57
- { key: 'version', header: 'Version', width: 14 },
58
- { key: 'source', header: 'Source', width: 10 },
59
- { key: 'status', header: 'Status', width: 10 },
60
- ],
61
- data: installed.map((p) => ({
62
- name: p.name,
63
- version: p.version,
64
- source: p.source,
65
- status: p.enabled ? output.success('Enabled') : output.dim('Disabled'),
66
- })),
67
- });
68
- output.writeln();
69
- output.writeln(output.dim(`Plugins directory: ${manager.getPluginsDir()}`));
70
- return { success: true, data: installed };
71
- }
72
- catch (error) {
73
- output.printError(`Failed to load installed plugins: ${String(error)}`);
74
- return { success: false, exitCode: 1 };
75
- }
76
- }
77
- // Discover registry via IPFS
78
- const spinner = output.createSpinner({ text: 'Discovering plugin registry via IPNS...', spinner: 'dots' });
79
- spinner.start();
80
- try {
81
- const discovery = createPluginDiscoveryService();
82
- const result = await discovery.discoverRegistry(registryName);
83
- if (!result.success || !result.registry) {
84
- spinner.fail('Failed to discover registry');
85
- output.printError(result.error || 'Unknown error');
86
- return { success: false, exitCode: 1 };
87
- }
88
- spinner.succeed(`Registry discovered: ${result.registry.totalPlugins} plugins available`);
89
- output.writeln();
90
- // Build search options
91
- const searchOptions = {
92
- category,
93
- type: type,
94
- sortBy: 'downloads',
95
- sortOrder: 'desc',
96
- };
97
- let plugins;
98
- let title;
99
- if (official) {
100
- plugins = getOfficialPlugins(result.registry);
101
- title = 'Official Plugins';
102
- }
103
- else if (featured) {
104
- plugins = getFeaturedPlugins(result.registry);
105
- title = 'Featured Plugins';
106
- }
107
- else {
108
- const searchResult = searchPlugins(result.registry, searchOptions);
109
- plugins = searchResult.plugins;
110
- title = category ? `${category} Plugins` : 'Available Plugins';
111
- }
112
- output.writeln(output.bold(title));
113
- output.writeln(output.dim('─'.repeat(70)));
114
- // Fetch real ratings from Cloud Function (non-blocking)
115
- let realRatings = {};
116
- try {
117
- const pluginIds = plugins.map(p => p.name);
118
- realRatings = await getBulkRatings(pluginIds, 'plugin');
119
- }
120
- catch {
121
- // Fall back to static ratings if Cloud Function unavailable
122
- }
123
- if (ctx.flags.format === 'json') {
124
- // Merge real ratings into plugin data
125
- const pluginsWithRatings = plugins.map(p => ({
126
- ...p,
127
- rating: realRatings[p.name]?.average || p.rating,
128
- ratingCount: realRatings[p.name]?.count || 0,
129
- }));
130
- output.printJson(pluginsWithRatings);
131
- return { success: true, data: pluginsWithRatings };
132
- }
133
- output.printTable({
134
- columns: [
135
- { key: 'name', header: 'Plugin', width: 38 },
136
- { key: 'version', header: 'Version', width: 14 },
137
- { key: 'type', header: 'Type', width: 12 },
138
- { key: 'downloads', header: 'Downloads', width: 10, align: 'right' },
139
- { key: 'rating', header: 'Rating', width: 10, align: 'right' },
140
- { key: 'trust', header: 'Trust', width: 10 },
141
- ],
142
- data: plugins.map(p => {
143
- const liveRating = realRatings[p.name];
144
- const ratingDisplay = liveRating && liveRating.count > 0
145
- ? `${liveRating.average.toFixed(1)}★(${liveRating.count})`
146
- : `${p.rating.toFixed(1)}★`;
147
- return {
148
- name: p.name,
149
- version: p.version,
150
- type: p.type,
151
- downloads: p.downloads.toLocaleString(),
152
- rating: ratingDisplay,
153
- trust: p.trustLevel === 'official' ? output.success('Official') :
154
- p.trustLevel === 'verified' ? output.highlight('Verified') :
155
- p.verified ? output.dim('Community') : output.dim('Unverified'),
156
- };
157
- }),
158
- });
159
- output.writeln();
160
- output.writeln(output.dim(`Source: ${result.source}${result.fromCache ? ' (cached)' : ''}`));
161
- if (result.cid) {
162
- output.writeln(output.dim(`Registry CID: ${result.cid.slice(0, 30)}...`));
163
- }
164
- return { success: true, data: plugins };
165
- }
166
- catch (error) {
167
- spinner.fail('Failed to fetch registry');
168
- output.printError(`Error: ${String(error)}`);
169
- return { success: false, exitCode: 1 };
170
- }
171
- },
172
- };
173
- // Install subcommand - Now fetches from IPFS registry
174
- const installCommand = {
175
- name: 'install',
176
- description: 'Install a plugin from IPFS registry or local path',
177
- options: [
178
- { name: 'name', short: 'n', type: 'string', description: 'Plugin name or path', required: true },
179
- { name: 'version', short: 'v', type: 'string', description: 'Specific version to install' },
180
- { name: 'global', short: 'g', type: 'boolean', description: 'Install globally' },
181
- { name: 'dev', short: 'd', type: 'boolean', description: 'Install as dev dependency' },
182
- { name: 'verify', type: 'boolean', description: 'Verify checksum (default: true)', default: true },
183
- { name: 'registry', short: 'r', type: 'string', description: 'Registry to use' },
184
- ],
185
- examples: [
186
- { command: 'monomind plugins install -n community-analytics', description: 'Install plugin from IPFS' },
187
- { command: 'monomind plugins install -n ./my-plugin --dev', description: 'Install local plugin' },
188
- ],
189
- action: async (ctx) => {
190
- const rawName = ctx.flags.name;
191
- const version = ctx.flags.version || 'latest';
192
- const registryName = ctx.flags.registry;
193
- const verify = ctx.flags.verify !== false;
194
- if (!rawName) {
195
- output.printError('Plugin name is required');
196
- return { success: false, exitCode: 1 };
197
- }
198
- // Cap plugin name and version to prevent DoS/injection
199
- const name = typeof rawName === 'string' ? rawName.slice(0, 214) : '';
200
- // Check if it's a local path
201
- const isLocalPath = name.startsWith('./') || name.startsWith('/') || name.startsWith('../');
202
- output.writeln();
203
- output.writeln(output.bold('Installing Plugin'));
204
- output.writeln(output.dim('─'.repeat(50)));
205
- const spinner = output.createSpinner({
206
- text: isLocalPath ? `Installing from ${name}...` : `Discovering ${name} in registry...`,
207
- spinner: 'dots'
208
- });
209
- spinner.start();
210
- try {
211
- const manager = getPluginManager();
212
- await manager.initialize();
213
- // Check if already installed
214
- const existingPlugin = await manager.getPlugin(name);
215
- if (existingPlugin) {
216
- spinner.fail(`Plugin ${name} is already installed (v${existingPlugin.version})`);
217
- output.writeln();
218
- output.writeln(output.dim('Use "monomind plugins upgrade -n ' + name + '" to update'));
219
- return { success: false, exitCode: 1 };
220
- }
221
- let result;
222
- let plugin;
223
- if (isLocalPath) {
224
- // Install from local path
225
- spinner.setText(`Installing from ${name}...`);
226
- result = await manager.installFromLocal(name);
227
- }
228
- else {
229
- // First, try to find in registry for metadata
230
- spinner.setText(`Discovering ${name} in registry...`);
231
- const discovery = createPluginDiscoveryService();
232
- const registryResult = await discovery.discoverRegistry(registryName);
233
- if (registryResult.success && registryResult.registry) {
234
- plugin = registryResult.registry.plugins.find(p => p.name === name || p.id === name);
235
- }
236
- if (plugin) {
237
- spinner.setText(`Found ${plugin.displayName} v${plugin.version}`);
238
- }
239
- // Install from npm (since IPFS is demo mode)
240
- spinner.setText(`Installing ${name} from npm...`);
241
- result = await manager.installFromNpm(name, version !== 'latest' ? version : undefined);
242
- }
243
- if (!result.success) {
244
- spinner.fail(`Installation failed: ${result.error}`);
245
- return { success: false, exitCode: 1 };
246
- }
247
- const installed = result.plugin;
248
- spinner.succeed(`Installed ${installed.name}@${installed.version}`);
249
- output.writeln();
250
- const boxContent = [
251
- `Plugin: ${installed.name}`,
252
- `Version: ${installed.version}`,
253
- `Source: ${installed.source}`,
254
- `Path: ${installed.path || 'N/A'}`,
255
- ``,
256
- `Hooks registered: ${installed.hooks?.length || 0}`,
257
- `Commands added: ${installed.commands?.length || 0}`,
258
- ];
259
- if (plugin) {
260
- boxContent.push(`Trust: ${plugin.trustLevel}`);
261
- boxContent.push(`Permissions: ${plugin.permissions.join(', ') || 'none'}`);
262
- }
263
- output.printBox(boxContent.join('\n'), 'Installation Complete');
264
- return { success: true, data: installed };
265
- }
266
- catch (error) {
267
- spinner.fail('Installation failed');
268
- output.printError(`Error: ${String(error)}`);
269
- return { success: false, exitCode: 1 };
270
- }
271
- },
272
- };
273
- // Uninstall subcommand
274
- const uninstallCommand = {
275
- name: 'uninstall',
276
- description: 'Uninstall a plugin',
277
- options: [
278
- { name: 'name', short: 'n', type: 'string', description: 'Plugin name', required: true },
279
- { name: 'force', short: 'f', type: 'boolean', description: 'Force uninstall without confirmation' },
280
- ],
281
- examples: [
282
- { command: 'monomind plugins uninstall -n community-analytics', description: 'Uninstall plugin' },
283
- ],
284
- action: async (ctx) => {
285
- const name = ctx.flags.name;
286
- if (!name) {
287
- output.printError('Plugin name is required');
288
- return { success: false, exitCode: 1 };
289
- }
290
- output.writeln();
291
- const spinner = output.createSpinner({ text: `Uninstalling ${name}...`, spinner: 'dots' });
292
- spinner.start();
293
- try {
294
- const manager = getPluginManager();
295
- await manager.initialize();
296
- // Check if installed
297
- const plugin = await manager.getPlugin(name);
298
- if (!plugin) {
299
- spinner.fail(`Plugin ${name} is not installed`);
300
- return { success: false, exitCode: 1 };
301
- }
302
- // Uninstall
303
- const result = await manager.uninstall(name);
304
- if (!result.success) {
305
- spinner.fail(`Failed to uninstall: ${result.error}`);
306
- return { success: false, exitCode: 1 };
307
- }
308
- spinner.succeed(`Uninstalled ${name}`);
309
- output.writeln();
310
- output.writeln(output.dim(`Removed ${plugin.version} from ${manager.getPluginsDir()}`));
311
- return { success: true };
312
- }
313
- catch (error) {
314
- spinner.fail('Uninstall failed');
315
- output.printError(`Error: ${String(error)}`);
316
- return { success: false, exitCode: 1 };
317
- }
318
- },
319
- };
320
- // Enable/Disable subcommand
321
- const toggleCommand = {
322
- name: 'toggle',
323
- description: 'Enable or disable a plugin',
324
- options: [
325
- { name: 'name', short: 'n', type: 'string', description: 'Plugin name', required: true },
326
- { name: 'enable', short: 'e', type: 'boolean', description: 'Enable the plugin' },
327
- { name: 'disable', short: 'd', type: 'boolean', description: 'Disable the plugin' },
328
- ],
329
- examples: [
330
- { command: 'monomind plugins toggle -n analytics --enable', description: 'Enable plugin' },
331
- { command: 'monomind plugins toggle -n analytics --disable', description: 'Disable plugin' },
332
- ],
333
- action: async (ctx) => {
334
- const name = ctx.flags.name;
335
- const enable = ctx.flags.enable;
336
- const disable = ctx.flags.disable;
337
- if (!name) {
338
- output.printError('Plugin name is required');
339
- return { success: false, exitCode: 1 };
340
- }
341
- try {
342
- const manager = getPluginManager();
343
- await manager.initialize();
344
- // Check if installed
345
- const plugin = await manager.getPlugin(name);
346
- if (!plugin) {
347
- output.printError(`Plugin ${name} is not installed`);
348
- return { success: false, exitCode: 1 };
349
- }
350
- let result;
351
- let action;
352
- let newState;
353
- if (enable) {
354
- result = await manager.enable(name);
355
- action = 'Enabled';
356
- newState = true;
357
- }
358
- else if (disable) {
359
- result = await manager.disable(name);
360
- action = 'Disabled';
361
- newState = false;
362
- }
363
- else {
364
- // Toggle
365
- result = await manager.toggle(name);
366
- newState = result.enabled ?? !plugin.enabled;
367
- action = newState ? 'Enabled' : 'Disabled';
368
- }
369
- if (!result.success) {
370
- output.printError(`Failed to toggle: ${result.error}`);
371
- return { success: false, exitCode: 1 };
372
- }
373
- output.writeln();
374
- output.writeln(output.success(`${action} ${name}`));
375
- output.writeln(output.dim(`Plugin is now ${newState ? 'enabled' : 'disabled'}`));
376
- return { success: true, data: { enabled: newState } };
377
- }
378
- catch (error) {
379
- output.printError(`Error: ${String(error)}`);
380
- return { success: false, exitCode: 1 };
381
- }
382
- },
383
- };
384
- // Info subcommand - Now fetches from IPFS registry
385
- const infoCommand = {
386
- name: 'info',
387
- description: 'Show detailed plugin information from IPFS registry',
388
- options: [
389
- { name: 'name', short: 'n', type: 'string', description: 'Plugin name', required: true },
390
- { name: 'registry', short: 'r', type: 'string', description: 'Registry to use' },
391
- ],
392
- examples: [
393
- { command: 'monomind plugins info -n @monomind/security', description: 'Show plugin info' },
394
- ],
395
- action: async (ctx) => {
396
- const name = ctx.flags.name;
397
- const registryName = ctx.flags.registry;
398
- if (!name) {
399
- output.printError('Plugin name is required');
400
- return { success: false, exitCode: 1 };
401
- }
402
- const spinner = output.createSpinner({ text: 'Fetching plugin details...', spinner: 'dots' });
403
- spinner.start();
404
- try {
405
- // Discover registry and find plugin
406
- const discovery = createPluginDiscoveryService();
407
- const result = await discovery.discoverRegistry(registryName);
408
- if (!result.success || !result.registry) {
409
- spinner.fail('Failed to discover registry');
410
- return { success: false, exitCode: 1 };
411
- }
412
- const plugin = result.registry.plugins.find(p => p.name === name || p.id === name);
413
- if (!plugin) {
414
- spinner.fail(`Plugin not found: ${name}`);
415
- return { success: false, exitCode: 1 };
416
- }
417
- spinner.succeed(`Found ${plugin.displayName}`);
418
- output.writeln();
419
- output.writeln(output.bold(`Plugin: ${plugin.displayName}`));
420
- output.writeln(output.dim('─'.repeat(60)));
421
- if (ctx.flags.format === 'json') {
422
- output.printJson(plugin);
423
- return { success: true, data: plugin };
424
- }
425
- // Basic info
426
- output.writeln(output.bold('Basic Information'));
427
- output.printTable({
428
- columns: [
429
- { key: 'field', header: 'Field', width: 15 },
430
- { key: 'value', header: 'Value', width: 45 },
431
- ],
432
- data: [
433
- { field: 'Name', value: plugin.name },
434
- { field: 'Display Name', value: plugin.displayName },
435
- { field: 'Version', value: plugin.version },
436
- { field: 'Type', value: plugin.type },
437
- { field: 'License', value: plugin.license },
438
- { field: 'Author', value: plugin.author.displayName || plugin.author.id },
439
- { field: 'Trust Level', value: plugin.trustLevel },
440
- { field: 'Verified', value: plugin.verified ? '✓ Yes' : '✗ No' },
441
- ],
442
- });
443
- output.writeln();
444
- output.writeln(output.bold('Description'));
445
- output.writeln(plugin.description);
446
- // Storage info
447
- output.writeln();
448
- output.writeln(output.bold('Storage'));
449
- output.printTable({
450
- columns: [
451
- { key: 'field', header: 'Field', width: 15 },
452
- { key: 'value', header: 'Value', width: 45 },
453
- ],
454
- data: [
455
- { field: 'CID', value: plugin.cid },
456
- { field: 'Size', value: `${(plugin.size / 1024).toFixed(1)} KB` },
457
- { field: 'Checksum', value: plugin.checksum },
458
- ],
459
- });
460
- // Stats
461
- output.writeln();
462
- output.writeln(output.bold('Statistics'));
463
- output.printTable({
464
- columns: [
465
- { key: 'field', header: 'Field', width: 15 },
466
- { key: 'value', header: 'Value', width: 45 },
467
- ],
468
- data: [
469
- { field: 'Downloads', value: plugin.downloads.toLocaleString() },
470
- { field: 'Rating', value: `${plugin.rating.toFixed(1)}★ (${plugin.ratingCount} ratings)` },
471
- { field: 'Created', value: plugin.createdAt },
472
- { field: 'Updated', value: plugin.lastUpdated },
473
- ],
474
- });
475
- // Hooks and commands
476
- if (plugin.hooks.length > 0) {
477
- output.writeln();
478
- output.writeln(output.bold('Hooks'));
479
- output.printList(plugin.hooks.map(h => output.highlight(h)));
480
- }
481
- if (plugin.commands.length > 0) {
482
- output.writeln();
483
- output.writeln(output.bold('Commands'));
484
- output.printList(plugin.commands.map(c => output.highlight(c)));
485
- }
486
- // Permissions
487
- if (plugin.permissions.length > 0) {
488
- output.writeln();
489
- output.writeln(output.bold('Required Permissions'));
490
- output.printList(plugin.permissions.map(p => {
491
- const icon = ['privileged', 'credentials', 'execute'].includes(p) ? '⚠️ ' : '';
492
- return `${icon}${p}`;
493
- }));
494
- }
495
- // Dependencies
496
- if (plugin.dependencies.length > 0) {
497
- output.writeln();
498
- output.writeln(output.bold('Dependencies'));
499
- output.printList(plugin.dependencies.map(d => `${d.name}@${d.version}${d.optional ? ' (optional)' : ''}`));
500
- }
501
- // Security audit
502
- if (plugin.securityAudit) {
503
- output.writeln();
504
- output.writeln(output.bold('Security Audit'));
505
- output.printTable({
506
- columns: [
507
- { key: 'field', header: 'Field', width: 15 },
508
- { key: 'value', header: 'Value', width: 45 },
509
- ],
510
- data: [
511
- { field: 'Auditor', value: plugin.securityAudit.auditor },
512
- { field: 'Date', value: plugin.securityAudit.auditDate },
513
- { field: 'Passed', value: plugin.securityAudit.passed ? '✓ Yes' : '✗ No' },
514
- { field: 'Issues', value: String(plugin.securityAudit.issues.length) },
515
- ],
516
- });
517
- }
518
- // Tags
519
- output.writeln();
520
- output.writeln(output.bold('Tags'));
521
- output.writeln(plugin.tags.map(t => output.dim(`#${t}`)).join(' '));
522
- return { success: true, data: plugin };
523
- }
524
- catch (error) {
525
- spinner.fail('Failed to fetch plugin info');
526
- output.printError(`Error: ${String(error)}`);
527
- return { success: false, exitCode: 1 };
528
- }
529
- },
530
- };
531
- // Create subcommand
532
- const createCommand = {
533
- name: 'create',
534
- description: 'Scaffold a new plugin project',
535
- options: [
536
- { name: 'name', short: 'n', type: 'string', description: 'Plugin name', required: true },
537
- { name: 'template', short: 't', type: 'string', description: 'Template: basic, advanced, hooks', default: 'basic' },
538
- { name: 'path', short: 'p', type: 'string', description: 'Output path', default: '.' },
539
- ],
540
- examples: [
541
- { command: 'monomind plugins create -n my-plugin', description: 'Create basic plugin' },
542
- { command: 'monomind plugins create -n my-plugin -t hooks', description: 'Create hooks plugin' },
543
- ],
544
- action: async (ctx) => {
545
- const name = ctx.flags.name;
546
- const template = ctx.flags.template || 'basic';
547
- if (!name) {
548
- output.printError('Plugin name is required');
549
- return { success: false, exitCode: 1 };
550
- }
551
- output.writeln();
552
- output.writeln(output.bold('Creating Plugin'));
553
- output.writeln(output.dim('─'.repeat(40)));
554
- output.printWarning('Plugin scaffolding is not yet implemented.');
555
- output.writeln(output.dim('Use --name to specify your plugin name. File generation coming soon.'));
556
- return { success: false, message: 'Not yet implemented', exitCode: 1 };
557
- },
558
- };
559
- // Upgrade subcommand
560
- const upgradeCommand = {
561
- name: 'upgrade',
562
- description: 'Upgrade an installed plugin to a newer version',
563
- options: [
564
- { name: 'name', short: 'n', type: 'string', description: 'Plugin name', required: true },
565
- { name: 'version', short: 'v', type: 'string', description: 'Target version (default: latest)' },
566
- ],
567
- examples: [
568
- { command: 'monomind plugins upgrade -n @monomind/security', description: 'Upgrade to latest' },
569
- { command: 'monomind plugins upgrade -n @monomind/security -v 3.1.0', description: 'Upgrade to specific version' },
570
- ],
571
- action: async (ctx) => {
572
- const name = ctx.flags.name;
573
- const version = ctx.flags.version;
574
- if (!name) {
575
- output.printError('Plugin name is required');
576
- return { success: false, exitCode: 1 };
577
- }
578
- output.writeln();
579
- const spinner = output.createSpinner({ text: `Upgrading ${name}...`, spinner: 'dots' });
580
- spinner.start();
581
- try {
582
- const manager = getPluginManager();
583
- await manager.initialize();
584
- // Check if installed
585
- const existing = await manager.getPlugin(name);
586
- if (!existing) {
587
- spinner.fail(`Plugin ${name} is not installed`);
588
- return { success: false, exitCode: 1 };
589
- }
590
- const oldVersion = existing.version;
591
- spinner.setText(`Upgrading ${name} from v${oldVersion}...`);
592
- const result = await manager.upgrade(name, version);
593
- if (!result.success) {
594
- spinner.fail(`Upgrade failed: ${result.error}`);
595
- return { success: false, exitCode: 1 };
596
- }
597
- const plugin = result.plugin;
598
- spinner.succeed(`Upgraded ${name}: v${oldVersion} -> v${plugin.version}`);
599
- return { success: true, data: plugin };
600
- }
601
- catch (error) {
602
- spinner.fail('Upgrade failed');
603
- output.printError(`Error: ${String(error)}`);
604
- return { success: false, exitCode: 1 };
605
- }
606
- },
607
- };
608
- // Search subcommand - Search IPFS registry
609
- const searchCommand = {
610
- name: 'search',
611
- description: 'Search plugins in the IPFS registry',
612
- options: [
613
- { name: 'query', short: 'q', type: 'string', description: 'Search query', required: true },
614
- { name: 'category', short: 'c', type: 'string', description: 'Filter by category' },
615
- { name: 'type', short: 't', type: 'string', description: 'Filter by plugin type' },
616
- { name: 'verified', short: 'v', type: 'boolean', description: 'Show only verified plugins' },
617
- { name: 'limit', short: 'l', type: 'number', description: 'Maximum results', default: 20 },
618
- { name: 'registry', short: 'r', type: 'string', description: 'Registry to use' },
619
- ],
620
- examples: [
621
- { command: 'monomind plugins search -q neural', description: 'Search for neural plugins' },
622
- { command: 'monomind plugins search -q security --verified', description: 'Search verified security plugins' },
623
- ],
624
- action: async (ctx) => {
625
- const rawQuery = ctx.flags.query;
626
- const category = ctx.flags.category;
627
- const type = ctx.flags.type;
628
- const verified = ctx.flags.verified;
629
- const rawLimit = ctx.flags.limit;
630
- const registryName = ctx.flags.registry;
631
- if (!rawQuery) {
632
- output.printError('Search query is required');
633
- return { success: false, exitCode: 1 };
634
- }
635
- // Cap query length and limit to prevent DoS
636
- const query = typeof rawQuery === 'string' ? rawQuery.slice(0, 200) : '';
637
- const limit = typeof rawLimit === 'number' && Number.isFinite(rawLimit)
638
- ? Math.max(1, Math.min(Math.floor(rawLimit), 100))
639
- : 20;
640
- const spinner = output.createSpinner({ text: 'Searching plugin registry...', spinner: 'dots' });
641
- spinner.start();
642
- try {
643
- const discovery = createPluginDiscoveryService();
644
- const result = await discovery.discoverRegistry(registryName);
645
- if (!result.success || !result.registry) {
646
- spinner.fail('Failed to discover registry');
647
- return { success: false, exitCode: 1 };
648
- }
649
- const searchOptions = {
650
- query,
651
- category,
652
- type: type,
653
- verified,
654
- limit,
655
- sortBy: 'downloads',
656
- sortOrder: 'desc',
657
- };
658
- const searchResult = searchPlugins(result.registry, searchOptions);
659
- spinner.succeed(`Found ${searchResult.total} plugins matching "${query}"`);
660
- output.writeln();
661
- output.writeln(output.bold(`Search Results: "${query}"`));
662
- output.writeln(output.dim('─'.repeat(70)));
663
- if (searchResult.plugins.length === 0) {
664
- output.writeln(output.dim('No plugins found matching your query'));
665
- output.writeln();
666
- output.writeln('Suggestions:');
667
- const suggestions = getPluginSearchSuggestions(result.registry, query.slice(0, 3));
668
- if (suggestions.length > 0) {
669
- output.printList(suggestions.slice(0, 5));
670
- }
671
- else {
672
- output.writeln(output.dim(' Try a different search term'));
673
- }
674
- return { success: true, data: searchResult };
675
- }
676
- if (ctx.flags.format === 'json') {
677
- output.printJson(searchResult);
678
- return { success: true, data: searchResult };
679
- }
680
- output.printTable({
681
- columns: [
682
- { key: 'name', header: 'Plugin', width: 38 },
683
- { key: 'description', header: 'Description', width: 40 },
684
- { key: 'downloads', header: 'Downloads', width: 10, align: 'right' },
685
- ],
686
- data: searchResult.plugins.map(p => ({
687
- name: p.verified ? `✓ ${p.name}` : p.name,
688
- description: p.description.slice(0, 33) + (p.description.length > 33 ? '...' : ''),
689
- downloads: p.downloads.toLocaleString(),
690
- })),
691
- });
692
- output.writeln();
693
- output.writeln(output.dim(`Showing ${searchResult.plugins.length} of ${searchResult.total} results`));
694
- if (searchResult.hasMore) {
695
- output.writeln(output.dim(`Use --limit to see more results`));
696
- }
697
- return { success: true, data: searchResult };
698
- }
699
- catch (error) {
700
- spinner.fail('Search failed');
701
- output.printError(`Error: ${String(error)}`);
702
- return { success: false, exitCode: 1 };
703
- }
704
- },
705
- };
706
- // Rate subcommand - Rate plugins via Cloud Function
707
- const rateCommand = {
708
- name: 'rate',
709
- description: 'Rate a plugin (1-5 stars)',
710
- options: [
711
- { name: 'name', short: 'n', type: 'string', description: 'Plugin name to rate', required: true },
712
- { name: 'rating', short: 'r', type: 'number', description: 'Rating (1-5)', required: true },
713
- ],
714
- examples: [
715
- { command: 'monomind plugins rate -n my-plugin -r 5', description: 'Rate 5 stars' },
716
- { command: 'monomind plugins rate -n my-plugin -r 4', description: 'Rate 4 stars' },
717
- ],
718
- action: async (ctx) => {
719
- const { rateItem } = await import('../services/registry-api.js');
720
- const name = ctx.flags.name;
721
- const rating = parseInt(ctx.flags.rating, 10);
722
- if (!name) {
723
- output.printError('Plugin name is required');
724
- return { success: false, exitCode: 1 };
725
- }
726
- if (!rating || rating < 1 || rating > 5) {
727
- output.printError('Rating must be 1-5');
728
- return { success: false, exitCode: 1 };
729
- }
730
- const spinner = output.createSpinner({ text: 'Submitting rating...', spinner: 'dots' });
731
- spinner.start();
732
- try {
733
- const result = await rateItem(name, rating, 'plugin');
734
- spinner.succeed('Rating submitted');
735
- output.writeln();
736
- output.writeln(`Plugin: ${output.highlight(name)}`);
737
- output.writeln(`Your rating: ${'★'.repeat(rating)}${'☆'.repeat(5 - rating)}`);
738
- output.writeln(`New average: ${result.average.toFixed(1)}★ (${result.count} ratings)`);
739
- output.writeln();
740
- output.writeln(output.dim('Thank you for your feedback!'));
741
- return { success: true, data: result };
742
- }
743
- catch (error) {
744
- spinner.fail('Failed to submit rating');
745
- output.printError(String(error));
746
- return { success: false, exitCode: 1 };
747
- }
748
- },
749
- };
750
- // Main plugins command - Now with IPFS-based registry
751
- export const pluginsCommand = {
752
- name: 'plugins',
753
- description: 'Plugin management with IPFS-based decentralized registry',
754
- subcommands: [listCommand, searchCommand, installCommand, uninstallCommand, upgradeCommand, toggleCommand, infoCommand, createCommand, rateCommand],
755
- examples: [
756
- { command: 'monomind plugins list', description: 'List plugins from IPFS registry' },
757
- { command: 'monomind plugins search -q neural', description: 'Search for plugins' },
758
- { command: 'monomind plugins install -n community-analytics', description: 'Install from IPFS' },
759
- { command: 'monomind plugins create -n my-plugin', description: 'Create new plugin' },
760
- ],
761
- action: async () => {
762
- output.writeln();
763
- output.writeln(output.bold('MonoMind Plugin System'));
764
- output.writeln(output.dim('Decentralized plugin marketplace via IPFS'));
765
- output.writeln();
766
- output.writeln('Subcommands:');
767
- output.printList([
768
- `${output.highlight('list')} - List plugins from IPFS registry`,
769
- `${output.highlight('search')} - Search plugins by query`,
770
- `${output.highlight('install')} - Install a plugin from npm or local path`,
771
- `${output.highlight('uninstall')} - Remove an installed plugin`,
772
- `${output.highlight('upgrade')} - Upgrade an installed plugin`,
773
- `${output.highlight('toggle')} - Enable or disable a plugin`,
774
- `${output.highlight('info')} - Show detailed plugin information`,
775
- `${output.highlight('create')} - Scaffold a new plugin project`,
776
- ]);
777
- output.writeln();
778
- output.writeln(output.bold('IPFS-Based Features:'));
779
- output.printList([
780
- 'Decentralized registry via IPNS for discoverability',
781
- 'Content-addressed storage for integrity verification',
782
- 'Ed25519 signatures for plugin verification',
783
- 'Trust levels: unverified, community, verified, official',
784
- 'Security audit tracking and vulnerability reporting',
785
- ]);
786
- output.writeln();
787
- output.writeln(output.bold('Official Plugins:'));
788
- output.printList([
789
- '@monomind/security - Security scanning and CVE detection',
790
- '@monomind/claims - Claims-based authorization',
791
- ]);
792
- output.writeln();
793
- output.writeln(output.dim('Run "monomind plugins list --official" to see all official plugins'));
794
- output.writeln(output.dim('github.com/monoes/monomind'));
795
- return { success: true };
796
- },
797
- };
798
- export default pluginsCommand;
799
- //# sourceMappingURL=plugins.js.map