@sparkleideas/plugins 3.0.0-alpha.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 (80) hide show
  1. package/README.md +401 -0
  2. package/__tests__/collection-manager.test.ts +332 -0
  3. package/__tests__/dependency-graph.test.ts +434 -0
  4. package/__tests__/enhanced-plugin-registry.test.ts +488 -0
  5. package/__tests__/plugin-registry.test.ts +368 -0
  6. package/__tests__/ruvector-bridge.test.ts +2429 -0
  7. package/__tests__/ruvector-integration.test.ts +1602 -0
  8. package/__tests__/ruvector-migrations.test.ts +1099 -0
  9. package/__tests__/ruvector-quantization.test.ts +846 -0
  10. package/__tests__/ruvector-streaming.test.ts +1088 -0
  11. package/__tests__/sdk.test.ts +325 -0
  12. package/__tests__/security.test.ts +348 -0
  13. package/__tests__/utils/ruvector-test-utils.ts +860 -0
  14. package/examples/plugin-creator/index.ts +636 -0
  15. package/examples/plugin-creator/plugin-creator.test.ts +312 -0
  16. package/examples/ruvector/README.md +288 -0
  17. package/examples/ruvector/attention-patterns.ts +394 -0
  18. package/examples/ruvector/basic-usage.ts +288 -0
  19. package/examples/ruvector/docker-compose.yml +75 -0
  20. package/examples/ruvector/gnn-analysis.ts +501 -0
  21. package/examples/ruvector/hyperbolic-hierarchies.ts +557 -0
  22. package/examples/ruvector/init-db.sql +119 -0
  23. package/examples/ruvector/quantization.ts +680 -0
  24. package/examples/ruvector/self-learning.ts +447 -0
  25. package/examples/ruvector/semantic-search.ts +576 -0
  26. package/examples/ruvector/streaming-large-data.ts +507 -0
  27. package/examples/ruvector/transactions.ts +594 -0
  28. package/examples/ruvector-plugins/hook-pattern-library.ts +486 -0
  29. package/examples/ruvector-plugins/index.ts +79 -0
  30. package/examples/ruvector-plugins/intent-router.ts +354 -0
  31. package/examples/ruvector-plugins/mcp-tool-optimizer.ts +424 -0
  32. package/examples/ruvector-plugins/reasoning-bank.ts +657 -0
  33. package/examples/ruvector-plugins/ruvector-plugins.test.ts +518 -0
  34. package/examples/ruvector-plugins/semantic-code-search.ts +498 -0
  35. package/examples/ruvector-plugins/shared/index.ts +20 -0
  36. package/examples/ruvector-plugins/shared/vector-utils.ts +257 -0
  37. package/examples/ruvector-plugins/sona-learning.ts +445 -0
  38. package/package.json +97 -0
  39. package/src/collections/collection-manager.ts +661 -0
  40. package/src/collections/index.ts +56 -0
  41. package/src/collections/official/index.ts +1040 -0
  42. package/src/core/base-plugin.ts +416 -0
  43. package/src/core/plugin-interface.ts +215 -0
  44. package/src/hooks/index.ts +685 -0
  45. package/src/index.ts +378 -0
  46. package/src/integrations/agentic-flow.ts +743 -0
  47. package/src/integrations/index.ts +88 -0
  48. package/src/integrations/ruvector/ARCHITECTURE.md +1245 -0
  49. package/src/integrations/ruvector/attention-advanced.ts +1040 -0
  50. package/src/integrations/ruvector/attention-executor.ts +782 -0
  51. package/src/integrations/ruvector/attention-mechanisms.ts +757 -0
  52. package/src/integrations/ruvector/attention.ts +1063 -0
  53. package/src/integrations/ruvector/gnn.ts +3050 -0
  54. package/src/integrations/ruvector/hyperbolic.ts +1948 -0
  55. package/src/integrations/ruvector/index.ts +394 -0
  56. package/src/integrations/ruvector/migrations/001_create_extension.sql +135 -0
  57. package/src/integrations/ruvector/migrations/002_create_vector_tables.sql +259 -0
  58. package/src/integrations/ruvector/migrations/003_create_indices.sql +328 -0
  59. package/src/integrations/ruvector/migrations/004_create_functions.sql +598 -0
  60. package/src/integrations/ruvector/migrations/005_create_attention_functions.sql +654 -0
  61. package/src/integrations/ruvector/migrations/006_create_gnn_functions.sql +728 -0
  62. package/src/integrations/ruvector/migrations/007_create_hyperbolic_functions.sql +762 -0
  63. package/src/integrations/ruvector/migrations/index.ts +35 -0
  64. package/src/integrations/ruvector/migrations/migrations.ts +647 -0
  65. package/src/integrations/ruvector/quantization.ts +2036 -0
  66. package/src/integrations/ruvector/ruvector-bridge.ts +2000 -0
  67. package/src/integrations/ruvector/self-learning.ts +2376 -0
  68. package/src/integrations/ruvector/streaming.ts +1737 -0
  69. package/src/integrations/ruvector/types.ts +1945 -0
  70. package/src/providers/index.ts +643 -0
  71. package/src/registry/dependency-graph.ts +568 -0
  72. package/src/registry/enhanced-plugin-registry.ts +994 -0
  73. package/src/registry/plugin-registry.ts +604 -0
  74. package/src/sdk/index.ts +563 -0
  75. package/src/security/index.ts +594 -0
  76. package/src/types/index.ts +446 -0
  77. package/src/workers/index.ts +700 -0
  78. package/tmp.json +0 -0
  79. package/tsconfig.json +25 -0
  80. package/vitest.config.ts +23 -0
