claude-flow 3.32.1 → 3.32.2

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.
@@ -0,0 +1 @@
1
+ sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319
@@ -26,8 +26,11 @@ const { execSync } = require('child_process');
26
26
  const os = require('os');
27
27
 
28
28
  // Configuration
29
- const CONFIG = {
30
- maxAgents: 15,
29
+ const CONFIG = {
30
+ maxAgents: 15,
31
+ // Header identity defaults to project/repository name. Set `author` to
32
+ // retain the previous `git config user.name` display (#2682).
33
+ identityMode: (process.env.RUFLO_STATUSLINE_IDENTITY || 'project').toLowerCase(),
31
34
  // Session-cost display. Claude Code's cost.total_cost_usd is a client-side
32
35
  // estimate that "may differ from your actual bill" and reads as misleading on
33
36
  // subscription plans, where token usage is not billed per dollar. These let
@@ -210,7 +213,9 @@ function getStatuslineData() {
210
213
  // 60s TTL (#2337 — don't re-spawn the CLI on every rapid re-render) AND the
211
214
  // tighter promo-rotation clock (this fix — don't let a still-fresh 60s
212
215
  // cache silently freeze the promo/insight row across multiple 20s slots).
213
- if (cache.fresh && cache.promoFresh) return overlayMemoPromo(cache.data);
216
+ if (cache.fresh && cache.promoFresh) {
217
+ return applyLocalOverlays(overlayMemoPromo(cache.data));
218
+ }
214
219
 
215
220
  // #2337: prefer an already-installed CLI bin via direct `node` invocation —
216
221
  // no npx, no registry round-trip, no @latest re-resolve per render. Try
@@ -417,7 +422,7 @@ function buildLocalFallback() {
417
422
  return applyLocalOverlays({
418
423
  user: { name: 'user', gitBranch: '', modelName: 'Claude Code' },
419
424
  v3Progress: { domainsCompleted: 0, totalDomains: 5, dddProgress: 0, patternsLearned: 0, sessionsCompleted: 0 },
420
- security: { status: 'NONE', cvesFixed: 0, totalCves: 0 },
425
+ security: { status: 'NONE', findings: 0, cvesFixed: 0, totalCves: 0 },
421
426
  swarm: { activeAgents: 0, maxAgents: CONFIG.maxAgents, coordinationActive: false },
422
427
  system: { memoryMB: memMB, contextPct: 0, intelligencePct: 0, subAgents: 0 },
423
428
  lastUpdated: new Date().toISOString(),
@@ -474,14 +479,16 @@ function readJSON(filePath) {
474
479
 
475
480
  // ─── Git info (pure-Node / single exec — needed for branch display) ──────────
476
481
 
477
- function getGitInfo() {
478
- const result = {
479
- name: 'user', gitBranch: '', modified: 0, untracked: 0,
480
- staged: 0, ahead: 0, behind: 0,
481
- };
482
-
483
- const script = [
484
- 'git config user.name 2>/dev/null || echo user',
482
+ function getGitInfo() {
483
+ const result = {
484
+ name: path.basename(CWD) || 'project', gitBranch: '', modified: 0, untracked: 0,
485
+ staged: 0, ahead: 0, behind: 0,
486
+ };
487
+
488
+ const script = [
489
+ 'git rev-parse --show-toplevel 2>/dev/null || pwd',
490
+ 'echo "---SEP---"',
491
+ 'git config user.name 2>/dev/null || echo user',
485
492
  'echo "---SEP---"',
486
493
  'git branch --show-current 2>/dev/null',
487
494
  'echo "---SEP---"',
@@ -494,12 +501,14 @@ function getGitInfo() {
494
501
  if (!raw) return result;
495
502
 
496
503
  const parts = raw.split('---SEP---').map(function(s) { return s.trim(); });
497
- if (parts.length >= 4) {
498
- result.name = parts[0] || 'user';
499
- result.gitBranch = parts[1] || '';
500
-
501
- if (parts[2]) {
502
- for (const line of parts[2].split('\n')) {
504
+ if (parts.length >= 5) {
505
+ const projectName = path.basename(parts[0] || CWD) || path.basename(CWD) || 'project';
506
+ const authorName = parts[1] || 'user';
507
+ result.name = CONFIG.identityMode === 'author' ? authorName : projectName;
508
+ result.gitBranch = parts[2] || '';
509
+
510
+ if (parts[3]) {
511
+ for (const line of parts[3].split('\n')) {
503
512
  if (!line || line.length < 2) continue;
504
513
  const x = line[0], y = line[1];
505
514
  if (x === '?' && y === '?') { result.untracked++; continue; }
@@ -508,7 +517,7 @@ function getGitInfo() {
508
517
  }
509
518
  }
510
519
 
511
- const ab = (parts[3] || '0 0').split(/\s+/);
520
+ const ab = (parts[4] || '0 0').split(/\s+/);
512
521
  result.ahead = parseInt(ab[0]) || 0;
513
522
  result.behind = parseInt(ab[1]) || 0;
514
523
  }
@@ -722,8 +731,7 @@ function generateStatusline() {
722
731
  const intelligencePct = system.intelligencePct || 0;
723
732
  const memoryMB = system.memoryMB || 0;
724
733
  const subAgents = system.subAgents || 0;
725
- const cvesFixed = security.cvesFixed || 0;
726
- const totalCves = security.totalCves || 0;
734
+ const findings = Math.max(0, security.findings || 0);
727
735
  const secStatus = security.status || 'NONE';
728
736
  const adrCount = adrs.count || 0;
729
737
  const adrImpl = adrs.implemented || 0;
@@ -778,8 +786,7 @@ function generateStatusline() {
778
786
  const hooksColor = hooksEnabled > 0 ? c.brightGreen : c.dim;
779
787
  const intellColor = intelligencePct >= 80 ? c.brightGreen : intelligencePct >= 40 ? c.brightYellow : c.dim;
780
788
  const swarmInd = coordinationActive ? c.brightGreen + '◉' + c.reset + ' ' : c.dim + '○' + c.reset + ' ';
781
- const cvesClean = totalCves === 0 || cvesFixed === totalCves;
782
- const healthAllGreen = (secStatus === 'CLEAN' || secStatus === 'NONE') && cvesClean;
789
+ const healthAllGreen = (secStatus === 'CLEAN' || secStatus === 'NONE') && findings === 0;
783
790
  const opsParts = [];
784
791
  opsParts.push(c.cyan + 'Swarm ' + swarmInd + agentsColor + activeAgents + c.reset + '/' + c.brightWhite + maxAgents + c.reset);
785
792
  if (subAgents > 0) opsParts.push(c.brightPurple + '👥 ' + subAgents + c.reset);
@@ -790,14 +797,14 @@ function generateStatusline() {
790
797
  if (healthAllGreen) {
791
798
  opsParts.push(c.brightGreen + '🛡 ✓' + c.reset);
792
799
  } else {
793
- if (secStatus === 'PENDING') opsParts.push(c.brightYellow + '🛡 scan pending' + c.reset);
794
- else if (secStatus === 'IN_PROGRESS') opsParts.push(c.brightYellow + '🛡 scanning…' + c.reset);
795
- else if (secStatus === 'STALE') opsParts.push(c.brightYellow + '🛡 scan stale' + c.reset);
796
- else if (secStatus !== 'NONE' && secStatus !== 'CLEAN') opsParts.push(c.brightRed + '🛡 ' + secStatus.toLowerCase() + c.reset);
797
- if (totalCves > 0 && cvesFixed < totalCves) {
798
- const unfixed = totalCves - cvesFixed;
799
- opsParts.push(c.brightRed + '⚠ ' + unfixed + ' CVE' + (unfixed === 1 ? '' : 's') + c.reset);
800
- }
800
+ if (secStatus === 'PENDING') opsParts.push(c.brightYellow + '🛡 scan pending' + c.reset);
801
+ else if (secStatus === 'IN_PROGRESS') opsParts.push(c.brightYellow + '🛡 scanning…' + c.reset);
802
+ else if (secStatus === 'ISSUES') opsParts.push(c.brightRed + '🛡 findings' + c.reset);
803
+ else if (secStatus === 'STALE') opsParts.push(c.brightYellow + '🛡 scan stale' + c.reset);
804
+ else if (secStatus !== 'NONE' && secStatus !== 'CLEAN') opsParts.push(c.brightRed + '🛡 ' + secStatus.toLowerCase() + c.reset);
805
+ if (findings > 0) {
806
+ opsParts.push(c.brightRed + '⚠ ' + findings + ' finding' + (findings === 1 ? '' : 's') + c.reset);
807
+ }
801
808
  }
802
809
  lines.push(opsParts.join(' ' + c.dim + '·' + c.reset + ' '));
803
810
 
@@ -0,0 +1,42 @@
1
+ {
2
+ "adoptedAt": 1784256882562,
3
+ "championId": "sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319",
4
+ "manifest": {
5
+ "schema": "ruflo.proven-config/v1",
6
+ "policy": {
7
+ "ref": "sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319",
8
+ "value": {
9
+ "alpha": 0.3,
10
+ "subjectWeight": 1,
11
+ "mmrLambda": 0.5,
12
+ "bodyWeight": 1.5,
13
+ "typePenaltyFactor": 0.5
14
+ }
15
+ },
16
+ "layer": "framework/node-cli",
17
+ "compatibility": {
18
+ "ruflo": ">=3.24.0"
19
+ },
20
+ "benchmark": {
21
+ "corpus": "ADR-081-labelled-v1",
22
+ "corpusHash": "sha256:2f700b5c363e20a3bd88ce2bc9b87bbbbaa61732c6177894c6ec37890f888982"
23
+ },
24
+ "receipt": {
25
+ "heldOutDelta": 0.07381404928570845,
26
+ "redblue": "PASS",
27
+ "drift": 0,
28
+ "canary": {
29
+ "rollbackRate": 0,
30
+ "latencyP95": 244.612458000076,
31
+ "costPerTask": 0
32
+ },
33
+ "receiptCoverage": 1
34
+ },
35
+ "platform": [
36
+ "linux",
37
+ "macOS",
38
+ "windows"
39
+ ]
40
+ },
41
+ "previous": ""
42
+ }
@@ -14,7 +14,7 @@
14
14
  * Behaviour mirrors ruflo-hook.sh:
15
15
  * 1. Reads hook JSON payload from stdin.
16
16
  * 2. Prefers a locally installed `ruflo` or `claude-flow` binary.
17
- * 3. Falls back to `npx --prefer-offline ruflo@alpha`.
17
+ * 3. Falls back to `npx --prefer-offline ruflo@latest`.
18
18
  * 4. Always exits 0 — hook subcommands are best-effort telemetry.
19
19
  * 5. Swallows all stderr — nothing should surface to Claude Code.
20
20
  *
@@ -157,7 +157,7 @@ function main() {
157
157
  // a spurious failure even though the shim itself works correctly.
158
158
  // The bash version doesn't hit this because it backgrounded the work.
159
159
  if (process.env.RUFLO_HOOK_SKIP_NPX !== '1') {
160
- invokeHook('npx', ['--prefer-offline', '--yes', 'ruflo@alpha'], hookArgs, stdinData);
160
+ invokeHook('npx', ['--prefer-offline', '--yes', 'ruflo@latest'], hookArgs, stdinData);
161
161
  }
162
162
 
163
163
  done();
@@ -24,14 +24,29 @@
24
24
  # so redirecting it is a pure cleanup with no functional cost.
25
25
  exec 1>/dev/null 2>/dev/null
26
26
 
27
- run() { "$@" || true; }
27
+ # Bound every hook process. A partially initialized native embedding pool can
28
+ # otherwise keep a logically completed Stop hook alive indefinitely (#2691).
29
+ run() {
30
+ "$@" &
31
+ child=$!
32
+ (
33
+ sleep 15
34
+ kill -TERM "$child" 2>/dev/null || true
35
+ sleep 1
36
+ kill -KILL "$child" 2>/dev/null || true
37
+ ) &
38
+ watchdog=$!
39
+ wait "$child" 2>/dev/null || true
40
+ kill "$watchdog" 2>/dev/null || true
41
+ wait "$watchdog" 2>/dev/null || true
42
+ }
28
43
 
29
44
  if command -v ruflo >/dev/null 2>&1; then
30
45
  run ruflo hooks "$@"
31
46
  elif command -v claude-flow >/dev/null 2>&1; then
32
47
  run claude-flow hooks "$@"
33
48
  else
34
- run npx --prefer-offline --yes ruflo@alpha hooks "$@"
49
+ run npx --prefer-offline --yes ruflo@latest hooks "$@"
35
50
  fi
36
51
 
37
52
  exit 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.32.1",
3
+ "version": "3.32.2",
4
4
  "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "generation": 1,
4
- "generatedAt": "2026-07-16T23:50:36.870Z",
5
- "gitSha": "81447ce7",
4
+ "generatedAt": "2026-07-17T04:00:15.717Z",
5
+ "gitSha": "61047df4",
6
6
  "catalog": {
7
7
  "agents": 164,
8
8
  "tools": 387,
@@ -3487,18 +3487,26 @@ const statuslineCommand = {
3487
3487
  }
3488
3488
  // Get user info
3489
3489
  function getUserInfo() {
3490
- let name = 'user';
3490
+ const identityMode = (process.env.RUFLO_STATUSLINE_IDENTITY || 'project').toLowerCase();
3491
+ let name = path.basename(process.cwd()) || 'project';
3491
3492
  let gitBranch = '';
3492
3493
  const modelName = 'Opus 4.6 (1M context)';
3493
3494
  const isWindows = process.platform === 'win32';
3494
3495
  try {
3495
- const nameCmd = isWindows
3496
- ? 'git config user.name 2>NUL || echo user'
3497
- : 'git config user.name 2>/dev/null || echo "user"';
3496
+ const rootCmd = isWindows
3497
+ ? 'git rev-parse --show-toplevel 2>NUL'
3498
+ : 'git rev-parse --show-toplevel 2>/dev/null';
3498
3499
  const branchCmd = isWindows
3499
3500
  ? 'git branch --show-current 2>NUL || echo.'
3500
3501
  : 'git branch --show-current 2>/dev/null || echo ""';
3501
- name = execSync(nameCmd, { encoding: 'utf-8' }).trim();
3502
+ const root = execSync(rootCmd, { encoding: 'utf-8' }).trim();
3503
+ name = path.basename(root) || name;
3504
+ if (identityMode === 'author') {
3505
+ const authorCmd = isWindows
3506
+ ? 'git config user.name 2>NUL || echo user'
3507
+ : 'git config user.name 2>/dev/null || echo "user"';
3508
+ name = execSync(authorCmd, { encoding: 'utf-8' }).trim() || 'user';
3509
+ }
3502
3510
  gitBranch = execSync(branchCmd, { encoding: 'utf-8' }).trim();
3503
3511
  if (gitBranch === '.')
3504
3512
  gitBranch = '';
@@ -3555,7 +3563,10 @@ const statuslineCommand = {
3555
3563
  const terminalCols = process.stdout.columns ?? 80;
3556
3564
  const autoCompact = !ctx.flags.full && terminalCols < COMPACT_WIDTH_THRESHOLD;
3557
3565
  if (ctx.flags.compact || autoCompact) {
3558
- const line = `DDD:${progress.domainsCompleted}/${progress.totalDomains} CVE:${security.cvesFixed}/${security.totalCves} Swarm:${swarm.activeAgents}/${swarm.maxAgents} Ctx:${system.contextPct}% Int:${system.intelligencePct}%`;
3566
+ const securityCompact = security.findings > 0
3567
+ ? `Findings:${security.findings}`
3568
+ : `Security:${security.status}`;
3569
+ const line = `DDD:${progress.domainsCompleted}/${progress.totalDomains} ${securityCompact} Swarm:${swarm.activeAgents}/${swarm.maxAgents} Ctx:${system.contextPct}% Int:${system.intelligencePct}%`;
3559
3570
  output.writeln(line);
3560
3571
  return { success: true, data: statusData };
3561
3572
  }
@@ -3729,13 +3740,13 @@ const statuslineCommand = {
3729
3740
  perfIndicator;
3730
3741
  const swarmIndicator = swarm.coordinationActive ? `${c.brightGreen}◉${c.reset}` : `${c.dim}○${c.reset}`;
3731
3742
  const agentsColor = swarm.activeAgents > 0 ? c.brightGreen : c.red;
3732
- const securityIcon = security.status === 'CLEAN' ? '🟢' : security.status === 'IN_PROGRESS' ? '🟡' : '🔴';
3733
- const securityColor = security.status === 'CLEAN' ? c.brightGreen : security.status === 'IN_PROGRESS' ? c.brightYellow : c.brightRed;
3743
+ const securityIcon = security.status === 'CLEAN' ? '🟢' : security.status === 'PENDING' ? '🟡' : '🔴';
3744
+ const securityColor = security.status === 'CLEAN' ? c.brightGreen : security.status === 'PENDING' ? c.brightYellow : c.brightRed;
3734
3745
  const hooksColor = hooksStats.enabled > 0 ? c.brightGreen : c.dim;
3735
3746
  const line2 = `${c.brightYellow}🤖 Swarm${c.reset} ${swarmIndicator} [${agentsColor}${String(swarm.activeAgents).padStart(2)}${c.reset}/${c.brightWhite}${swarm.maxAgents}${c.reset}] ` +
3736
3747
  `${c.brightPurple}👥 ${system.subAgents}${c.reset} ` +
3737
3748
  `${c.brightBlue}🪝 ${hooksColor}${hooksStats.enabled}${c.reset}/${c.brightWhite}${hooksStats.total}${c.reset} ` +
3738
- `${securityIcon} ${securityColor}CVE ${security.cvesFixed}${c.reset}/${c.brightWhite}${security.totalCves}${c.reset} ` +
3749
+ `${securityIcon} ${securityColor}${security.findings > 0 ? `Findings ${security.findings}` : `Security ${security.status}`}${c.reset} ` +
3739
3750
  `${c.brightCyan}💾 ${system.memoryMB}MB${c.reset} ` +
3740
3751
  `${c.brightPurple}🧠 ${String(system.intelligencePct).padStart(3)}%${c.reset}`;
3741
3752
  const dddColor = progress.dddProgress >= 50 ? c.brightGreen : progress.dddProgress > 0 ? c.yellow : c.red;
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { output } from '../output.js';
8
8
  import { execSync } from 'node:child_process';
9
+ import { createBuiltinAIDefence } from '../security/builtin-aidefence.js';
9
10
  // Scan subcommand
10
11
  const scanCommand = {
11
12
  name: 'scan',
@@ -861,16 +862,17 @@ const defendCommand = {
861
862
  output.writeln(output.bold('🛡️ AIDefence - AI Manipulation Defense System'));
862
863
  output.writeln(output.dim('─'.repeat(55)));
863
864
  // Dynamic import of aidefence (allows package to be optional)
864
- let createAIDefence;
865
+ let defender;
865
866
  try {
866
867
  const aidefence = await import('@claude-flow/aidefence');
867
- createAIDefence = aidefence.createAIDefence;
868
+ defender = aidefence.createAIDefence({ enableLearning });
868
869
  }
869
870
  catch {
870
- output.error('AIDefence package not installed. Run: npm install @claude-flow/aidefence');
871
- return { success: false, message: 'AIDefence not available' };
871
+ // Keep cold npx startup lean (#2561): the full learning engine remains
872
+ // user-installable, while the CLI always ships a deterministic scanner.
873
+ defender = createBuiltinAIDefence();
874
+ output.writeln(output.dim('Using built-in defense engine (install @claude-flow/aidefence for adaptive learning)'));
872
875
  }
873
- const defender = createAIDefence({ enableLearning });
874
876
  // Show stats mode
875
877
  if (showStats) {
876
878
  const stats = await defender.getStats();
@@ -893,8 +895,8 @@ const defendCommand = {
893
895
  output.writeln(output.dim(`Reading file: ${filePath}`));
894
896
  }
895
897
  catch (err) {
896
- output.error(`Failed to read file: ${filePath}`);
897
- return { success: false, message: 'File not found' };
898
+ output.printError(`Failed to read file: ${filePath}`);
899
+ return { success: false, exitCode: 2, message: 'File not found' };
898
900
  }
899
901
  }
900
902
  if (!textToScan) {
@@ -914,8 +916,9 @@ const defendCommand = {
914
916
  spinner.start();
915
917
  // Perform scan
916
918
  const startTime = performance.now();
917
- const result = quickMode
918
- ? { ...defender.quickScan(textToScan), threats: [], piiFound: false, detectionTimeMs: 0, inputHash: '', safe: !defender.quickScan(textToScan).threat }
919
+ const quickResult = quickMode ? defender.quickScan(textToScan) : undefined;
920
+ const result = quickResult
921
+ ? { ...quickResult, threats: [], piiFound: false, detectionTimeMs: 0, inputHash: '', safe: !quickResult.threat }
919
922
  : await defender.detect(textToScan);
920
923
  const scanTime = performance.now() - startTime;
921
924
  spinner.stop();
@@ -927,7 +930,8 @@ const defendCommand = {
927
930
  piiFound: result.piiFound,
928
931
  detectionTimeMs: scanTime,
929
932
  }, null, 2));
930
- return { success: true };
933
+ const safe = result.safe && !result.piiFound;
934
+ return { success: safe, exitCode: safe ? 0 : 1 };
931
935
  }
932
936
  // Text output
933
937
  output.writeln();
@@ -969,7 +973,8 @@ const defendCommand = {
969
973
  }
970
974
  }
971
975
  output.writeln(output.dim(`Detection time: ${scanTime.toFixed(3)}ms`));
972
- return { success: result.safe };
976
+ const safe = result.safe && !result.piiFound;
977
+ return { success: safe, exitCode: safe ? 0 : 1 };
973
978
  },
974
979
  };
975
980
  // Main security command
@@ -30,6 +30,7 @@ export interface LocalInsight {
30
30
  export interface LocalInsightContext {
31
31
  security?: {
32
32
  status: string;
33
+ findings?: number;
33
34
  cvesFixed: number;
34
35
  totalCves: number;
35
36
  };
@@ -42,11 +42,11 @@ function securityInsight(ctx) {
42
42
  const s = ctx.security;
43
43
  if (!s)
44
44
  return null;
45
- const pending = s.totalCves - s.cvesFixed;
46
- if (pending > 0) {
45
+ const findings = Math.max(0, s.findings ?? 0);
46
+ if (s.status === 'ISSUES' || findings > 0) {
47
47
  return {
48
- id: 'insight-cves-pending',
49
- text: `⚠ ${pending} CVE${pending === 1 ? '' : 's'} pending Run ruflo security scan --depth full`,
48
+ id: 'insight-security-findings',
49
+ text: `⚠ ${findings} security finding${findings === 1 ? '' : 's'} — Review the latest ruflo security scan`,
50
50
  priority: 90,
51
51
  };
52
52
  }
@@ -1,6 +1,11 @@
1
1
  export interface SecurityStatus {
2
- status: 'CLEAN' | 'IN_PROGRESS' | 'PENDING';
2
+ status: 'CLEAN' | 'ISSUES' | 'PENDING';
3
+ /** Generic code-pattern findings from `ruflo security scan` (not CVEs). */
4
+ findings: number;
5
+ scannedAt?: string;
6
+ /** @deprecated Retained as a zero-valued compatibility field. */
3
7
  cvesFixed: number;
8
+ /** @deprecated Retained as a zero-valued compatibility field. */
4
9
  totalCves: number;
5
10
  }
6
11
  export declare function getSecurityStatus(cwd?: string): SecurityStatus;
@@ -11,30 +11,39 @@ import * as fs from 'fs';
11
11
  import * as path from 'path';
12
12
  import { execSync } from 'child_process';
13
13
  export function getSecurityStatus(cwd = process.cwd()) {
14
+ const empty = {
15
+ status: 'PENDING', findings: 0, cvesFixed: 0, totalCves: 0,
16
+ };
14
17
  const scanResultsPath = path.join(cwd, '.claude', 'security-scans');
15
- let cvesFixed = 0;
16
- const totalCves = 3;
17
- if (fs.existsSync(scanResultsPath)) {
18
- try {
19
- const scans = fs.readdirSync(scanResultsPath).filter((f) => f.endsWith('.json'));
20
- cvesFixed = Math.min(totalCves, scans.length);
21
- }
22
- catch {
23
- // Ignore
18
+ if (!fs.existsSync(scanResultsPath))
19
+ return empty;
20
+ try {
21
+ const files = fs.readdirSync(scanResultsPath).filter((f) => f.endsWith('.json'));
22
+ if (files.length === 0)
23
+ return empty;
24
+ let newest = files[0];
25
+ let newestMtime = -1;
26
+ for (const f of files) {
27
+ const st = fs.statSync(path.join(scanResultsPath, f));
28
+ if (st.mtimeMs > newestMtime) {
29
+ newestMtime = st.mtimeMs;
30
+ newest = f;
31
+ }
24
32
  }
33
+ const scan = JSON.parse(fs.readFileSync(path.join(scanResultsPath, newest), 'utf-8'));
34
+ const rawFindings = scan.summary?.total ?? scan.totalFindings ?? scan.findings?.length ?? 0;
35
+ const findings = Math.max(0, Number.isFinite(rawFindings) ? rawFindings : 0);
36
+ return {
37
+ status: findings > 0 ? 'ISSUES' : 'CLEAN',
38
+ findings,
39
+ scannedAt: typeof scan.timestamp === 'string' ? scan.timestamp : undefined,
40
+ cvesFixed: 0,
41
+ totalCves: 0,
42
+ };
25
43
  }
26
- const auditPath = path.join(cwd, '.swarm', 'security');
27
- if (fs.existsSync(auditPath)) {
28
- try {
29
- const audits = fs.readdirSync(auditPath).filter((f) => f.includes('audit'));
30
- cvesFixed = Math.min(totalCves, Math.max(cvesFixed, audits.length));
31
- }
32
- catch {
33
- // Ignore
34
- }
44
+ catch {
45
+ return empty;
35
46
  }
36
- const status = cvesFixed >= totalCves ? 'CLEAN' : cvesFixed > 0 ? 'IN_PROGRESS' : 'PENDING';
37
- return { status, cvesFixed, totalCves };
38
47
  }
39
48
  export function getSwarmStatus() {
40
49
  let activeAgents = 0;
@@ -619,7 +619,7 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
619
619
  initialized: new Date().toISOString(),
620
620
  status: 'PENDING',
621
621
  cvesFixed: 0,
622
- totalCves: 3,
622
+ totalCves: 0,
623
623
  lastScan: null,
624
624
  _note: 'Run: npx @claude-flow/cli@latest security scan'
625
625
  };
@@ -1541,7 +1541,7 @@ async function writeInitialMetrics(targetDir, options, result) {
1541
1541
  initialized: new Date().toISOString(),
1542
1542
  status: 'PENDING',
1543
1543
  cvesFixed: 0,
1544
- totalCves: 3,
1544
+ totalCves: 0,
1545
1545
  lastScan: null,
1546
1546
  _note: 'Run: npx @claude-flow/cli@latest security scan'
1547
1547
  };
@@ -2010,8 +2010,9 @@ export const hooksSessionEnd = {
2010
2010
  }
2011
2011
  // Phase 5: Wire ReflexionMemory session end + NightlyLearner consolidation via bridge
2012
2012
  let sessionPersistence = null;
2013
+ let bridge = null;
2013
2014
  try {
2014
- const bridge = await import('../memory/memory-bridge.js');
2015
+ bridge = await import('../memory/memory-bridge.js');
2015
2016
  const result = await bridge.bridgeSessionEnd({
2016
2017
  sessionId,
2017
2018
  summary: saveState ? 'Session ended with state saved' : 'Session ended',
@@ -2028,6 +2029,17 @@ export const hooksSessionEnd = {
2028
2029
  catch {
2029
2030
  // Bridge not available
2030
2031
  }
2032
+ finally {
2033
+ // Release AgentDB/ONNX resources after one-shot session persistence.
2034
+ // A partially initialized native pool can otherwise keep Node alive
2035
+ // after the command has completed all logical work (#2691).
2036
+ try {
2037
+ await bridge?.shutdownBridge();
2038
+ }
2039
+ catch {
2040
+ // Cleanup is best-effort and must not fail session-end.
2041
+ }
2042
+ }
2031
2043
  return {
2032
2044
  sessionId,
2033
2045
  duration: 3600000, // 1 hour in ms
@@ -0,0 +1,34 @@
1
+ export interface BuiltinThreat {
2
+ type: string;
3
+ severity: 'critical' | 'high' | 'medium' | 'low';
4
+ description: string;
5
+ confidence: number;
6
+ }
7
+ export interface DefenceResult {
8
+ safe: boolean;
9
+ threats: BuiltinThreat[];
10
+ piiFound: boolean;
11
+ detectionTimeMs: number;
12
+ inputHash: string;
13
+ }
14
+ export interface DefenceEngine {
15
+ detect(input: string): Promise<DefenceResult>;
16
+ quickScan(input: string): {
17
+ threat: boolean;
18
+ confidence: number;
19
+ type?: string;
20
+ };
21
+ getStats(): Promise<{
22
+ detectionCount: number;
23
+ avgDetectionTimeMs: number;
24
+ learnedPatterns: number;
25
+ mitigationStrategies: number;
26
+ avgMitigationEffectiveness: number;
27
+ }>;
28
+ getBestMitigation(type: string): Promise<{
29
+ strategy: string;
30
+ effectiveness: number;
31
+ } | null>;
32
+ }
33
+ export declare function createBuiltinAIDefence(): DefenceEngine;
34
+ //# sourceMappingURL=builtin-aidefence.d.ts.map
@@ -0,0 +1,86 @@
1
+ import { createHash } from 'node:crypto';
2
+ const THREAT_PATTERNS = [
3
+ {
4
+ type: 'prompt-injection',
5
+ severity: 'high',
6
+ confidence: 0.96,
7
+ description: 'Attempts to override or discard trusted instructions',
8
+ pattern: /\b(?:ignore|disregard|forget|override)\b[\s\S]{0,40}\b(?:previous|prior|system|developer|trusted)\b[\s\S]{0,24}\b(?:instructions?|prompts?|rules?|messages?)\b/i,
9
+ },
10
+ {
11
+ type: 'system-prompt-extraction',
12
+ severity: 'high',
13
+ confidence: 0.94,
14
+ description: 'Attempts to reveal hidden system or developer instructions',
15
+ pattern: /\b(?:reveal|show|print|repeat|dump|expose)\b[\s\S]{0,32}\b(?:system|developer|hidden|initial)\b[\s\S]{0,20}\b(?:prompt|message|instructions?)\b/i,
16
+ },
17
+ {
18
+ type: 'jailbreak',
19
+ severity: 'high',
20
+ confidence: 0.91,
21
+ description: 'Attempts to bypass model safeguards or enter an unrestricted mode',
22
+ pattern: /\b(?:developer mode|DAN mode|jailbreak|bypass (?:all )?(?:safeguards|restrictions|filters)|unrestricted mode)\b/i,
23
+ },
24
+ {
25
+ type: 'data-exfiltration',
26
+ severity: 'critical',
27
+ confidence: 0.93,
28
+ description: 'Attempts to transmit secrets or credentials to an external destination',
29
+ pattern: /\b(?:send|upload|post|exfiltrate|transmit)\b[\s\S]{0,48}\b(?:secret|credential|password|api key|token|private key)\b/i,
30
+ },
31
+ ];
32
+ const PII_PATTERNS = [
33
+ /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/i,
34
+ /\b\d{3}-\d{2}-\d{4}\b/,
35
+ /\b(?:sk-|ghp_|xox[baprs]-)[A-Za-z0-9_-]{16,}\b/,
36
+ /\bAKIA[A-Z0-9]{16}\b/,
37
+ ];
38
+ export function createBuiltinAIDefence() {
39
+ let detectionCount = 0;
40
+ let totalDetectionTimeMs = 0;
41
+ const scan = (input) => THREAT_PATTERNS
42
+ .filter(({ pattern }) => pattern.test(input))
43
+ .map(({ pattern: _pattern, ...threat }) => threat);
44
+ return {
45
+ async detect(input) {
46
+ const startedAt = performance.now();
47
+ const threats = scan(input);
48
+ const piiFound = PII_PATTERNS.some((pattern) => pattern.test(input));
49
+ const detectionTimeMs = performance.now() - startedAt;
50
+ detectionCount++;
51
+ totalDetectionTimeMs += detectionTimeMs;
52
+ return {
53
+ safe: threats.length === 0 && !piiFound,
54
+ threats,
55
+ piiFound,
56
+ detectionTimeMs,
57
+ inputHash: createHash('sha256').update(input).digest('hex'),
58
+ };
59
+ },
60
+ quickScan(input) {
61
+ const threat = scan(input)[0];
62
+ return threat
63
+ ? { threat: true, confidence: threat.confidence, type: threat.type }
64
+ : { threat: false, confidence: 0 };
65
+ },
66
+ async getStats() {
67
+ return {
68
+ detectionCount,
69
+ avgDetectionTimeMs: detectionCount === 0 ? 0 : totalDetectionTimeMs / detectionCount,
70
+ learnedPatterns: 0,
71
+ mitigationStrategies: 4,
72
+ avgMitigationEffectiveness: 0.9,
73
+ };
74
+ },
75
+ async getBestMitigation(type) {
76
+ const strategies = {
77
+ 'prompt-injection': 'Keep trusted instructions immutable and reject instruction overrides',
78
+ 'system-prompt-extraction': 'Do not disclose system or developer messages',
79
+ jailbreak: 'Apply the configured policy without adopting alternate personas',
80
+ 'data-exfiltration': 'Block external transmission and rotate exposed credentials',
81
+ };
82
+ return strategies[type] ? { strategy: strategies[type], effectiveness: 0.9 } : null;
83
+ },
84
+ };
85
+ }
86
+ //# sourceMappingURL=builtin-aidefence.js.map
@@ -90,6 +90,7 @@ export interface ReflectResult {
90
90
  export interface CoPilotSnapshot {
91
91
  security?: {
92
92
  status: string;
93
+ findings?: number;
93
94
  cvesFixed: number;
94
95
  totalCves: number;
95
96
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.32.1",
3
+ "version": "3.32.2",
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",
@@ -111,7 +111,7 @@
111
111
  "yaml": "^2.8.0"
112
112
  },
113
113
  "optionalDependencies": {
114
- "@claude-flow/memory": "^3.0.0-alpha.21",
114
+ "@claude-flow/memory": "^3.0.0-alpha.21",
115
115
  "@claude-flow/security": "^3.0.0-alpha.10",
116
116
  "agentdb": "^3.0.0-alpha.17",
117
117
  "agentic-flow": "^3.0.0-alpha.1",