@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.
- package/.claude/settings.json +2 -2
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +45 -5
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +80 -9
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +221 -2
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/plugins.d.ts +1 -0
- package/dist/src/commands/plugins.d.ts.map +1 -1
- package/dist/src/commands/plugins.js +439 -89
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/transfer-store.d.ts +13 -0
- package/dist/src/commands/transfer-store.d.ts.map +1 -0
- package/dist/src/commands/transfer-store.js +428 -0
- package/dist/src/commands/transfer-store.js.map +1 -0
- package/dist/src/init/mcp-generator.d.ts +9 -0
- package/dist/src/init/mcp-generator.d.ts.map +1 -1
- package/dist/src/init/mcp-generator.js +57 -28
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +4 -2
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +1 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +1 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.d.ts +14 -0
- package/dist/src/mcp-tools/transfer-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/transfer-tools.js +396 -0
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -0
- package/dist/src/plugins/store/discovery.d.ts +73 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +568 -0
- package/dist/src/plugins/store/discovery.js.map +1 -0
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +141 -0
- package/dist/src/plugins/store/index.js.map +1 -0
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +230 -0
- package/dist/src/plugins/store/search.js.map +1 -0
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/store/types.js +7 -0
- package/dist/src/plugins/store/types.js.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
- package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +126 -0
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -0
- package/dist/src/plugins/tests/standalone-test.d.ts +12 -0
- package/dist/src/plugins/tests/standalone-test.d.ts.map +1 -0
- package/dist/src/plugins/tests/standalone-test.js +188 -0
- package/dist/src/plugins/tests/standalone-test.js.map +1 -0
- package/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
- package/dist/src/plugins/tests/test-plugin-store.d.ts.map +1 -0
- package/dist/src/plugins/tests/test-plugin-store.js +206 -0
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -0
- package/dist/src/transfer/anonymization/index.d.ts +25 -0
- package/dist/src/transfer/anonymization/index.d.ts.map +1 -0
- package/dist/src/transfer/anonymization/index.js +175 -0
- package/dist/src/transfer/anonymization/index.js.map +1 -0
- package/dist/src/transfer/deploy-seraphine.d.ts +13 -0
- package/dist/src/transfer/deploy-seraphine.d.ts.map +1 -0
- package/dist/src/transfer/deploy-seraphine.js +205 -0
- package/dist/src/transfer/deploy-seraphine.js.map +1 -0
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +113 -0
- package/dist/src/transfer/export.js.map +1 -0
- package/dist/src/transfer/index.d.ts +12 -0
- package/dist/src/transfer/index.d.ts.map +1 -0
- package/dist/src/transfer/index.js +31 -0
- package/dist/src/transfer/index.js.map +1 -0
- package/dist/src/transfer/ipfs/client.d.ts +31 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +74 -0
- package/dist/src/transfer/ipfs/client.js.map +1 -0
- package/dist/src/transfer/ipfs/upload.d.ts +85 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +319 -0
- package/dist/src/transfer/ipfs/upload.js.map +1 -0
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +373 -0
- package/dist/src/transfer/models/seraphine.js.map +1 -0
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +180 -0
- package/dist/src/transfer/serialization/cfp.js.map +1 -0
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +275 -0
- package/dist/src/transfer/store/discovery.js.map +1 -0
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +295 -0
- package/dist/src/transfer/store/download.js.map +1 -0
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +153 -0
- package/dist/src/transfer/store/index.js.map +1 -0
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +262 -0
- package/dist/src/transfer/store/publish.js.map +1 -0
- package/dist/src/transfer/store/registry.d.ts +58 -0
- package/dist/src/transfer/store/registry.d.ts.map +1 -0
- package/dist/src/transfer/store/registry.js +285 -0
- package/dist/src/transfer/store/registry.js.map +1 -0
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +232 -0
- package/dist/src/transfer/store/search.js.map +1 -0
- package/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
- package/dist/src/transfer/store/tests/standalone-test.d.ts.map +1 -0
- package/dist/src/transfer/store/tests/standalone-test.js +190 -0
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -0
- package/dist/src/transfer/store/types.d.ts +193 -0
- package/dist/src/transfer/store/types.d.ts.map +1 -0
- package/dist/src/transfer/store/types.js +6 -0
- package/dist/src/transfer/store/types.js.map +1 -0
- package/dist/src/transfer/test-seraphine.d.ts +6 -0
- package/dist/src/transfer/test-seraphine.d.ts.map +1 -0
- package/dist/src/transfer/test-seraphine.js +105 -0
- package/dist/src/transfer/test-seraphine.js.map +1 -0
- package/dist/src/transfer/tests/test-store.d.ts +7 -0
- package/dist/src/transfer/tests/test-store.d.ts.map +1 -0
- package/dist/src/transfer/tests/test-store.js +214 -0
- package/dist/src/transfer/tests/test-store.js.map +1 -0
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/transfer/types.js +6 -0
- package/dist/src/transfer/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seraphine Genesis Model
|
|
3
|
+
* The first Claude Flow pattern model - "Hello World" for pattern sharing
|
|
4
|
+
*
|
|
5
|
+
* Seraphine represents the foundational patterns for intelligent agent coordination.
|
|
6
|
+
* Named after the Greek "Seraphim" (burning ones), symbolizing the spark of knowledge
|
|
7
|
+
* that ignites collaborative AI intelligence.
|
|
8
|
+
*/
|
|
9
|
+
import { createCFP } from '../serialization/cfp.js';
|
|
10
|
+
/**
|
|
11
|
+
* Seraphine model version
|
|
12
|
+
*/
|
|
13
|
+
export const SERAPHINE_VERSION = '1.0.0';
|
|
14
|
+
/**
|
|
15
|
+
* Seraphine model metadata
|
|
16
|
+
*/
|
|
17
|
+
export const SERAPHINE_METADATA = {
|
|
18
|
+
name: 'seraphine-genesis',
|
|
19
|
+
displayName: 'Seraphine Genesis',
|
|
20
|
+
description: 'The foundational Claude Flow pattern model. Contains core routing patterns, complexity heuristics, and coordination trajectories for multi-agent swarms.',
|
|
21
|
+
author: {
|
|
22
|
+
id: 'claude-flow-team',
|
|
23
|
+
displayName: 'Claude Flow Team',
|
|
24
|
+
},
|
|
25
|
+
license: 'MIT',
|
|
26
|
+
tags: [
|
|
27
|
+
'genesis',
|
|
28
|
+
'foundational',
|
|
29
|
+
'routing',
|
|
30
|
+
'swarm',
|
|
31
|
+
'coordination',
|
|
32
|
+
'multi-agent',
|
|
33
|
+
'hello-world',
|
|
34
|
+
],
|
|
35
|
+
language: 'typescript',
|
|
36
|
+
framework: 'claude-flow',
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Core routing patterns for Seraphine
|
|
40
|
+
* These define how tasks are routed to appropriate agents
|
|
41
|
+
*/
|
|
42
|
+
export const SERAPHINE_ROUTING_PATTERNS = [
|
|
43
|
+
{
|
|
44
|
+
id: 'route-code-to-coder',
|
|
45
|
+
trigger: 'implement|code|write|create function|build feature',
|
|
46
|
+
action: 'spawn coder agent',
|
|
47
|
+
confidence: 0.95,
|
|
48
|
+
usageCount: 1000,
|
|
49
|
+
successRate: 0.92,
|
|
50
|
+
context: {
|
|
51
|
+
category: 'development',
|
|
52
|
+
priority: 'high',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'route-test-to-tester',
|
|
57
|
+
trigger: 'test|validate|verify|check|ensure quality',
|
|
58
|
+
action: 'spawn tester agent',
|
|
59
|
+
confidence: 0.93,
|
|
60
|
+
usageCount: 850,
|
|
61
|
+
successRate: 0.89,
|
|
62
|
+
context: {
|
|
63
|
+
category: 'quality',
|
|
64
|
+
priority: 'high',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'route-review-to-reviewer',
|
|
69
|
+
trigger: 'review|audit|analyze code|check security',
|
|
70
|
+
action: 'spawn reviewer agent',
|
|
71
|
+
confidence: 0.91,
|
|
72
|
+
usageCount: 720,
|
|
73
|
+
successRate: 0.87,
|
|
74
|
+
context: {
|
|
75
|
+
category: 'quality',
|
|
76
|
+
priority: 'medium',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'route-research-to-researcher',
|
|
81
|
+
trigger: 'research|investigate|explore|find|search codebase',
|
|
82
|
+
action: 'spawn researcher agent',
|
|
83
|
+
confidence: 0.94,
|
|
84
|
+
usageCount: 680,
|
|
85
|
+
successRate: 0.91,
|
|
86
|
+
context: {
|
|
87
|
+
category: 'discovery',
|
|
88
|
+
priority: 'medium',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'route-architecture-to-architect',
|
|
93
|
+
trigger: 'design|architect|plan structure|refactor system',
|
|
94
|
+
action: 'spawn architect agent',
|
|
95
|
+
confidence: 0.88,
|
|
96
|
+
usageCount: 420,
|
|
97
|
+
successRate: 0.85,
|
|
98
|
+
context: {
|
|
99
|
+
category: 'design',
|
|
100
|
+
priority: 'high',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
id: 'route-complex-to-swarm',
|
|
105
|
+
trigger: 'complex task|multi-file|feature implementation|major refactor',
|
|
106
|
+
action: 'initialize hierarchical swarm',
|
|
107
|
+
confidence: 0.87,
|
|
108
|
+
usageCount: 350,
|
|
109
|
+
successRate: 0.82,
|
|
110
|
+
context: {
|
|
111
|
+
category: 'coordination',
|
|
112
|
+
priority: 'critical',
|
|
113
|
+
agentCount: 5,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 'route-security-to-auditor',
|
|
118
|
+
trigger: 'security|vulnerability|CVE|threat|penetration',
|
|
119
|
+
action: 'spawn security-architect agent',
|
|
120
|
+
confidence: 0.96,
|
|
121
|
+
usageCount: 280,
|
|
122
|
+
successRate: 0.94,
|
|
123
|
+
context: {
|
|
124
|
+
category: 'security',
|
|
125
|
+
priority: 'critical',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'route-performance-to-optimizer',
|
|
130
|
+
trigger: 'optimize|performance|speed|memory|benchmark',
|
|
131
|
+
action: 'spawn performance-engineer agent',
|
|
132
|
+
confidence: 0.89,
|
|
133
|
+
usageCount: 310,
|
|
134
|
+
successRate: 0.86,
|
|
135
|
+
context: {
|
|
136
|
+
category: 'optimization',
|
|
137
|
+
priority: 'high',
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
/**
|
|
142
|
+
* Complexity heuristics for Seraphine
|
|
143
|
+
* These help estimate task complexity for resource allocation
|
|
144
|
+
*/
|
|
145
|
+
export const SERAPHINE_COMPLEXITY_PATTERNS = [
|
|
146
|
+
{
|
|
147
|
+
id: 'complexity-single-file',
|
|
148
|
+
pattern: 'single file modification',
|
|
149
|
+
complexity: 1,
|
|
150
|
+
tokens: 500,
|
|
151
|
+
frequency: 0.45,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: 'complexity-multi-file',
|
|
155
|
+
pattern: 'multiple file changes (2-5 files)',
|
|
156
|
+
complexity: 3,
|
|
157
|
+
tokens: 2000,
|
|
158
|
+
frequency: 0.35,
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: 'complexity-feature',
|
|
162
|
+
pattern: 'new feature implementation',
|
|
163
|
+
complexity: 5,
|
|
164
|
+
tokens: 5000,
|
|
165
|
+
frequency: 0.12,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: 'complexity-refactor',
|
|
169
|
+
pattern: 'system-wide refactoring',
|
|
170
|
+
complexity: 8,
|
|
171
|
+
tokens: 10000,
|
|
172
|
+
frequency: 0.05,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: 'complexity-migration',
|
|
176
|
+
pattern: 'major version migration',
|
|
177
|
+
complexity: 10,
|
|
178
|
+
tokens: 20000,
|
|
179
|
+
frequency: 0.03,
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
/**
|
|
183
|
+
* Coverage patterns for Seraphine
|
|
184
|
+
* These track knowledge domain coverage
|
|
185
|
+
*/
|
|
186
|
+
export const SERAPHINE_COVERAGE_PATTERNS = [
|
|
187
|
+
{
|
|
188
|
+
id: 'coverage-typescript',
|
|
189
|
+
domain: 'TypeScript Development',
|
|
190
|
+
coverage: 0.92,
|
|
191
|
+
gaps: ['advanced generics', 'decorators'],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: 'coverage-testing',
|
|
195
|
+
domain: 'Testing & QA',
|
|
196
|
+
coverage: 0.88,
|
|
197
|
+
gaps: ['e2e testing', 'visual regression'],
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
id: 'coverage-security',
|
|
201
|
+
domain: 'Security Analysis',
|
|
202
|
+
coverage: 0.85,
|
|
203
|
+
gaps: ['supply chain', 'zero-day detection'],
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: 'coverage-swarm',
|
|
207
|
+
domain: 'Multi-Agent Coordination',
|
|
208
|
+
coverage: 0.90,
|
|
209
|
+
gaps: ['byzantine consensus', 'network partitions'],
|
|
210
|
+
},
|
|
211
|
+
];
|
|
212
|
+
/**
|
|
213
|
+
* Trajectory patterns for Seraphine
|
|
214
|
+
* These capture successful task execution paths
|
|
215
|
+
*/
|
|
216
|
+
export const SERAPHINE_TRAJECTORY_PATTERNS = [
|
|
217
|
+
{
|
|
218
|
+
id: 'traj-bug-fix',
|
|
219
|
+
steps: [
|
|
220
|
+
'research: identify bug location',
|
|
221
|
+
'coder: implement fix',
|
|
222
|
+
'tester: write regression test',
|
|
223
|
+
'reviewer: verify fix quality',
|
|
224
|
+
],
|
|
225
|
+
outcome: 'success',
|
|
226
|
+
duration: 1800000, // 30 minutes
|
|
227
|
+
learnings: [
|
|
228
|
+
'Always add regression test for bug fixes',
|
|
229
|
+
'Review similar code for same bug pattern',
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: 'traj-feature-impl',
|
|
234
|
+
steps: [
|
|
235
|
+
'architect: design feature structure',
|
|
236
|
+
'researcher: analyze existing patterns',
|
|
237
|
+
'coder: implement feature',
|
|
238
|
+
'tester: write comprehensive tests',
|
|
239
|
+
'reviewer: security and quality review',
|
|
240
|
+
'coder: address review feedback',
|
|
241
|
+
],
|
|
242
|
+
outcome: 'success',
|
|
243
|
+
duration: 7200000, // 2 hours
|
|
244
|
+
learnings: [
|
|
245
|
+
'Design before implementation reduces rework',
|
|
246
|
+
'Parallel testing accelerates delivery',
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: 'traj-refactor',
|
|
251
|
+
steps: [
|
|
252
|
+
'researcher: map affected code',
|
|
253
|
+
'architect: plan refactoring strategy',
|
|
254
|
+
'tester: ensure test coverage exists',
|
|
255
|
+
'coder: incremental refactoring',
|
|
256
|
+
'tester: verify no regressions',
|
|
257
|
+
'reviewer: architectural review',
|
|
258
|
+
],
|
|
259
|
+
outcome: 'success',
|
|
260
|
+
duration: 10800000, // 3 hours
|
|
261
|
+
learnings: [
|
|
262
|
+
'Test coverage before refactoring is critical',
|
|
263
|
+
'Small incremental changes are safer',
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
id: 'traj-security-audit',
|
|
268
|
+
steps: [
|
|
269
|
+
'security-architect: threat modeling',
|
|
270
|
+
'researcher: dependency analysis',
|
|
271
|
+
'security-auditor: code scanning',
|
|
272
|
+
'coder: remediation',
|
|
273
|
+
'security-architect: verification',
|
|
274
|
+
],
|
|
275
|
+
outcome: 'success',
|
|
276
|
+
duration: 14400000, // 4 hours
|
|
277
|
+
learnings: [
|
|
278
|
+
'Automated scanning catches common issues',
|
|
279
|
+
'Manual review needed for logic flaws',
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
];
|
|
283
|
+
/**
|
|
284
|
+
* Custom patterns for Seraphine
|
|
285
|
+
* These are specialized patterns unique to Seraphine
|
|
286
|
+
*/
|
|
287
|
+
export const SERAPHINE_CUSTOM_PATTERNS = [
|
|
288
|
+
{
|
|
289
|
+
id: 'custom-swarm-topology',
|
|
290
|
+
type: 'topology-recommendation',
|
|
291
|
+
data: {
|
|
292
|
+
taskType: 'feature-implementation',
|
|
293
|
+
recommendedTopology: 'hierarchical',
|
|
294
|
+
agentRoles: ['coordinator', 'architect', 'coder', 'tester', 'reviewer'],
|
|
295
|
+
communicationPattern: 'hub-spoke',
|
|
296
|
+
},
|
|
297
|
+
metadata: {
|
|
298
|
+
confidence: 0.89,
|
|
299
|
+
source: 'production-data',
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
id: 'custom-memory-strategy',
|
|
304
|
+
type: 'memory-optimization',
|
|
305
|
+
data: {
|
|
306
|
+
pattern: 'vector-search-first',
|
|
307
|
+
hnswParams: { m: 16, efConstruction: 200 },
|
|
308
|
+
cacheStrategy: 'lru-with-embedding',
|
|
309
|
+
},
|
|
310
|
+
metadata: {
|
|
311
|
+
speedup: '150x',
|
|
312
|
+
memoryReduction: '60%',
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
id: 'custom-hello-world',
|
|
317
|
+
type: 'greeting',
|
|
318
|
+
data: {
|
|
319
|
+
message: 'Hello, World! Welcome to Claude Flow pattern sharing.',
|
|
320
|
+
version: SERAPHINE_VERSION,
|
|
321
|
+
genesis: true,
|
|
322
|
+
},
|
|
323
|
+
metadata: {
|
|
324
|
+
significance: 'First pattern ever exported via transfer hook system',
|
|
325
|
+
timestamp: new Date().toISOString(),
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
];
|
|
329
|
+
/**
|
|
330
|
+
* Create the complete Seraphine pattern collection
|
|
331
|
+
*/
|
|
332
|
+
export function createSeraphinePatterns() {
|
|
333
|
+
return {
|
|
334
|
+
routing: SERAPHINE_ROUTING_PATTERNS,
|
|
335
|
+
complexity: SERAPHINE_COMPLEXITY_PATTERNS,
|
|
336
|
+
coverage: SERAPHINE_COVERAGE_PATTERNS,
|
|
337
|
+
trajectory: SERAPHINE_TRAJECTORY_PATTERNS,
|
|
338
|
+
custom: SERAPHINE_CUSTOM_PATTERNS,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Create the Seraphine Genesis CFP document
|
|
343
|
+
*/
|
|
344
|
+
export function createSeraphineGenesis() {
|
|
345
|
+
return createCFP({
|
|
346
|
+
name: SERAPHINE_METADATA.name,
|
|
347
|
+
description: SERAPHINE_METADATA.description,
|
|
348
|
+
patterns: createSeraphinePatterns(),
|
|
349
|
+
author: SERAPHINE_METADATA.author,
|
|
350
|
+
license: SERAPHINE_METADATA.license,
|
|
351
|
+
tags: SERAPHINE_METADATA.tags,
|
|
352
|
+
language: SERAPHINE_METADATA.language,
|
|
353
|
+
framework: SERAPHINE_METADATA.framework,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Get Seraphine model info
|
|
358
|
+
*/
|
|
359
|
+
export function getSeraphineInfo() {
|
|
360
|
+
return {
|
|
361
|
+
name: SERAPHINE_METADATA.displayName,
|
|
362
|
+
version: SERAPHINE_VERSION,
|
|
363
|
+
description: SERAPHINE_METADATA.description,
|
|
364
|
+
patternCounts: {
|
|
365
|
+
routing: SERAPHINE_ROUTING_PATTERNS.length,
|
|
366
|
+
complexity: SERAPHINE_COMPLEXITY_PATTERNS.length,
|
|
367
|
+
coverage: SERAPHINE_COVERAGE_PATTERNS.length,
|
|
368
|
+
trajectory: SERAPHINE_TRAJECTORY_PATTERNS.length,
|
|
369
|
+
custom: SERAPHINE_CUSTOM_PATTERNS.length,
|
|
370
|
+
},
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=seraphine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seraphine.js","sourceRoot":"","sources":["../../../../src/transfer/models/seraphine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,0JAA0J;IACvK,MAAM,EAAE;QACN,EAAE,EAAE,kBAAkB;QACtB,WAAW,EAAE,kBAAkB;KAChC;IACD,OAAO,EAAE,KAAK;IACd,IAAI,EAAE;QACJ,SAAS;QACT,cAAc;QACd,SAAS;QACT,OAAO;QACP,cAAc;QACd,aAAa;QACb,aAAa;KACd;IACD,QAAQ,EAAE,YAAY;IACtB,SAAS,EAAE,aAAa;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAqB;IAC1D;QACE,EAAE,EAAE,qBAAqB;QACzB,OAAO,EAAE,oDAAoD;QAC7D,MAAM,EAAE,mBAAmB;QAC3B,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,IAAI;QACjB,OAAO,EAAE;YACP,QAAQ,EAAE,aAAa;YACvB,QAAQ,EAAE,MAAM;SACjB;KACF;IACD;QACE,EAAE,EAAE,sBAAsB;QAC1B,OAAO,EAAE,2CAA2C;QACpD,MAAM,EAAE,oBAAoB;QAC5B,UAAU,EA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C;AAEF;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,OAAO,EAAE,0BAA0B;QACnC,UAAU,EAAE,6BAA6B;QACzC,QAAQ,EAAE,2BAA2B;QACrC,UAAU,EAAE,6BAA6B;QACzC,MAAM,EAAE,yBAAyB;KAClC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,SAAS,CAAC;QACf,IAAI,EAAE,kBAAkB,CAAC,IAAI;QAC7B,WAAW,EAAE,kBAAkB,CAAC,WAAW;QAC3C,QAAQ,EAAE,uBAAuB,EAAE;QACnC,MAAM,EAAE,kBAAkB,CAAC,MAAM;QACjC,OAAO,EAAE,kBAAkB,CAAC,OAAO;QACnC,IAAI,EAAE,kBAAkB,CAAC,IAAI;QAC7B,QAAQ,EAAE,kBAAkB,CAAC,QAAQ;QACrC,SAAS,EAAE,kBAAkB,CAAC,SAAS;KACxC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAM9B,OAAO;QACL,IAAI,EAAE,kBAAkB,CAAC,WAAW;QACpC,OAAO,EAAE,iBAAiB;QAC1B,WAAW,EAAE,kBAAkB,CAAC,WAAW;QAC3C,aAAa,EAAE;YACb,OAAO,EAAE,0BAA0B,CAAC,MAAM;YAC1C,UAAU,EAAE,6BAA6B,CAAC,MAAM;YAChD,QAAQ,EAAE,2BAA2B,CAAC,MAAM;YAC5C,UAAU,EAAE,6BAA6B,CAAC,MAAM;YAChD,MAAM,EAAE,yBAAyB,CAAC,MAAM;SACzC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CFP Format Serializer
|
|
3
|
+
* Claude Flow Pattern format serialization
|
|
4
|
+
*/
|
|
5
|
+
import type { CFPFormat, SerializationFormat, PatternCollection } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Create a new CFP document
|
|
8
|
+
*/
|
|
9
|
+
export declare function createCFP(options: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
patterns: PatternCollection;
|
|
13
|
+
author?: {
|
|
14
|
+
id: string;
|
|
15
|
+
displayName?: string;
|
|
16
|
+
};
|
|
17
|
+
license?: string;
|
|
18
|
+
tags?: string[];
|
|
19
|
+
language?: string;
|
|
20
|
+
framework?: string;
|
|
21
|
+
}): CFPFormat;
|
|
22
|
+
/**
|
|
23
|
+
* Serialize CFP to JSON string
|
|
24
|
+
*/
|
|
25
|
+
export declare function serializeToJson(cfp: CFPFormat): string;
|
|
26
|
+
/**
|
|
27
|
+
* Serialize CFP to Buffer (for CBOR/binary formats)
|
|
28
|
+
*/
|
|
29
|
+
export declare function serializeToBuffer(cfp: CFPFormat, format: SerializationFormat): Buffer;
|
|
30
|
+
/**
|
|
31
|
+
* Deserialize CFP from string/buffer
|
|
32
|
+
*/
|
|
33
|
+
export declare function deserializeCFP(data: string | Buffer): CFPFormat;
|
|
34
|
+
/**
|
|
35
|
+
* Validate CFP document
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateCFP(cfp: CFPFormat): {
|
|
38
|
+
valid: boolean;
|
|
39
|
+
errors: string[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Get file extension for format
|
|
43
|
+
*/
|
|
44
|
+
export declare function getFileExtension(format: SerializationFormat): string;
|
|
45
|
+
/**
|
|
46
|
+
* Detect format from file path
|
|
47
|
+
*/
|
|
48
|
+
export declare function detectFormat(filePath: string): SerializationFormat;
|
|
49
|
+
//# sourceMappingURL=cfp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cfp.d.ts","sourceRoot":"","sources":["../../../../src/transfer/serialization/cfp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAOrF;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,SAAS,CAwCZ;AAiCD;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAetD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAkBrF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAU/D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAuBhF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAepE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAMlE"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CFP Format Serializer
|
|
3
|
+
* Claude Flow Pattern format serialization
|
|
4
|
+
*/
|
|
5
|
+
import * as crypto from 'crypto';
|
|
6
|
+
// Version info
|
|
7
|
+
const CFP_VERSION = '1.0.0';
|
|
8
|
+
const GENERATOR = 'claude-flow@3.0.0-alpha';
|
|
9
|
+
/**
|
|
10
|
+
* Create a new CFP document
|
|
11
|
+
*/
|
|
12
|
+
export function createCFP(options) {
|
|
13
|
+
const now = new Date().toISOString();
|
|
14
|
+
const id = crypto.randomUUID();
|
|
15
|
+
return {
|
|
16
|
+
magic: 'CFP1',
|
|
17
|
+
version: CFP_VERSION,
|
|
18
|
+
createdAt: now,
|
|
19
|
+
generatedBy: GENERATOR,
|
|
20
|
+
metadata: {
|
|
21
|
+
id,
|
|
22
|
+
name: options.name,
|
|
23
|
+
description: options.description,
|
|
24
|
+
author: options.author ? {
|
|
25
|
+
id: options.author.id,
|
|
26
|
+
displayName: options.author.displayName,
|
|
27
|
+
verified: false,
|
|
28
|
+
} : undefined,
|
|
29
|
+
license: options.license || 'MIT',
|
|
30
|
+
tags: options.tags || [],
|
|
31
|
+
language: options.language,
|
|
32
|
+
framework: options.framework,
|
|
33
|
+
createdAt: now,
|
|
34
|
+
updatedAt: now,
|
|
35
|
+
},
|
|
36
|
+
anonymization: {
|
|
37
|
+
level: 'minimal',
|
|
38
|
+
appliedTransforms: [],
|
|
39
|
+
piiRedacted: false,
|
|
40
|
+
pathsStripped: false,
|
|
41
|
+
timestampsGeneralized: false,
|
|
42
|
+
checksum: '',
|
|
43
|
+
},
|
|
44
|
+
patterns: options.patterns,
|
|
45
|
+
statistics: calculateStatistics(options.patterns),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Calculate pattern statistics
|
|
50
|
+
*/
|
|
51
|
+
function calculateStatistics(patterns) {
|
|
52
|
+
const counts = {
|
|
53
|
+
routing: patterns.routing.length,
|
|
54
|
+
complexity: patterns.complexity.length,
|
|
55
|
+
coverage: patterns.coverage.length,
|
|
56
|
+
trajectory: patterns.trajectory.length,
|
|
57
|
+
custom: patterns.custom.length,
|
|
58
|
+
};
|
|
59
|
+
const total = Object.values(counts).reduce((a, b) => a + b, 0);
|
|
60
|
+
// Calculate average confidence from routing patterns
|
|
61
|
+
const confidences = patterns.routing.map(p => p.confidence);
|
|
62
|
+
const avgConfidence = confidences.length > 0
|
|
63
|
+
? confidences.reduce((a, b) => a + b, 0) / confidences.length
|
|
64
|
+
: 0;
|
|
65
|
+
return {
|
|
66
|
+
totalPatterns: total,
|
|
67
|
+
avgConfidence,
|
|
68
|
+
patternTypes: counts,
|
|
69
|
+
timeRange: {
|
|
70
|
+
start: new Date().toISOString(),
|
|
71
|
+
end: new Date().toISOString(),
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Serialize CFP to JSON string
|
|
77
|
+
*/
|
|
78
|
+
export function serializeToJson(cfp) {
|
|
79
|
+
// Calculate checksum before serialization
|
|
80
|
+
const content = JSON.stringify({
|
|
81
|
+
magic: cfp.magic,
|
|
82
|
+
version: cfp.version,
|
|
83
|
+
metadata: cfp.metadata,
|
|
84
|
+
patterns: cfp.patterns,
|
|
85
|
+
});
|
|
86
|
+
cfp.anonymization.checksum = crypto
|
|
87
|
+
.createHash('sha256')
|
|
88
|
+
.update(content)
|
|
89
|
+
.digest('hex');
|
|
90
|
+
return JSON.stringify(cfp, null, 2);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Serialize CFP to Buffer (for CBOR/binary formats)
|
|
94
|
+
*/
|
|
95
|
+
export function serializeToBuffer(cfp, format) {
|
|
96
|
+
// For now, just use JSON - in production, would use cbor-x or msgpack
|
|
97
|
+
const json = serializeToJson(cfp);
|
|
98
|
+
switch (format) {
|
|
99
|
+
case 'json':
|
|
100
|
+
return Buffer.from(json, 'utf-8');
|
|
101
|
+
case 'cbor':
|
|
102
|
+
case 'cbor.gz':
|
|
103
|
+
case 'cbor.zstd':
|
|
104
|
+
case 'msgpack':
|
|
105
|
+
// Fallback to JSON for now
|
|
106
|
+
// In production: use cbor-x, msgpack-lite, etc.
|
|
107
|
+
console.warn(`Format ${format} not implemented, using JSON`);
|
|
108
|
+
return Buffer.from(json, 'utf-8');
|
|
109
|
+
default:
|
|
110
|
+
return Buffer.from(json, 'utf-8');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Deserialize CFP from string/buffer
|
|
115
|
+
*/
|
|
116
|
+
export function deserializeCFP(data) {
|
|
117
|
+
const str = typeof data === 'string' ? data : data.toString('utf-8');
|
|
118
|
+
const parsed = JSON.parse(str);
|
|
119
|
+
// Validate magic bytes
|
|
120
|
+
if (parsed.magic !== 'CFP1') {
|
|
121
|
+
throw new Error(`Invalid CFP format: expected magic 'CFP1', got '${parsed.magic}'`);
|
|
122
|
+
}
|
|
123
|
+
return parsed;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Validate CFP document
|
|
127
|
+
*/
|
|
128
|
+
export function validateCFP(cfp) {
|
|
129
|
+
const errors = [];
|
|
130
|
+
if (cfp.magic !== 'CFP1') {
|
|
131
|
+
errors.push(`Invalid magic bytes: ${cfp.magic}`);
|
|
132
|
+
}
|
|
133
|
+
if (!cfp.version) {
|
|
134
|
+
errors.push('Missing version');
|
|
135
|
+
}
|
|
136
|
+
if (!cfp.metadata?.id) {
|
|
137
|
+
errors.push('Missing metadata.id');
|
|
138
|
+
}
|
|
139
|
+
if (!cfp.patterns) {
|
|
140
|
+
errors.push('Missing patterns');
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
valid: errors.length === 0,
|
|
144
|
+
errors,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get file extension for format
|
|
149
|
+
*/
|
|
150
|
+
export function getFileExtension(format) {
|
|
151
|
+
switch (format) {
|
|
152
|
+
case 'json':
|
|
153
|
+
return '.cfp.json';
|
|
154
|
+
case 'cbor':
|
|
155
|
+
return '.cfp';
|
|
156
|
+
case 'cbor.gz':
|
|
157
|
+
return '.cfp.gz';
|
|
158
|
+
case 'cbor.zstd':
|
|
159
|
+
return '.cfp.zst';
|
|
160
|
+
case 'msgpack':
|
|
161
|
+
return '.cfp.mp';
|
|
162
|
+
default:
|
|
163
|
+
return '.cfp';
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Detect format from file path
|
|
168
|
+
*/
|
|
169
|
+
export function detectFormat(filePath) {
|
|
170
|
+
if (filePath.endsWith('.cfp.json'))
|
|
171
|
+
return 'json';
|
|
172
|
+
if (filePath.endsWith('.cfp.gz'))
|
|
173
|
+
return 'cbor.gz';
|
|
174
|
+
if (filePath.endsWith('.cfp.zst'))
|
|
175
|
+
return 'cbor.zstd';
|
|
176
|
+
if (filePath.endsWith('.cfp.mp'))
|
|
177
|
+
return 'msgpack';
|
|
178
|
+
return 'cbor';
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=cfp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cfp.js","sourceRoot":"","sources":["../../../../src/transfer/serialization/cfp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,eAAe;AACf,MAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,MAAM,SAAS,GAAG,yBAAyB,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OASzB;IACC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAE/B,OAAO;QACL,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,WAAW;QACpB,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,SAAS;QAEtB,QAAQ,EAAE;YACR,EAAE;YACF,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;gBACvB,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE;gBACrB,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW;gB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