claude-flow 3.32.0 → 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.
- package/.claude/helpers/statusline.cjs +38 -31
- package/.claude/proven-config.json +1 -1
- package/.claude-plugin/scripts/ruflo-hook.cjs +2 -2
- package/.claude-plugin/scripts/ruflo-hook.sh +17 -2
- package/package.json +186 -185
- package/v3/@claude-flow/cli/catalog-manifest.json +2 -2
- package/v3/@claude-flow/cli/dist/src/commands/hooks.js +20 -9
- package/v3/@claude-flow/cli/dist/src/commands/init.d.ts +5 -0
- package/v3/@claude-flow/cli/dist/src/commands/init.js +30 -1
- package/v3/@claude-flow/cli/dist/src/commands/security.js +16 -11
- package/v3/@claude-flow/cli/dist/src/funnel/insights.d.ts +1 -0
- package/v3/@claude-flow/cli/dist/src/funnel/insights.js +4 -4
- package/v3/@claude-flow/cli/dist/src/funnel/local-signals.d.ts +6 -1
- package/v3/@claude-flow/cli/dist/src/funnel/local-signals.js +29 -20
- package/v3/@claude-flow/cli/dist/src/init/executor.js +2 -2
- package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +13 -1
- package/v3/@claude-flow/cli/dist/src/security/builtin-aidefence.d.ts +34 -0
- package/v3/@claude-flow/cli/dist/src/security/builtin-aidefence.js +86 -0
- package/v3/@claude-flow/cli/dist/src/services/fable-harness.d.ts +1 -0
- package/v3/@claude-flow/cli/package.json +9 -8
- package/.claude/helpers/.helpers-version +0 -1
- package/.claude/helpers/helpers.manifest.json +0 -13
- package/.claude/helpers/hidden-hook.vbs +0 -43
- package/.claude/settings.local.json +0 -78
- package/v3/@claude-flow/cli/dist/src/ruvector/flash-attention.d.ts +0 -195
- package/v3/@claude-flow/cli/dist/src/ruvector/flash-attention.js +0 -643
- package/v3/@claude-flow/cli/dist/src/ruvector/moe-router.d.ts +0 -206
- package/v3/@claude-flow/cli/dist/src/ruvector/moe-router.js +0 -626
- package/v3/@claude-flow/cli/dist/src/services/event-stream.d.ts +0 -25
- package/v3/@claude-flow/cli/dist/src/services/event-stream.js +0 -27
- package/v3/@claude-flow/cli/dist/src/services/loop-worker-runner.d.ts +0 -16
- package/v3/@claude-flow/cli/dist/src/services/loop-worker-runner.js +0 -34
- package/v3/@claude-flow/cli/dist/src/services/runtime-capabilities.d.ts +0 -22
- package/v3/@claude-flow/cli/dist/src/services/runtime-capabilities.js +0 -45
|
@@ -3487,18 +3487,26 @@ const statuslineCommand = {
|
|
|
3487
3487
|
}
|
|
3488
3488
|
// Get user info
|
|
3489
3489
|
function getUserInfo() {
|
|
3490
|
-
|
|
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
|
|
3496
|
-
? 'git
|
|
3497
|
-
: 'git
|
|
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
|
-
|
|
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
|
|
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 === '
|
|
3733
|
-
const securityColor = security.status === 'CLEAN' ? c.brightGreen : security.status === '
|
|
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}
|
|
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;
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
* Comprehensive initialization for Claude Flow with Claude Code integration
|
|
4
4
|
*/
|
|
5
5
|
import type { Command } from '../types.js';
|
|
6
|
+
export declare function runCodexInitializerCli(cwd: string, options: {
|
|
7
|
+
template: string;
|
|
8
|
+
force: boolean;
|
|
9
|
+
dual: boolean;
|
|
10
|
+
}): boolean;
|
|
6
11
|
export declare const initCommand: Command;
|
|
7
12
|
export default initCommand;
|
|
8
13
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -6,6 +6,7 @@ import { output } from '../output.js';
|
|
|
6
6
|
import { confirm, select, multiSelect, input } from '../prompt.js';
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
9
10
|
import { executeInit, executeUpgrade, executeUpgradeWithMissing, DEFAULT_INIT_OPTIONS, MINIMAL_INIT_OPTIONS, FULL_INIT_OPTIONS, } from '../init/index.js';
|
|
10
11
|
import { ENROLLMENT_SCREEN, recordEnrollmentOutcome, shouldOfferEnrollment, } from '../funnel/enrollment.js';
|
|
11
12
|
import { commandExists } from '../services/harness-hosts.js';
|
|
@@ -82,6 +83,27 @@ async function resolveCodexInitializer(cwd) {
|
|
|
82
83
|
}
|
|
83
84
|
return undefined;
|
|
84
85
|
}
|
|
86
|
+
// Keep Codex out of the CLI dependency graph so cold `npx ruflo --version`
|
|
87
|
+
// remains fast (#2561). An explicit `init --codex` may fetch the small,
|
|
88
|
+
// stable adapter on demand when it is not already installed by an umbrella
|
|
89
|
+
// package, the current project, or the global npm prefix.
|
|
90
|
+
export function runCodexInitializerCli(cwd, options) {
|
|
91
|
+
const npxArgs = [
|
|
92
|
+
'-y',
|
|
93
|
+
'@claude-flow/codex@latest',
|
|
94
|
+
'init',
|
|
95
|
+
'--template',
|
|
96
|
+
options.template,
|
|
97
|
+
...(options.force ? ['--force'] : []),
|
|
98
|
+
...(options.dual ? ['--dual'] : []),
|
|
99
|
+
];
|
|
100
|
+
const result = process.platform === 'win32'
|
|
101
|
+
? spawnSync(process.env.ComSpec || 'cmd.exe', ['/d', '/s', '/c', ['npx', ...npxArgs].join(' ')], { cwd, stdio: 'inherit', windowsHide: true })
|
|
102
|
+
: spawnSync('npx', npxArgs, { cwd, stdio: 'inherit' });
|
|
103
|
+
if (result.error)
|
|
104
|
+
throw result.error;
|
|
105
|
+
return result.status === 0;
|
|
106
|
+
}
|
|
85
107
|
// #2666-adjacent — quietly wire up Codex too when a plain `ruflo init` (no
|
|
86
108
|
// --codex/--dual) runs on a machine that also has the OpenAI Codex CLI on
|
|
87
109
|
// PATH: registers its MCP server and installs skills alongside the Claude
|
|
@@ -194,7 +216,14 @@ async function initCodexAction(ctx, options) {
|
|
|
194
216
|
try {
|
|
195
217
|
const CodexInitializer = await resolveCodexInitializer(ctx.cwd);
|
|
196
218
|
if (!CodexInitializer) {
|
|
197
|
-
|
|
219
|
+
spinner.stop();
|
|
220
|
+
output.printInfo('Fetching the stable Codex adapter for this initialization...');
|
|
221
|
+
const success = runCodexInitializerCli(ctx.cwd, { template, force, dual: dualMode });
|
|
222
|
+
if (!success) {
|
|
223
|
+
output.printError('Codex initialization failed while running @claude-flow/codex@latest.');
|
|
224
|
+
return { success: false, exitCode: 1 };
|
|
225
|
+
}
|
|
226
|
+
return { success: true, data: { adapter: '@claude-flow/codex@latest' } };
|
|
198
227
|
}
|
|
199
228
|
const initializer = new CodexInitializer();
|
|
200
229
|
const result = await initializer.initialize({
|
|
@@ -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
|
|
865
|
+
let defender;
|
|
865
866
|
try {
|
|
866
867
|
const aidefence = await import('@claude-flow/aidefence');
|
|
867
|
-
|
|
868
|
+
defender = aidefence.createAIDefence({ enableLearning });
|
|
868
869
|
}
|
|
869
870
|
catch {
|
|
870
|
-
|
|
871
|
-
|
|
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.
|
|
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
|
|
918
|
-
|
|
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
|
-
|
|
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
|
-
|
|
976
|
+
const safe = result.safe && !result.piiFound;
|
|
977
|
+
return { success: safe, exitCode: safe ? 0 : 1 };
|
|
973
978
|
},
|
|
974
979
|
};
|
|
975
980
|
// Main security command
|
|
@@ -42,11 +42,11 @@ function securityInsight(ctx) {
|
|
|
42
42
|
const s = ctx.security;
|
|
43
43
|
if (!s)
|
|
44
44
|
return null;
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
45
|
+
const findings = Math.max(0, s.findings ?? 0);
|
|
46
|
+
if (s.status === 'ISSUES' || findings > 0) {
|
|
47
47
|
return {
|
|
48
|
-
id: 'insight-
|
|
49
|
-
text: `⚠ ${
|
|
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' | '
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.32.
|
|
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",
|
|
7
7
|
"types": "dist/src/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"bin": {
|
|
10
|
-
"cli": "
|
|
11
|
-
"claude-flow": "
|
|
12
|
-
"claude-flow-mcp": "
|
|
10
|
+
"cli": "bin/cli.js",
|
|
11
|
+
"claude-flow": "bin/cli.js",
|
|
12
|
+
"claude-flow-mcp": "bin/mcp-server.js"
|
|
13
13
|
},
|
|
14
14
|
"homepage": "https://github.com/ruvnet/claude-flow#readme",
|
|
15
15
|
"bugs": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/ruvnet/claude-flow.git",
|
|
20
|
+
"url": "git+https://github.com/ruvnet/claude-flow.git",
|
|
21
21
|
"directory": "v3/@claude-flow/cli"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
@@ -90,8 +90,9 @@
|
|
|
90
90
|
"test:plugin-store": "npx tsx src/plugins/tests/standalone-test.ts",
|
|
91
91
|
"test:pattern-store": "npx tsx src/transfer/store/tests/standalone-test.ts",
|
|
92
92
|
"postinstall": "node ./scripts/postinstall.cjs",
|
|
93
|
-
"prepublishOnly": "
|
|
94
|
-
"release": "npm
|
|
93
|
+
"prepublishOnly": "node scripts/prepare-publish.mjs",
|
|
94
|
+
"release": "npm publish --access public --tag latest",
|
|
95
|
+
"release:alpha": "npm version prerelease --preid=alpha && npm run publish:all",
|
|
95
96
|
"publish:all": "./scripts/publish.sh"
|
|
96
97
|
},
|
|
97
98
|
"devDependencies": {
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"yaml": "^2.8.0"
|
|
111
112
|
},
|
|
112
113
|
"optionalDependencies": {
|
|
113
|
-
"@claude-flow/memory": "^3.0.0-alpha.21",
|
|
114
|
+
"@claude-flow/memory": "^3.0.0-alpha.21",
|
|
114
115
|
"@claude-flow/security": "^3.0.0-alpha.10",
|
|
115
116
|
"agentdb": "^3.0.0-alpha.17",
|
|
116
117
|
"agentic-flow": "^3.0.0-alpha.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.29.0
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"manifest": {
|
|
3
|
-
"version": "3.29.0",
|
|
4
|
-
"files": {
|
|
5
|
-
"auto-memory-hook.mjs": "e3e1033b24704992ddef6b31c7fa9dd7fcd9e1af7935dd77ef73402b916b31e6",
|
|
6
|
-
"hook-handler.cjs": "f51fb035d8a4110fdf763cee2913e285bcdbbaa618cbee980e032f89ffaf89d2",
|
|
7
|
-
"intelligence.cjs": "5a55d979cb7ba5c8c4f27f3b2e6d686fbb1045d180023b803da672a37e05b915",
|
|
8
|
-
"statusline.cjs": "8416172e504b03f9ec2266a47bba048578c3b1e30c5c7c97a0a8261460cd601d"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"signature": "F0YZmNYCOnPOkf/kqbUoXtZ/jfYsX+Mn3QTGvtR6dafHx+oZ4uoobOKu/GYls+z+vHN2beL9c9GK53YKB1txBA==",
|
|
12
|
-
"algorithm": "ed25519"
|
|
13
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
' hidden-hook.vbs — Windowless launcher for Claude Code hooks on Windows.
|
|
2
|
-
'
|
|
3
|
-
' Workaround for anthropics/claude-code#14828 / #70200 — Claude Code's
|
|
4
|
-
' child_process.spawn for hook commands is missing windowsHide/CREATE_NO_WINDOW,
|
|
5
|
-
' so every hook fire flashes a visible cmd.exe window. This shim is invoked via
|
|
6
|
-
' wscript.exe (a GUI-subsystem host with no console), so Claude Code's outer
|
|
7
|
-
' spawn attaches no console. Internally it runs node hidden via
|
|
8
|
-
' WScript.Shell.Run(cmd, 0, True).
|
|
9
|
-
'
|
|
10
|
-
' Usage from settings.local.json:
|
|
11
|
-
' "command": "wscript.exe \"${CLAUDE_PROJECT_DIR}\\.claude\\helpers\\hidden-hook.vbs\" hook-handler.cjs pre-bash"
|
|
12
|
-
'
|
|
13
|
-
' TRADE-OFF: wscript.exe has no stdin. Claude Code sends hook event data as
|
|
14
|
-
' JSON via stdin, so hooks routed through this shim run WITHOUT their event
|
|
15
|
-
' payload. Most ruflo hooks (env-var driven) still work; hooks like `route`
|
|
16
|
-
' that need the user's prompt will have reduced context.
|
|
17
|
-
'
|
|
18
|
-
' Exit code from the wrapped node process is propagated back to Claude Code.
|
|
19
|
-
|
|
20
|
-
Option Explicit
|
|
21
|
-
|
|
22
|
-
If WScript.Arguments.Count < 1 Then
|
|
23
|
-
WScript.Quit 2
|
|
24
|
-
End If
|
|
25
|
-
|
|
26
|
-
Dim shell, cmd, i, arg
|
|
27
|
-
Set shell = CreateObject("WScript.Shell")
|
|
28
|
-
|
|
29
|
-
' Resolve helpers dir from this script's own path (avoids env-var dependency)
|
|
30
|
-
Dim scriptDir
|
|
31
|
-
scriptDir = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\"))
|
|
32
|
-
|
|
33
|
-
' First arg is the hook-handler script name (e.g. "hook-handler.cjs"),
|
|
34
|
-
' remaining args are passed through to node.
|
|
35
|
-
cmd = "node """ & scriptDir & WScript.Arguments(0) & """"
|
|
36
|
-
For i = 1 To WScript.Arguments.Count - 1
|
|
37
|
-
arg = WScript.Arguments(i)
|
|
38
|
-
arg = Replace(arg, """", "\""")
|
|
39
|
-
cmd = cmd & " """ & arg & """"
|
|
40
|
-
Next
|
|
41
|
-
|
|
42
|
-
' 0 = SW_HIDE, True = wait for completion (propagates exit code synchronously)
|
|
43
|
-
WScript.Quit shell.Run(cmd, 0, True)
|