@claude-flow/cli 3.0.0-alpha.55 → 3.0.0-alpha.57

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 (139) hide show
  1. package/.claude/settings.json +2 -2
  2. package/dist/src/commands/hooks.d.ts.map +1 -1
  3. package/dist/src/commands/hooks.js +45 -5
  4. package/dist/src/commands/hooks.js.map +1 -1
  5. package/dist/src/commands/init.d.ts.map +1 -1
  6. package/dist/src/commands/init.js +80 -9
  7. package/dist/src/commands/init.js.map +1 -1
  8. package/dist/src/commands/memory.d.ts.map +1 -1
  9. package/dist/src/commands/memory.js +221 -2
  10. package/dist/src/commands/memory.js.map +1 -1
  11. package/dist/src/commands/plugins.d.ts +1 -0
  12. package/dist/src/commands/plugins.d.ts.map +1 -1
  13. package/dist/src/commands/plugins.js +439 -89
  14. package/dist/src/commands/plugins.js.map +1 -1
  15. package/dist/src/commands/transfer-store.d.ts +13 -0
  16. package/dist/src/commands/transfer-store.d.ts.map +1 -0
  17. package/dist/src/commands/transfer-store.js +428 -0
  18. package/dist/src/commands/transfer-store.js.map +1 -0
  19. package/dist/src/init/mcp-generator.d.ts +9 -0
  20. package/dist/src/init/mcp-generator.d.ts.map +1 -1
  21. package/dist/src/init/mcp-generator.js +57 -28
  22. package/dist/src/init/mcp-generator.js.map +1 -1
  23. package/dist/src/init/settings-generator.d.ts.map +1 -1
  24. package/dist/src/init/settings-generator.js +4 -2
  25. package/dist/src/init/settings-generator.js.map +1 -1
  26. package/dist/src/mcp-tools/index.d.ts +1 -0
  27. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  28. package/dist/src/mcp-tools/index.js +1 -0
  29. package/dist/src/mcp-tools/index.js.map +1 -1
  30. package/dist/src/mcp-tools/transfer-tools.d.ts +14 -0
  31. package/dist/src/mcp-tools/transfer-tools.d.ts.map +1 -0
  32. package/dist/src/mcp-tools/transfer-tools.js +396 -0
  33. package/dist/src/mcp-tools/transfer-tools.js.map +1 -0
  34. package/dist/src/plugins/store/discovery.d.ts +73 -0
  35. package/dist/src/plugins/store/discovery.d.ts.map +1 -0
  36. package/dist/src/plugins/store/discovery.js +568 -0
  37. package/dist/src/plugins/store/discovery.js.map +1 -0
  38. package/dist/src/plugins/store/index.d.ts +76 -0
  39. package/dist/src/plugins/store/index.d.ts.map +1 -0
  40. package/dist/src/plugins/store/index.js +141 -0
  41. package/dist/src/plugins/store/index.js.map +1 -0
  42. package/dist/src/plugins/store/search.d.ts +46 -0
  43. package/dist/src/plugins/store/search.d.ts.map +1 -0
  44. package/dist/src/plugins/store/search.js +230 -0
  45. package/dist/src/plugins/store/search.js.map +1 -0
  46. package/dist/src/plugins/store/types.d.ts +274 -0
  47. package/dist/src/plugins/store/types.d.ts.map +1 -0
  48. package/dist/src/plugins/store/types.js +7 -0
  49. package/dist/src/plugins/store/types.js.map +1 -0
  50. package/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
  51. package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +1 -0
  52. package/dist/src/plugins/tests/demo-plugin-store.js +126 -0
  53. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -0
  54. package/dist/src/plugins/tests/standalone-test.d.ts +12 -0
  55. package/dist/src/plugins/tests/standalone-test.d.ts.map +1 -0
  56. package/dist/src/plugins/tests/standalone-test.js +188 -0
  57. package/dist/src/plugins/tests/standalone-test.js.map +1 -0
  58. package/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
  59. package/dist/src/plugins/tests/test-plugin-store.d.ts.map +1 -0
  60. package/dist/src/plugins/tests/test-plugin-store.js +206 -0
  61. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -0
  62. package/dist/src/transfer/anonymization/index.d.ts +25 -0
  63. package/dist/src/transfer/anonymization/index.d.ts.map +1 -0
  64. package/dist/src/transfer/anonymization/index.js +175 -0
  65. package/dist/src/transfer/anonymization/index.js.map +1 -0
  66. package/dist/src/transfer/deploy-seraphine.d.ts +13 -0
  67. package/dist/src/transfer/deploy-seraphine.d.ts.map +1 -0
  68. package/dist/src/transfer/deploy-seraphine.js +205 -0
  69. package/dist/src/transfer/deploy-seraphine.js.map +1 -0
  70. package/dist/src/transfer/export.d.ts +25 -0
  71. package/dist/src/transfer/export.d.ts.map +1 -0
  72. package/dist/src/transfer/export.js +113 -0
  73. package/dist/src/transfer/export.js.map +1 -0
  74. package/dist/src/transfer/index.d.ts +12 -0
  75. package/dist/src/transfer/index.d.ts.map +1 -0
  76. package/dist/src/transfer/index.js +31 -0
  77. package/dist/src/transfer/index.js.map +1 -0
  78. package/dist/src/transfer/ipfs/client.d.ts +31 -0
  79. package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
  80. package/dist/src/transfer/ipfs/client.js +74 -0
  81. package/dist/src/transfer/ipfs/client.js.map +1 -0
  82. package/dist/src/transfer/ipfs/upload.d.ts +85 -0
  83. package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
  84. package/dist/src/transfer/ipfs/upload.js +319 -0
  85. package/dist/src/transfer/ipfs/upload.js.map +1 -0
  86. package/dist/src/transfer/models/seraphine.d.ts +72 -0
  87. package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
  88. package/dist/src/transfer/models/seraphine.js +373 -0
  89. package/dist/src/transfer/models/seraphine.js.map +1 -0
  90. package/dist/src/transfer/serialization/cfp.d.ts +49 -0
  91. package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
  92. package/dist/src/transfer/serialization/cfp.js +180 -0
  93. package/dist/src/transfer/serialization/cfp.js.map +1 -0
  94. package/dist/src/transfer/store/discovery.d.ts +84 -0
  95. package/dist/src/transfer/store/discovery.d.ts.map +1 -0
  96. package/dist/src/transfer/store/discovery.js +275 -0
  97. package/dist/src/transfer/store/discovery.js.map +1 -0
  98. package/dist/src/transfer/store/download.d.ts +70 -0
  99. package/dist/src/transfer/store/download.d.ts.map +1 -0
  100. package/dist/src/transfer/store/download.js +295 -0
  101. package/dist/src/transfer/store/download.js.map +1 -0
  102. package/dist/src/transfer/store/index.d.ts +84 -0
  103. package/dist/src/transfer/store/index.d.ts.map +1 -0
  104. package/dist/src/transfer/store/index.js +153 -0
  105. package/dist/src/transfer/store/index.js.map +1 -0
  106. package/dist/src/transfer/store/publish.d.ts +76 -0
  107. package/dist/src/transfer/store/publish.d.ts.map +1 -0
  108. package/dist/src/transfer/store/publish.js +262 -0
  109. package/dist/src/transfer/store/publish.js.map +1 -0
  110. package/dist/src/transfer/store/registry.d.ts +58 -0
  111. package/dist/src/transfer/store/registry.d.ts.map +1 -0
  112. package/dist/src/transfer/store/registry.js +285 -0
  113. package/dist/src/transfer/store/registry.js.map +1 -0
  114. package/dist/src/transfer/store/search.d.ts +54 -0
  115. package/dist/src/transfer/store/search.d.ts.map +1 -0
  116. package/dist/src/transfer/store/search.js +232 -0
  117. package/dist/src/transfer/store/search.js.map +1 -0
  118. package/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
  119. package/dist/src/transfer/store/tests/standalone-test.d.ts.map +1 -0
  120. package/dist/src/transfer/store/tests/standalone-test.js +190 -0
  121. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -0
  122. package/dist/src/transfer/store/types.d.ts +193 -0
  123. package/dist/src/transfer/store/types.d.ts.map +1 -0
  124. package/dist/src/transfer/store/types.js +6 -0
  125. package/dist/src/transfer/store/types.js.map +1 -0
  126. package/dist/src/transfer/test-seraphine.d.ts +6 -0
  127. package/dist/src/transfer/test-seraphine.d.ts.map +1 -0
  128. package/dist/src/transfer/test-seraphine.js +105 -0
  129. package/dist/src/transfer/test-seraphine.js.map +1 -0
  130. package/dist/src/transfer/tests/test-store.d.ts +7 -0
  131. package/dist/src/transfer/tests/test-store.d.ts.map +1 -0
  132. package/dist/src/transfer/tests/test-store.js +214 -0
  133. package/dist/src/transfer/tests/test-store.js.map +1 -0
  134. package/dist/src/transfer/types.d.ts +245 -0
  135. package/dist/src/transfer/types.d.ts.map +1 -0
  136. package/dist/src/transfer/types.js +6 -0
  137. package/dist/src/transfer/types.js.map +1 -0
  138. package/dist/tsconfig.tsbuildinfo +1 -1
  139. package/package.json +3 -1
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * Plugin Store Test Suite
4
+ * Tests IPFS-based plugin registry discovery, search, and operations
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=test-plugin-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-plugin-store.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tests/test-plugin-store.ts"],"names":[],"mappings":";AACA;;;GAGG"}
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * Plugin Store Test Suite
4
+ * Tests IPFS-based plugin registry discovery, search, and operations
5
+ */
6
+ import { createPluginDiscoveryService, searchPlugins, getPluginSearchSuggestions, getPluginTagCloud, getFeaturedPlugins, getTrendingPlugins, getOfficialPlugins, findSimilarPlugins, } from '../store/index.js';
7
+ // Test results tracking
8
+ const results = [];
9
+ function logTest(name, passed, details) {
10
+ results.push({ test: name, passed, details });
11
+ const icon = passed ? '✅' : '❌';
12
+ console.log(`${icon} ${name}${details ? `: ${details}` : ''}`);
13
+ }
14
+ async function runTests() {
15
+ console.log('');
16
+ console.log('╔══════════════════════════════════════════════════════════╗');
17
+ console.log('║ PLUGIN STORE TEST SUITE ║');
18
+ console.log('║ Testing IPFS-Based Registry Discovery ║');
19
+ console.log('╚══════════════════════════════════════════════════════════╝');
20
+ console.log('');
21
+ // ==========================================================================
22
+ // 1. DISCOVERY TESTS
23
+ // ==========================================================================
24
+ console.log('─── Discovery Tests ───────────────────────────────────────');
25
+ try {
26
+ const discovery = createPluginDiscoveryService();
27
+ logTest('Discovery service created', true);
28
+ // List registries
29
+ const registries = discovery.listRegistries();
30
+ logTest('List registries', registries.length > 0, `Found ${registries.length} registries`);
31
+ // Discover registry
32
+ const result = await discovery.discoverRegistry();
33
+ logTest('Discover registry via IPNS', result.success, result.success
34
+ ? `Loaded ${result.registry?.plugins.length || 0} plugins`
35
+ : result.error);
36
+ // Cache test
37
+ if (result.success) {
38
+ const cachedResult = await discovery.discoverRegistry();
39
+ logTest('Cache hit', cachedResult.fromCache === true, 'Second request from cache');
40
+ }
41
+ console.log('');
42
+ // ==========================================================================
43
+ // 2. SEARCH TESTS
44
+ // ==========================================================================
45
+ console.log('─── Search Tests ──────────────────────────────────────────');
46
+ if (result.success && result.registry) {
47
+ const registry = result.registry;
48
+ // Basic search
49
+ const basicSearch = searchPlugins(registry);
50
+ logTest('Basic search', basicSearch.plugins.length > 0, `Found ${basicSearch.total} plugins`);
51
+ // Query search for plugin-creator
52
+ const creatorSearch = searchPlugins(registry, { query: 'creator' });
53
+ logTest('Query search: "creator"', creatorSearch.plugins.length > 0, `Found ${creatorSearch.plugins.length} plugins matching "creator"`);
54
+ // Verify plugin-creator exists
55
+ const pluginCreator = creatorSearch.plugins.find(p => p.id === 'plugin-creator');
56
+ logTest('Plugin Creator found', pluginCreator !== undefined, pluginCreator ? `v${pluginCreator.version} - ${pluginCreator.displayName}` : 'Not found');
57
+ // Category filter
58
+ const securitySearch = searchPlugins(registry, { category: 'security' });
59
+ logTest('Category filter: security', true, `Found ${securitySearch.plugins.length} security plugins`);
60
+ // Type filter
61
+ const commandSearch = searchPlugins(registry, { type: 'command' });
62
+ logTest('Type filter: command', commandSearch.plugins.length > 0, `Found ${commandSearch.plugins.length} command plugins`);
63
+ // Verified filter
64
+ const verifiedSearch = searchPlugins(registry, { verified: true });
65
+ logTest('Verified filter', verifiedSearch.plugins.length > 0, `Verified plugins: ${verifiedSearch.plugins.length}`);
66
+ // Sort by downloads
67
+ const sortedSearch = searchPlugins(registry, {
68
+ sortBy: 'downloads',
69
+ sortOrder: 'desc',
70
+ });
71
+ logTest('Sort by downloads', true, `Top plugin: ${sortedSearch.plugins[0]?.displayName || 'none'} (${sortedSearch.plugins[0]?.downloads || 0} downloads)`);
72
+ // Pagination
73
+ const page1 = searchPlugins(registry, { limit: 3, offset: 0 });
74
+ logTest('Pagination', page1.pageSize === 3, `Page 1 with ${page1.plugins.length} plugins, hasMore: ${page1.hasMore}`);
75
+ // Search suggestions
76
+ const suggestions = getPluginSearchSuggestions(registry, 'neu');
77
+ logTest('Search suggestions', suggestions.length >= 0, `Suggestions for "neu": ${suggestions.slice(0, 3).join(', ') || 'none'}`);
78
+ // Tag cloud
79
+ const tagCloud = getPluginTagCloud(registry);
80
+ logTest('Tag cloud', tagCloud.size > 0, `${tagCloud.size} unique tags`);
81
+ }
82
+ console.log('');
83
+ // ==========================================================================
84
+ // 3. FEATURED/TRENDING/OFFICIAL TESTS
85
+ // ==========================================================================
86
+ console.log('─── Featured/Trending/Official Tests ─────────────────────');
87
+ if (result.success && result.registry) {
88
+ const registry = result.registry;
89
+ // Featured plugins
90
+ const featured = getFeaturedPlugins(registry);
91
+ logTest('Featured plugins', featured.length > 0, `${featured.length} featured: ${featured.map(p => p.name).join(', ')}`);
92
+ // Check plugin-creator is featured
93
+ const creatorFeatured = featured.some(p => p.id === 'plugin-creator');
94
+ logTest('Plugin Creator is featured', creatorFeatured, creatorFeatured ? 'Yes' : 'No');
95
+ // Trending plugins
96
+ const trending = getTrendingPlugins(registry);
97
+ logTest('Trending plugins', trending.length > 0, `${trending.length} trending: ${trending.map(p => p.name).join(', ')}`);
98
+ // Official plugins
99
+ const official = getOfficialPlugins(registry);
100
+ logTest('Official plugins', official.length > 0, `${official.length} official plugins`);
101
+ // Similar plugins
102
+ const similar = findSimilarPlugins(registry, '@claude-flow/neural', 3);
103
+ logTest('Similar plugins', similar.length >= 0, `Similar to @claude-flow/neural: ${similar.map(p => p.name).join(', ') || 'none'}`);
104
+ }
105
+ console.log('');
106
+ // ==========================================================================
107
+ // 4. PLUGIN DETAILS TEST
108
+ // ==========================================================================
109
+ console.log('─── Plugin Details Test ───────────────────────────────────');
110
+ if (result.success && result.registry) {
111
+ const pluginCreator = result.registry.plugins.find(p => p.id === 'plugin-creator');
112
+ if (pluginCreator) {
113
+ logTest('Plugin Creator details', true);
114
+ console.log('');
115
+ console.log(' Plugin Creator Pro Details:');
116
+ console.log(` ├─ ID: ${pluginCreator.id}`);
117
+ console.log(` ├─ Version: ${pluginCreator.version}`);
118
+ console.log(` ├─ CID: ${pluginCreator.cid}`);
119
+ console.log(` ├─ Size: ${(pluginCreator.size / 1024).toFixed(1)} KB`);
120
+ console.log(` ├─ Downloads: ${pluginCreator.downloads.toLocaleString()}`);
121
+ console.log(` ├─ Rating: ${pluginCreator.rating}★ (${pluginCreator.ratingCount} ratings)`);
122
+ console.log(` ├─ Trust: ${pluginCreator.trustLevel}`);
123
+ console.log(` ├─ Verified: ${pluginCreator.verified ? '✓' : '✗'}`);
124
+ console.log(` ├─ Commands: ${pluginCreator.commands.length}`);
125
+ pluginCreator.commands.forEach(cmd => {
126
+ console.log(` │ └─ ${cmd}`);
127
+ });
128
+ console.log(` ├─ Hooks: ${pluginCreator.hooks.length}`);
129
+ pluginCreator.hooks.forEach(hook => {
130
+ console.log(` │ └─ ${hook}`);
131
+ });
132
+ console.log(` ├─ Permissions: ${pluginCreator.permissions.join(', ')}`);
133
+ console.log(` ├─ Security Audit: ${pluginCreator.securityAudit ? '✓ Passed' : 'None'}`);
134
+ console.log(` └─ License: ${pluginCreator.license}`);
135
+ console.log('');
136
+ }
137
+ }
138
+ // ==========================================================================
139
+ // 5. INTEGRATION TEST
140
+ // ==========================================================================
141
+ console.log('─── Integration Test ──────────────────────────────────────');
142
+ // Full workflow: discover -> search -> get details
143
+ const store = createPluginDiscoveryService();
144
+ const discoverResult = await store.discoverRegistry();
145
+ if (discoverResult.success && discoverResult.registry) {
146
+ const searchResult = searchPlugins(discoverResult.registry, {
147
+ query: 'plugin creator',
148
+ });
149
+ if (searchResult.plugins.length > 0) {
150
+ const plugin = searchResult.plugins[0];
151
+ logTest('Full workflow', true, `Discover → Search → Found "${plugin.displayName}" ready to download`);
152
+ }
153
+ else {
154
+ logTest('Full workflow', true, 'Discover → Search completed');
155
+ }
156
+ }
157
+ }
158
+ catch (error) {
159
+ console.error('Test error:', error);
160
+ logTest('Test suite', false, `Error: ${error}`);
161
+ }
162
+ // ==========================================================================
163
+ // SUMMARY
164
+ // ==========================================================================
165
+ console.log('');
166
+ console.log('═══════════════════════════════════════════════════════════');
167
+ console.log(' TEST SUMMARY ');
168
+ console.log('═══════════════════════════════════════════════════════════');
169
+ console.log('');
170
+ const passed = results.filter(r => r.passed).length;
171
+ const failed = results.filter(r => !r.passed).length;
172
+ const total = results.length;
173
+ console.log(` Total Tests: ${total}`);
174
+ console.log(` ✅ Passed: ${passed}`);
175
+ console.log(` ❌ Failed: ${failed}`);
176
+ console.log('');
177
+ if (failed === 0) {
178
+ console.log(' 🎉 All tests passed!');
179
+ console.log('');
180
+ console.log(' 📦 Plugin Store Features Verified:');
181
+ console.log(' - Registry discovery via IPNS');
182
+ console.log(' - Plugin search with filters');
183
+ console.log(' - Featured/Trending/Official listings');
184
+ console.log(' - Plugin Creator Pro available for download');
185
+ console.log('');
186
+ console.log(' 🔧 Plugin Creator Pro Commands:');
187
+ console.log(' - plugin-creator new Create new plugin');
188
+ console.log(' - plugin-creator template Use template');
189
+ console.log(' - plugin-creator validate Validate plugin');
190
+ console.log(' - plugin-creator test Run tests');
191
+ console.log(' - plugin-creator build Build plugin');
192
+ console.log(' - plugin-creator publish Publish to IPFS');
193
+ console.log(' - plugin-creator watch Hot-reload dev mode');
194
+ console.log('');
195
+ }
196
+ else {
197
+ console.log(' ⚠️ Some tests failed. Please review the output above.');
198
+ }
199
+ process.exit(failed > 0 ? 1 : 0);
200
+ }
201
+ // Run tests
202
+ runTests().catch(error => {
203
+ console.error('Fatal error:', error);
204
+ process.exit(1);
205
+ });
206
+ //# sourceMappingURL=test-plugin-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-plugin-store.js","sourceRoot":"","sources":["../../../../src/plugins/tests/test-plugin-store.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EACL,4BAA4B,EAC5B,aAAa,E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AAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,YAAY;AACZ,QAAQ,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACvB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Anonymization Pipeline
3
+ * PII detection and redaction for pattern export
4
+ */
5
+ import type { CFPFormat, AnonymizationLevel, PIIDetectionResult } from '../types.js';
6
+ /**
7
+ * Detect PII in a string
8
+ */
9
+ export declare function detectPII(content: string): PIIDetectionResult;
10
+ /**
11
+ * Redact PII from a string
12
+ */
13
+ export declare function redactPII(content: string): string;
14
+ /**
15
+ * Apply anonymization to CFP document
16
+ */
17
+ export declare function anonymizeCFP(cfp: CFPFormat, level: AnonymizationLevel): {
18
+ cfp: CFPFormat;
19
+ transforms: string[];
20
+ };
21
+ /**
22
+ * Scan CFP for PII without modification
23
+ */
24
+ export declare function scanCFPForPII(cfp: CFPFormat): PIIDetectionResult;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transfer/anonymization/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAElB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAsCrB;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CA2B7D;AAqBD;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAajD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,kBAAkB,GACxB;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CA2E1C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,GAAG,kBAAkB,CAGhE"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Anonymization Pipeline
3
+ * PII detection and redaction for pattern export
4
+ */
5
+ import * as crypto from 'crypto';
6
+ /**
7
+ * PII detection patterns
8
+ */
9
+ const PII_PATTERNS = {
10
+ email: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,
11
+ phone: /\b(\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g,
12
+ ipv4: /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/g,
13
+ ipv6: /\b(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\b/g,
14
+ apiKey: /\b(sk-|pk-|api[_-]?key[_-]?)[a-zA-Z0-9]{20,}\b/gi,
15
+ jwt: /\beyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*\b/g,
16
+ homePath: /\/(Users|home|Documents)\/[a-zA-Z0-9_.-]+/g,
17
+ windowsPath: /[A-Z]:\\Users\\[a-zA-Z0-9_.-]+/g,
18
+ };
19
+ /**
20
+ * Redaction replacements
21
+ */
22
+ const REDACTIONS = {
23
+ email: (match) => `user_${hash(match).slice(0, 8)}@example.com`,
24
+ phone: '[REDACTED_PHONE]',
25
+ ipv4: '0.0.0.0',
26
+ ipv6: '::1',
27
+ apiKey: '[REDACTED_API_KEY]',
28
+ jwt: '[REDACTED_JWT]',
29
+ homePath: '/user/anonymous',
30
+ windowsPath: 'C:\\Users\\anonymous',
31
+ };
32
+ /**
33
+ * Hash a string for consistent pseudonymization
34
+ */
35
+ function hash(input) {
36
+ return crypto.createHash('sha256').update(input).digest('hex');
37
+ }
38
+ /**
39
+ * Detect PII in a string
40
+ */
41
+ export function detectPII(content) {
42
+ const result = {
43
+ found: false,
44
+ count: 0,
45
+ types: {},
46
+ locations: [],
47
+ };
48
+ for (const [type, pattern] of Object.entries(PII_PATTERNS)) {
49
+ const matches = content.match(pattern);
50
+ if (matches) {
51
+ result.found = true;
52
+ result.count += matches.length;
53
+ result.types[type] = matches.length;
54
+ for (const match of matches.slice(0, 5)) { // Limit to first 5 samples
55
+ result.locations.push({
56
+ type,
57
+ path: 'content',
58
+ sample: match.slice(0, 20) + (match.length > 20 ? '...' : ''),
59
+ severity: getSeverity(type),
60
+ });
61
+ }
62
+ }
63
+ }
64
+ return result;
65
+ }
66
+ /**
67
+ * Get severity for PII type
68
+ */
69
+ function getSeverity(type) {
70
+ switch (type) {
71
+ case 'apiKey':
72
+ case 'jwt':
73
+ return 'critical';
74
+ case 'email':
75
+ case 'phone':
76
+ return 'high';
77
+ case 'ipv4':
78
+ case 'ipv6':
79
+ return 'medium';
80
+ default:
81
+ return 'low';
82
+ }
83
+ }
84
+ /**
85
+ * Redact PII from a string
86
+ */
87
+ export function redactPII(content) {
88
+ let result = content;
89
+ for (const [type, pattern] of Object.entries(PII_PATTERNS)) {
90
+ const replacement = REDACTIONS[type];
91
+ if (typeof replacement === 'function') {
92
+ result = result.replace(pattern, replacement);
93
+ }
94
+ else {
95
+ result = result.replace(pattern, replacement);
96
+ }
97
+ }
98
+ return result;
99
+ }
100
+ /**
101
+ * Apply anonymization to CFP document
102
+ */
103
+ export function anonymizeCFP(cfp, level) {
104
+ const transforms = [];
105
+ const anonymized = JSON.parse(JSON.stringify(cfp));
106
+ // Level: Minimal
107
+ if (['minimal', 'standard', 'strict', 'paranoid'].includes(level)) {
108
+ // Redact author display name
109
+ if (anonymized.metadata.author?.displayName) {
110
+ anonymized.metadata.author.displayName = undefined;
111
+ transforms.push('author-name-removed');
112
+ }
113
+ }
114
+ // Level: Standard
115
+ if (['standard', 'strict', 'paranoid'].includes(level)) {
116
+ // Redact PII from all string fields
117
+ const jsonStr = JSON.stringify(anonymized.patterns);
118
+ const redacted = redactPII(jsonStr);
119
+ anonymized.patterns = JSON.parse(redacted);
120
+ transforms.push('pii-redacted');
121
+ // Generalize timestamps
122
+ anonymized.anonymization.timestampsGeneralized = true;
123
+ transforms.push('timestamps-generalized');
124
+ }
125
+ // Level: Strict
126
+ if (['strict', 'paranoid'].includes(level)) {
127
+ // Hash all IDs
128
+ for (const pattern of anonymized.patterns.routing) {
129
+ pattern.id = `pattern_${hash(pattern.id).slice(0, 12)}`;
130
+ }
131
+ transforms.push('ids-hashed');
132
+ // Remove context details
133
+ for (const pattern of anonymized.patterns.routing) {
134
+ pattern.context = undefined;
135
+ }
136
+ transforms.push('context-removed');
137
+ anonymized.anonymization.pathsStripped = true;
138
+ transforms.push('paths-stripped');
139
+ }
140
+ // Level: Paranoid
141
+ if (level === 'paranoid') {
142
+ // Add noise to numeric values (differential privacy)
143
+ for (const pattern of anonymized.patterns.routing) {
144
+ pattern.usageCount = Math.round(pattern.usageCount * (0.9 + Math.random() * 0.2));
145
+ pattern.successRate = Math.min(1, Math.max(0, pattern.successRate + (Math.random() - 0.5) * 0.1));
146
+ }
147
+ transforms.push('differential-privacy-noise');
148
+ // Remove all trajectory learnings
149
+ for (const traj of anonymized.patterns.trajectory) {
150
+ traj.learnings = [];
151
+ }
152
+ transforms.push('learnings-removed');
153
+ }
154
+ // Update anonymization record
155
+ anonymized.anonymization.level = level;
156
+ anonymized.anonymization.appliedTransforms = transforms;
157
+ anonymized.anonymization.piiRedacted = level !== 'minimal';
158
+ // Recalculate checksum
159
+ const content = JSON.stringify({
160
+ magic: anonymized.magic,
161
+ version: anonymized.version,
162
+ metadata: anonymized.metadata,
163
+ patterns: anonymized.patterns,
164
+ });
165
+ anonymized.anonymization.checksum = hash(content);
166
+ return { cfp: anonymized, transforms };
167
+ }
168
+ /**
169
+ * Scan CFP for PII without modification
170
+ */
171
+ export function scanCFPForPII(cfp) {
172
+ const content = JSON.stringify(cfp.patterns);
173
+ return detectPII(content);
174
+ }
175
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transfer/anonymization/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;GAEG;AACH,MAAM,YAAY,GAAG;IACnB,KAAK,EAAE,sDAAsD;IAC7D,KAAK,EAAE,8DAA8D;IACrE,IAAI,EAAE,gGAAgG;IACtG,IAAI,EAAE,+CAA+C;IACrD,MAAM,EAAE,kDAAkD;IAC1D,GAAG,EAAE,2DAA2D;IAChE,QAAQ,EAAE,4CAA4C;IACtD,WAAW,EAAE,iCAAiC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,GAAyD;IACvE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,cAAc;IAC/D,KAAK,EAAE,kBAAkB;IACzB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,oBAAoB;IAC5B,GAAG,EAAE,gBAAgB;IACrB,QAAQ,EAAE,iBAAiB;IAC3B,WAAW,EAAE,sBAAsB;CACpC,CAAC;AAEF;;GAEG;AACH,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,MAAM,MAAM,GAAuB;QACjC,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,EAAE;KACd,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAA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@@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * Deploy Seraphine Genesis Model
4
+ * Exports and uploads the first Claude Flow pattern model to IPFS
5
+ *
6
+ * Usage:
7
+ * npx tsx deploy-seraphine.ts
8
+ * npx tsx deploy-seraphine.ts --output ./patterns/
9
+ * npx tsx deploy-seraphine.ts --to-ipfs
10
+ * npx tsx deploy-seraphine.ts --to-ipfs --anonymize strict
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=deploy-seraphine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-seraphine.d.ts","sourceRoot":"","sources":["../../../src/transfer/deploy-seraphine.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}