package/src/index.ts ADDED
@@ -0,0 +1,378 @@
1
+ /**
2
+ * @sparkleideas/plugins
3
+ *
4
+ * Unified Plugin SDK for Claude Flow v3
5
+ *
6
+ * This package provides a comprehensive plugin development framework including:
7
+ * - Plugin lifecycle management
8
+ * - Worker capabilities
9
+ * - Hook system
10
+ * - LLM provider integration
11
+ * - Security utilities
12
+ * - MCP tool development
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import {
17
+ * PluginBuilder,
18
+ * HookEvent,
19
+ * HookPriority,
20
+ * WorkerFactory,
21
+ * ProviderFactory,
22
+ * Security,
23
+ * } from '@sparkleideas/plugins';
24
+ *
25
+ * // Create a plugin with the builder
26
+ * const myPlugin = new PluginBuilder('my-plugin', '1.0.0')
27
+ * .withDescription('My awesome plugin')
28
+ * .withMCPTools([...])
29
+ * .withHooks([...])
30
+ * .withWorkers([...])
31
+ * .build();
32
+ *
33
+ * // Register with the default registry
34
+ * await getDefaultRegistry().register(myPlugin);
35
+ * ```
36
+ *
37
+ * @packageDocumentation
38
+ */
39
+
40
+ // ============================================================================
41
+ // Core Types
42
+ // ============================================================================
43
+
44
+ export * from './types/index.js';
45
+
46
+ // ============================================================================
47
+ // Plugin Interface & Base
48
+ // ============================================================================
49
+
50
+ export {
51
+ type IPlugin,
52
+ type PluginFactory,
53
+ type PluginModule,
54
+ type PluginEvent,
55
+ validatePlugin,
56
+ validatePluginMetadata,
57
+ PLUGIN_EVENTS,
58
+ } from './core/plugin-interface.js';
59
+
60
+ export {
61
+ BasePlugin,
62
+ createSimplePlugin,
63
+ type SimplePluginConfig,
64
+ } from './core/base-plugin.js';
65
+
66
+ // ============================================================================
67
+ // Plugin Registry
68
+ // ============================================================================
69
+
70
+ export {
71
+ PluginRegistry,
72
+ getDefaultRegistry,
73
+ setDefaultRegistry,
74
+ type PluginRegistryConfig,
75
+ type PluginEntry,
76
+ type RegistryStats,
77
+ } from './registry/plugin-registry.js';
78
+
79
+ // ============================================================================
80
+ // Enhanced Plugin Registry (v2)
81
+ // ============================================================================
82
+
83
+ export {
84
+ EnhancedPluginRegistry,
85
+ getDefaultEnhancedRegistry,
86
+ setDefaultEnhancedRegistry,
87
+ type EnhancedPluginRegistryConfig,
88
+ type InitializationStrategy,
89
+ type ConflictStrategy,
90
+ type ConflictResolution,
91
+ type UnregisterOptions,
92
+ type HotReloadOptions,
93
+ type ServiceMetadata,
94
+ } from './registry/enhanced-plugin-registry.js';
95
+
96
+ // ============================================================================
97
+ // Dependency Graph
98
+ // ============================================================================
99
+
100
+ export {
101
+ DependencyGraph,
102
+ parseVersion,
103
+ compareVersions,
104
+ satisfiesVersion,
105
+ type PluginDependency,
106
+ type DependencyNode,
107
+ type DependencyError,
108
+ } from './registry/dependency-graph.js';
109
+
110
+ // ============================================================================
111
+ // Plugin Collections
112
+ // ============================================================================
113
+
114
+ export {
115
+ // Collection Manager
116
+ PluginCollectionManager,
117
+ getDefaultCollectionManager,
118
+ setDefaultCollectionManager,
119
+ type PluginCollection,
120
+ type PluginCollectionEntry,
121
+ type PluginCategory,
122
+ type PluginCapability,
123
+ type CollectionManagerState,
124
+ type CollectionManagerConfig,
125
+ type CollectionStats,
126
+
127
+ // Official Plugins
128
+ sessionPlugin,
129
+ memoryCoordinatorPlugin,
130
+ eventBusPlugin,
131
+ coderAgentPlugin,
132
+ testerAgentPlugin,
133
+ reviewerAgentPlugin,
134
+ gitIntegrationPlugin,
135
+ linterPlugin,
136
+ sonaPlugin,
137
+ reasoningBankPlugin,
138
+ patternLearningPlugin,
139
+ hiveMindPlugin,
140
+ maestroPlugin,
141
+ consensusPlugin,
142
+ coordinatorAgentPlugin,
143
+ inputValidationPlugin,
144
+ pathSecurityPlugin,
145
+ auditLogPlugin,
146
+ securityScanPlugin,
147
+ metricsPlugin,
148
+ cachePlugin,
149
+
150
+ // Official Collections
151
+ coreCollection,
152
+ developmentCollection,
153
+ intelligenceCollection,
154
+ swarmCollection,
155
+ securityCollection,
156
+ utilityCollection,
157
+ officialCollections,
158
+
159
+ // Helpers
160
+ getAllOfficialPlugins,
161
+ getOfficialCollection,
162
+ } from './collections/index.js';
163
+
164
+ // ============================================================================
165
+ // SDK Builders
166
+ // ============================================================================
167
+
168
+ export {
169
+ PluginBuilder,
170
+ MCPToolBuilder,
171
+ HookBuilder,
172
+ WorkerBuilder,
173
+ createToolPlugin,
174
+ createHooksPlugin,
175
+ createWorkerPlugin,
176
+ createProviderPlugin,
177
+ } from './sdk/index.js';
178
+
179
+ // ============================================================================
180
+ // Workers
181
+ // ============================================================================
182
+
183
+ export {
184
+ WorkerPool,
185
+ WorkerInstance,
186
+ WorkerFactory,
187
+ WORKER_EVENTS,
188
+ type IWorkerPool,
189
+ type IWorkerInstance,
190
+ type WorkerTask,
191
+ type WorkerTaskResult,
192
+ type WorkerPoolConfig,
193
+ type PoolMetrics,
194
+ type WorkerEvent,
195
+ } from './workers/index.js';
196
+
197
+ // ============================================================================
198
+ // Hooks
199
+ // ============================================================================
200
+
201
+ export {
202
+ HookRegistry,
203
+ HookBuilder as HookBuilderAdvanced,
204
+ HookFactory,
205
+ HookExecutor,
206
+ HookEvent,
207
+ HookPriority,
208
+ type HookRegistryConfig,
209
+ type HookEntry,
210
+ type HookRegistryStats,
211
+ } from './hooks/index.js';
212
+
213
+ // ============================================================================
214
+ // Providers
215
+ // ============================================================================
216
+
217
+ export {
218
+ ProviderRegistry,
219
+ BaseLLMProvider,
220
+ ProviderFactory,
221
+ PROVIDER_EVENTS,
222
+ type ILLMProvider,
223
+ type RateLimitStatus,
224
+ type ProviderRegistryConfig,
225
+ type ProviderEntry,
226
+ type ProviderRegistryStats,
227
+ type RetryConfig,
228
+ type ProviderEvent,
229
+ } from './providers/index.js';
230
+
231
+ // ============================================================================
232
+ // Integrations
233
+ // ============================================================================
234
+
235
+ export {
236
+ // Agentic Flow
237
+ AgenticFlowBridge,
238
+ getAgenticFlowBridge,
239
+ AGENTIC_FLOW_EVENTS,
240
+ type AgenticFlowConfig,
241
+ type SwarmTopology,
242
+ type AgentSpawnOptions,
243
+ type SpawnedAgent,
244
+ type TaskOrchestrationOptions,
245
+ type OrchestrationResult,
246
+ type AgenticFlowEvent,
247
+ // AgentDB
248
+ AgentDBBridge,
249
+ getAgentDBBridge,
250
+ resetBridges,
251
+ type AgentDBConfig,
252
+ type VectorEntry,
253
+ type VectorSearchOptions,
254
+ type VectorSearchResult,
255
+ } from './integrations/index.js';
256
+
257
+ // ============================================================================
258
+ // Security
259
+ // ============================================================================
260
+
261
+ export {
262
+ Security,
263
+ validateString,
264
+ validateNumber,
265
+ validateBoolean,
266
+ validateArray,
267
+ validateEnum,
268
+ validatePath,
269
+ validateCommand,
270
+ safePath,
271
+ safePathAsync,
272
+ safeJsonParse,
273
+ safeJsonStringify,
274
+ escapeShellArg,
275
+ sanitizeError,
276
+ sanitizeErrorMessage,
277
+ createRateLimiter,
278
+ createResourceLimiter,
279
+ generateSecureId,
280
+ generateSecureToken,
281
+ hashString,
282
+ constantTimeCompare,
283
+ type RateLimiter,
284
+ type ResourceLimits,
285
+ } from './security/index.js';
286
+
287
+ // ============================================================================
288
+ // Version
289
+ // ============================================================================
290
+
291
+ export const VERSION = '3.0.0-alpha.1';
292
+ export const SDK_VERSION = '1.0.0';
293
+
294
+ // ============================================================================
295
+ // Quick Start Utilities
296
+ // ============================================================================
297
+
298
+ import { PluginBuilder } from './sdk/index.js';
299
+ import { getDefaultRegistry } from './registry/plugin-registry.js';
300
+ import type { IPlugin, PluginFactory } from './core/plugin-interface.js';
301
+ import type { PluginConfig } from './types/index.js';
302
+
303
+ /**
304
+ * Quick start: Create and register a plugin in one call.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * const plugin = await quickPlugin('my-plugin', '1.0.0', (builder) => {
309
+ * builder
310
+ * .withDescription('Quick plugin')
311
+ * .withMCPTools([...]);
312
+ * });
313
+ * ```
314
+ */
315
+ export async function quickPlugin(
316
+ name: string,
317
+ version: string,
318
+ configure: (builder: PluginBuilder) => void,
319
+ config?: Partial<PluginConfig>
320
+ ): Promise<IPlugin> {
321
+ const builder = new PluginBuilder(name, version);
322
+ configure(builder);
323
+ return builder.buildAndRegister(config);
324
+ }
325
+
326
+ /**
327
+ * Load and register a plugin module dynamically.
328
+ *
329
+ * @example
330
+ * ```typescript
331
+ * const plugin = await loadPlugin('./my-plugin.js');
332
+ * ```
333
+ */
334
+ export async function loadPlugin(
335
+ modulePath: string,
336
+ config?: Partial<PluginConfig>
337
+ ): Promise<IPlugin> {
338
+ const module = await import(modulePath);
339
+ const pluginOrFactory: IPlugin | PluginFactory = module.default ?? module.plugin;
340
+
341
+ if (!pluginOrFactory) {
342
+ throw new Error(`Module ${modulePath} does not export a plugin`);
343
+ }
344
+
345
+ const plugin = typeof pluginOrFactory === 'function'
346
+ ? await pluginOrFactory()
347
+ : pluginOrFactory;
348
+
349
+ await getDefaultRegistry().register(plugin, config);
350
+ return plugin;
351
+ }
352
+
353
+ /**
354
+ * Initialize the plugin system.
355
+ *
356
+ * @example
357
+ * ```typescript
358
+ * await initializePlugins({
359
+ * coreVersion: '3.0.0',
360
+ * dataDir: './data',
361
+ * });
362
+ * ```
363
+ */
364
+ export async function initializePlugins(_options?: {
365
+ coreVersion?: string;
366
+ dataDir?: string;
367
+ }): Promise<void> {
368
+ const registry = getDefaultRegistry();
369
+ await registry.initialize();
370
+ }
371
+
372
+ /**
373
+ * Shutdown the plugin system.
374
+ */
375
+ export async function shutdownPlugins(): Promise<void> {
376
+ const registry = getDefaultRegistry();
377
+ await registry.shutdown();
378
+ }