claude-flow 3.72.2 → 3.74.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 (46) hide show
  1. package/.claude/proven-config.json +1 -1
  2. package/.claude-plugin/marketplace.json +2 -2
  3. package/README.md +29 -21
  4. package/README.zh-CN.md +69 -4
  5. package/node_modules/@claude-flow/plugin-agent-federation/package.json +5 -5
  6. package/node_modules/@claude-flow/security/dist/input-validator.d.ts +138 -106
  7. package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -1
  8. package/node_modules/@claude-flow/security/dist/input-validator.js +23 -26
  9. package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -1
  10. package/node_modules/@claude-flow/security/package.json +2 -2
  11. package/package.json +4 -4
  12. package/v3/@claude-flow/cli/README.md +29 -21
  13. package/v3/@claude-flow/cli/catalog-manifest.json +2 -2
  14. package/v3/@claude-flow/cli/dist/src/commands/agent.js +2 -0
  15. package/v3/@claude-flow/cli/dist/src/commands/doctor.js +5 -3
  16. package/v3/@claude-flow/cli/dist/src/commands/funnel.d.ts +1 -0
  17. package/v3/@claude-flow/cli/dist/src/commands/funnel.js +37 -2
  18. package/v3/@claude-flow/cli/dist/src/commands/hooks.js +16 -2
  19. package/v3/@claude-flow/cli/dist/src/commands/init.js +70 -16
  20. package/v3/@claude-flow/cli/dist/src/commands/mcp.js +15 -0
  21. package/v3/@claude-flow/cli/dist/src/commands/swarm.js +2 -0
  22. package/v3/@claude-flow/cli/dist/src/funnel/activation.d.ts +30 -0
  23. package/v3/@claude-flow/cli/dist/src/funnel/activation.js +69 -0
  24. package/v3/@claude-flow/cli/dist/src/funnel/events.js +4 -1
  25. package/v3/@claude-flow/cli/dist/src/funnel/index.d.ts +2 -1
  26. package/v3/@claude-flow/cli/dist/src/funnel/index.js +2 -1
  27. package/v3/@claude-flow/cli/dist/src/funnel/message-transport.d.ts +12 -0
  28. package/v3/@claude-flow/cli/dist/src/funnel/message-transport.js +23 -1
  29. package/v3/@claude-flow/cli/dist/src/funnel/types.d.ts +2 -2
  30. package/v3/@claude-flow/cli/dist/src/init/first-win.d.ts +24 -0
  31. package/v3/@claude-flow/cli/dist/src/init/first-win.js +97 -0
  32. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.js +2 -0
  33. package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +17 -0
  34. package/v3/@claude-flow/cli/dist/src/mcp-tools/metaharness-tools.js +19 -0
  35. package/v3/@claude-flow/cli/dist/src/mcp-tools/swarm-tools.js +2 -0
  36. package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.d.ts +2 -0
  37. package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.js +1 -1
  38. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.d.ts +2 -0
  39. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +1 -1
  40. package/v3/@claude-flow/cli/dist/src/metaharness/darwin-lib.d.ts +68 -0
  41. package/v3/@claude-flow/cli/dist/src/metaharness/darwin-lib.js +150 -0
  42. package/v3/@claude-flow/cli/dist/src/transfer/store/download.d.ts +1 -1
  43. package/v3/@claude-flow/cli/dist/src/transfer/store/download.js +22 -21
  44. package/v3/@claude-flow/cli/dist/src/transfer/store/publish.d.ts +1 -1
  45. package/v3/@claude-flow/cli/dist/src/transfer/store/publish.js +13 -14
  46. package/v3/@claude-flow/cli/package.json +10 -10
@@ -0,0 +1,150 @@
1
+ /**
2
+ * In-process access to @metaharness/darwin (ADR-526).
3
+ *
4
+ * darwin is a regular dependency of the CLI, so the long-lived MCP server can
5
+ * import it once and answer `metaharness_bench --op verify` and every
6
+ * `metaharness_gepa` op without spawning `node bench.mjs` → `node darwin/cli.js`
7
+ * per call. Each function returns the same {exitCode, json} pair the plugin
8
+ * script would have produced, so callers keep the existing
9
+ * {success, data, degraded, exitCode} contract.
10
+ *
11
+ * Graceful degradation (ADR-150 rule 3) still holds: if the import fails, every
12
+ * function returns null and the caller falls back to the subprocess path.
13
+ */
14
+ import { existsSync, readFileSync } from 'node:fs';
15
+ import { resolve } from 'node:path';
16
+ // The specifiers are held in variables so a missing package degrades at
17
+ // runtime instead of failing the CLI's own type-check or bundling.
18
+ const ROOT_SPEC = '@metaharness/darwin';
19
+ const GEPA_SPEC = '@metaharness/darwin/gepa';
20
+ let rootPromise = null;
21
+ let gepaPromise = null;
22
+ export function loadDarwin() {
23
+ rootPromise ??= import(ROOT_SPEC).then((m) => m, () => null);
24
+ return rootPromise;
25
+ }
26
+ export function loadDarwinGepa() {
27
+ gepaPromise ??= import(GEPA_SPEC).then((m) => m, () => null);
28
+ return gepaPromise;
29
+ }
30
+ /** Test hook: forget the cached modules. */
31
+ export function resetDarwinCache() {
32
+ rootPromise = null;
33
+ gepaPromise = null;
34
+ }
35
+ /**
36
+ * `bench verify <suite>` in-process. Mirrors plugins/ruflo-metaharness/scripts/bench.mjs:
37
+ * exit 2 + no payload for a missing path, exit 1 when the suite fails to load
38
+ * (darwin's loadSuite throws on tamper) or its hash does not match, exit 0 otherwise.
39
+ * Returns null when darwin cannot be imported.
40
+ */
41
+ export async function benchVerify(suitePath) {
42
+ const darwin = await loadDarwin();
43
+ if (!darwin)
44
+ return null;
45
+ if (!suitePath || !existsSync(resolve(suitePath)))
46
+ return { exitCode: 2, json: null };
47
+ const start = Date.now();
48
+ const file = resolve(suitePath);
49
+ try {
50
+ const suite = await darwin.bench.loadSuite(file);
51
+ const check = darwin.bench.verifySuite(suite);
52
+ const tasks = Array.isArray(suite.tasks) ? suite.tasks.length : 0;
53
+ const data = {
54
+ op: 'verify',
55
+ suiteId: suite.id,
56
+ version: suite.version,
57
+ tasks,
58
+ hashOk: check.ok,
59
+ hash: check.actual,
60
+ // Same line the darwin CLI prints, so readers of the old shape keep working.
61
+ stdoutTail: `Suite ${suite.id}@${suite.version}: ${tasks} tasks, hash ${check.ok ? 'OK' : 'MISMATCH'} (${String(check.actual).slice(0, 12)}…)\n`,
62
+ durationMs: Date.now() - start,
63
+ };
64
+ return { exitCode: check.ok ? 0 : 1, json: { success: check.ok, data, generatedAt: new Date().toISOString() } };
65
+ }
66
+ catch (e) {
67
+ const data = { op: 'verify', error: e instanceof Error ? e.message : String(e), durationMs: Date.now() - start };
68
+ return { exitCode: 1, json: { success: false, data, generatedAt: new Date().toISOString() } };
69
+ }
70
+ }
71
+ const GEPA_OPS = ['genome', 'validate', 'render', 'analyze'];
72
+ function readJson(path) {
73
+ try {
74
+ return { ok: true, value: JSON.parse(readFileSync(path, 'utf8')) };
75
+ }
76
+ catch {
77
+ return { ok: false };
78
+ }
79
+ }
80
+ /**
81
+ * GEPA genome ops in-process. Mirrors plugins/ruflo-metaharness/scripts/gepa.mjs,
82
+ * including its exit codes: 2 for input errors (no payload), 1 for an invalid
83
+ * genome with alertOnInvalid, 0 otherwise. Returns null when darwin/gepa cannot
84
+ * be imported.
85
+ */
86
+ export async function gepaOp(input) {
87
+ if (!GEPA_OPS.includes(input.op))
88
+ return { exitCode: 2, json: null };
89
+ const gepa = await loadDarwinGepa();
90
+ if (!gepa)
91
+ return null;
92
+ const start = Date.now();
93
+ let out;
94
+ try {
95
+ const loadGenome = () => {
96
+ if (input.path) {
97
+ if (!existsSync(input.path))
98
+ return null;
99
+ return { genome: gepa.loadGenome(readFileSync, input.path), source: input.path };
100
+ }
101
+ return { genome: gepa.loadCand6Genome(), source: gepa.CAND6_GENOME_PATH };
102
+ };
103
+ if (input.op === 'genome') {
104
+ const loaded = loadGenome();
105
+ if (!loaded)
106
+ return { exitCode: 2, json: null };
107
+ const errors = gepa.validateGenome(loaded.genome);
108
+ out = { op: 'genome', source: loaded.source, valid: errors.length === 0, errors, genome: loaded.genome };
109
+ }
110
+ else if (input.op === 'validate') {
111
+ let raw;
112
+ if (input.path) {
113
+ if (!existsSync(input.path))
114
+ return { exitCode: 2, json: null };
115
+ const r = readJson(input.path);
116
+ if (!r.ok)
117
+ return { exitCode: 2, json: null };
118
+ raw = r.value;
119
+ }
120
+ else {
121
+ raw = gepa.loadCand6Genome();
122
+ }
123
+ const errors = gepa.validateGenome(raw);
124
+ out = { op: 'validate', source: input.path ?? gepa.CAND6_GENOME_PATH, valid: errors.length === 0, errors };
125
+ }
126
+ else if (input.op === 'render') {
127
+ const loaded = loadGenome();
128
+ if (!loaded)
129
+ return { exitCode: 2, json: null };
130
+ const system = gepa.buildSystemFromGenome(loaded.genome, input.ext, input.glob);
131
+ out = { op: 'render', source: loaded.source, chars: system.length, system };
132
+ }
133
+ else {
134
+ if (!input.transcript || !existsSync(input.transcript))
135
+ return { exitCode: 2, json: null };
136
+ const r = readJson(input.transcript);
137
+ if (!r.ok || !Array.isArray(r.value))
138
+ return { exitCode: 2, json: null };
139
+ out = { op: 'analyze', source: input.transcript, entries: r.value.length, analysis: gepa.analyzeTranscript(r.value) };
140
+ }
141
+ }
142
+ catch {
143
+ // gepa.mjs exits 2 on any thrown error (its main().catch handler).
144
+ return { exitCode: 2, json: null };
145
+ }
146
+ out.durationMs = Date.now() - start;
147
+ const exitCode = input.alertOnInvalid && out.valid === false ? 1 : 0;
148
+ return { exitCode, json: out };
149
+ }
150
+ //# sourceMappingURL=darwin-lib.js.map
@@ -36,7 +36,7 @@ export declare class PatternDownloader {
36
36
  */
37
37
  private verifyChecksum;
38
38
  /**
39
- * Verify content signature using crypto
39
+ * Verify an Ed25519 signature over the content. Any error is a failure.
40
40
  */
41
41
  private verifySignature;
42
42
  /**
@@ -75,15 +75,20 @@ export class PatternDownloader {
75
75
  console.log(`[Download] Checksum verified!`);
76
76
  }
77
77
  }
78
- // Verify signature if available
78
+ // Verify signature if available. A pattern that carries a signature
79
+ // which does not verify is refused rather than written.
79
80
  if (pattern.signature && pattern.publicKey) {
80
- const sigVerified = this.verifySignature(content, pattern.signature, pattern.publicKey);
81
+ const sigVerified = await this.verifySignature(content, pattern.signature, pattern.publicKey);
81
82
  if (!sigVerified) {
82
- console.warn(`[Download] Warning: Signature verification failed!`);
83
- }
84
- else {
85
- console.log(`[Download] Signature verified!`);
83
+ console.warn(`[Download] Signature verification failed, not writing the pattern.`);
84
+ return {
85
+ success: false,
86
+ pattern,
87
+ verified: false,
88
+ size: content.length,
89
+ };
86
90
  }
91
+ console.log(`[Download] Signature verified!`);
87
92
  }
88
93
  // Write to file
89
94
  fs.writeFileSync(outputPath, content);
@@ -228,28 +233,24 @@ export class PatternDownloader {
228
233
  return actualChecksum === expectedChecksum;
229
234
  }
230
235
  /**
231
- * Verify content signature using crypto
236
+ * Verify an Ed25519 signature over the content. Any error is a failure.
232
237
  */
233
- verifySignature(content, signature, publicKey) {
234
- // Check signature format
238
+ async verifySignature(content, signature, publicKey) {
235
239
  if (!signature.startsWith('ed25519:') || !publicKey.startsWith('ed25519:')) {
236
240
  return false;
237
241
  }
238
242
  try {
239
- // For HMAC-based signatures (used in publish.ts)
240
- const sigHex = signature.replace('ed25519:', '');
241
- const keyHex = publicKey.replace('ed25519:', '');
242
- // Verify HMAC signature
243
- const expectedSig = crypto
244
- .createHmac('sha256', keyHex)
245
- .update(content)
246
- .digest('hex');
247
- // Constant-time comparison to prevent timing attacks
248
- return crypto.timingSafeEqual(Buffer.from(sigHex, 'hex'), Buffer.from(expectedSig, 'hex'));
243
+ const ed = await import('@noble/ed25519');
244
+ const sigBytes = Buffer.from(signature.slice('ed25519:'.length), 'hex');
245
+ const pubBytes = Buffer.from(publicKey.slice('ed25519:'.length), 'hex');
246
+ if (sigBytes.length !== 64 || pubBytes.length !== 32) {
247
+ return false;
248
+ }
249
+ // RFC 8032 strict mode, as in transfer/ipfs/client.ts.
250
+ return await ed.verifyAsync(sigBytes, content, pubBytes, { zip215: false });
249
251
  }
250
252
  catch {
251
- // If crypto verification fails, check basic format
252
- return signature.length > 20 && publicKey.length > 20;
253
+ return false;
253
254
  }
254
255
  }
255
256
  /**
@@ -16,7 +16,7 @@ export declare class PatternPublisher {
16
16
  */
17
17
  publishPattern(cfp: CFPFormat, options: PublishOptions): Promise<PublishResult>;
18
18
  /**
19
- * Sign content with private key
19
+ * Sign content with Ed25519. The private key file holds a 32-byte hex seed.
20
20
  */
21
21
  private signContent;
22
22
  /**
@@ -37,7 +37,7 @@ export class PatternPublisher {
37
37
  let signature;
38
38
  let publicKey;
39
39
  if (options.privateKeyPath && fs.existsSync(options.privateKeyPath)) {
40
- const signResult = this.signContent(contentBuffer, options.privateKeyPath);
40
+ const signResult = await this.signContent(contentBuffer, options.privateKeyPath);
41
41
  signature = signResult.signature;
42
42
  publicKey = signResult.publicKey;
43
43
  console.log(`[Publish] Content signed`);
@@ -148,21 +148,20 @@ export class PatternPublisher {
148
148
  }
149
149
  }
150
150
  /**
151
- * Sign content with private key
151
+ * Sign content with Ed25519. The private key file holds a 32-byte hex seed.
152
152
  */
153
- signContent(content, privateKeyPath) {
154
- // In production: Use actual Ed25519 signing
155
- // For demo: Generate mock signature
156
- const privateKey = fs.readFileSync(privateKeyPath, 'utf-8').trim();
157
- const signature = crypto
158
- .createHmac('sha256', privateKey)
159
- .update(content)
160
- .digest('hex');
161
- const publicKey = 'ed25519:' +
162
- crypto.createHash('sha256').update(privateKey).digest('hex').slice(0, 32);
153
+ async signContent(content, privateKeyPath) {
154
+ const ed = await import('@noble/ed25519');
155
+ const raw = fs.readFileSync(privateKeyPath, 'utf-8').trim();
156
+ const seed = Buffer.from(raw, 'hex');
157
+ if (seed.length !== 32 || seed.toString('hex') !== raw.toLowerCase()) {
158
+ throw new Error(`[Publish] Ed25519 private key at ${privateKeyPath} must be a 32-byte hex seed.`);
159
+ }
160
+ const pub = await ed.getPublicKeyAsync(seed);
161
+ const sig = await ed.signAsync(content, seed);
163
162
  return {
164
- signature: `ed25519:${signature}`,
165
- publicKey,
163
+ signature: 'ed25519:' + Buffer.from(sig).toString('hex'),
164
+ publicKey: 'ed25519:' + Buffer.from(pub).toString('hex'),
166
165
  };
167
166
  }
168
167
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.72.2",
3
+ "version": "3.74.0",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",
@@ -101,16 +101,18 @@
101
101
  },
102
102
  "dependencies": {
103
103
  "@electron/asar": "^4.3.1",
104
- "@claude-flow/cli-core": "3.7.5",
104
+ "@claude-flow/cli-core": "3.7.6",
105
105
  "@claude-flow/codex": "3.0.6",
106
106
  "@claude-flow/mcp": "3.1.6",
107
107
  "@claude-flow/neural": "3.0.3",
108
- "@claude-flow/plugin-agent-federation": "1.0.5",
109
- "@claude-flow/security": "3.0.6",
108
+ "@claude-flow/plugin-agent-federation": "1.0.7",
109
+ "@claude-flow/security": "3.0.7",
110
110
  "@claude-flow/shared": "3.0.7",
111
111
  "@iarna/toml": "^2.2.5",
112
+ "@metaharness/darwin": "~0.13.0",
112
113
  "@noble/ed25519": "2.3.0",
113
114
  "@ruvector/rabitq-wasm": "0.1.2",
115
+ "agentic-flow": "^3.0.0",
114
116
  "ajv": "^8.20.0",
115
117
  "bcryptjs": "^3.0.3",
116
118
  "chalk": "^5.3.0",
@@ -128,19 +130,17 @@
128
130
  "ws": "^8.21.0",
129
131
  "yaml": "^2.8.0",
130
132
  "zod": "^3.22.0",
131
- "@claude-flow/memory": "3.2.3"
133
+ "@claude-flow/memory": "3.2.5"
132
134
  },
133
135
  "optionalDependencies": {
134
136
  "@agntcy/slim-bindings": "2.1.1",
135
- "@claude-flow/aidefence": "3.1.0",
136
- "@claude-flow/memory": "3.2.3",
137
- "@metaharness/darwin": "~0.13.0",
137
+ "@claude-flow/aidefence": "3.1.1",
138
+ "@claude-flow/memory": "3.2.5",
138
139
  "@metaharness/flywheel": "~0.1.10",
139
140
  "@metaharness/radio": "~0.1.0",
140
141
  "@metaharness/turn-credit": "~0.1.0",
141
142
  "@napi-rs/keyring": "1.3.0",
142
- "agentdb": "^3.3.0",
143
- "agentic-flow": "^3.0.0",
143
+ "agentdb": "^3.6.0",
144
144
  "better-sqlite3": "^12.9.0",
145
145
  "ruvector": "^0.3.13",
146
146
  "nostr-tools": "^2.7.0",