claude-flow 3.31.3 → 3.32.1

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.
@@ -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)
@@ -1,42 +0,0 @@
1
- {
2
- "adoptedAt": 1784038275868,
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
- }
@@ -1,78 +0,0 @@
1
- {
2
- "_comment": "Windows-only override — routes HOOKS through wscript.exe hidden-hook.vbs to work around anthropics/claude-code#14828 / #70200 (missing windowsHide/CREATE_NO_WINDOW on hook spawns). Gitignored; delete or empty to restore normal .claude/settings.json behavior. Trade-offs: (1) wscript has no stdin/stdout, so hooks routed through here run without their JSON event payload and cannot print output back to Claude Code — most ruflo hooks tolerate this. (2) statusLine is NOT overridden here because it requires stdout; it falls back to .claude/settings.json's direct node invocation, which will still flash on Windows until Claude Code adds windowsHide to its statusLine spawn. See .claude/helpers/hidden-hook.vbs.",
3
- "hooks": {
4
- "PreToolUse": [
5
- {
6
- "matcher": "Bash",
7
- "hooks": [
8
- {
9
- "type": "command",
10
- "command": "wscript.exe \"${CLAUDE_PROJECT_DIR}\\.claude\\helpers\\hidden-hook.vbs\" hook-handler.cjs pre-bash",
11
- "timeout": 5000
12
- }
13
- ]
14
- }
15
- ],
16
- "PostToolUse": [
17
- {
18
- "matcher": "Write|Edit|MultiEdit",
19
- "hooks": [
20
- {
21
- "type": "command",
22
- "command": "wscript.exe \"${CLAUDE_PROJECT_DIR}\\.claude\\helpers\\hidden-hook.vbs\" hook-handler.cjs post-edit",
23
- "timeout": 10000
24
- }
25
- ]
26
- }
27
- ],
28
- "UserPromptSubmit": [
29
- {
30
- "hooks": [
31
- {
32
- "type": "command",
33
- "command": "wscript.exe \"${CLAUDE_PROJECT_DIR}\\.claude\\helpers\\hidden-hook.vbs\" hook-handler.cjs route",
34
- "timeout": 10000
35
- }
36
- ]
37
- }
38
- ],
39
- "SessionStart": [
40
- {
41
- "hooks": [
42
- {
43
- "type": "command",
44
- "command": "wscript.exe \"${CLAUDE_PROJECT_DIR}\\.claude\\helpers\\hidden-hook.vbs\" hook-handler.cjs session-restore",
45
- "timeout": 15000
46
- },
47
- {
48
- "type": "command",
49
- "command": "wscript.exe \"${CLAUDE_PROJECT_DIR}\\.claude\\helpers\\hidden-hook.vbs\" auto-memory-hook.mjs import",
50
- "timeout": 8000
51
- }
52
- ]
53
- }
54
- ],
55
- "SessionEnd": [
56
- {
57
- "hooks": [
58
- {
59
- "type": "command",
60
- "command": "wscript.exe \"${CLAUDE_PROJECT_DIR}\\.claude\\helpers\\hidden-hook.vbs\" hook-handler.cjs session-end",
61
- "timeout": 10000
62
- }
63
- ]
64
- }
65
- ],
66
- "Stop": [
67
- {
68
- "hooks": [
69
- {
70
- "type": "command",
71
- "command": "wscript.exe \"${CLAUDE_PROJECT_DIR}\\.claude\\helpers\\hidden-hook.vbs\" auto-memory-hook.mjs sync",
72
- "timeout": 10000
73
- }
74
- ]
75
- }
76
- ]
77
- }
78
- }
@@ -1,195 +0,0 @@
1
- /**
2
- * Flash Attention Implementation for RuVector Intelligence System
3
- *
4
- * Implements block-wise attention computation for faster similarity calculations.
5
- * Achieves O(N) memory instead of O(N^2) through tiling strategy.
6
- *
7
- * Key optimizations:
8
- * - Block-wise computation to fit in L1 cache
9
- * - Fused softmax-matmul operations
10
- * - Float32Array for all operations
11
- * - Online softmax for numerical stability
12
- *
13
- * Target: 2-5x speedup on CPU vs naive attention
14
- *
15
- * Created with love by ruv.io
16
- */
17
- export interface FlashAttentionConfig {
18
- /** Block size for tiling (32-64 optimal for CPU L1 cache) */
19
- blockSize: number;
20
- /** Number of dimensions in embedding vectors */
21
- dimensions: number;
22
- /** Temperature for softmax scaling */
23
- temperature: number;
24
- /** Enable numerical stability optimizations */
25
- useStableMode: boolean;
26
- /** Use optimized CPU path (default: true) */
27
- useCPUOptimizations: boolean;
28
- }
29
- export interface AttentionResult {
30
- /** Output vectors after attention */
31
- output: Float32Array[];
32
- /** Attention weights (optional, for debugging) */
33
- weights?: Float32Array[];
34
- /** Computation time in milliseconds */
35
- computeTimeMs: number;
36
- }
37
- export interface BenchmarkResult {
38
- /** Naive attention time in milliseconds */
39
- naiveTimeMs: number;
40
- /** Flash attention time in milliseconds */
41
- flashTimeMs: number;
42
- /** Speedup factor (naive / flash) */
43
- speedup: number;
44
- /** Number of vectors benchmarked */
45
- numVectors: number;
46
- /** Dimensions of vectors */
47
- dimensions: number;
48
- /** Memory usage estimate for naive (bytes) */
49
- naiveMemoryBytes: number;
50
- /** Memory usage estimate for flash (bytes) */
51
- flashMemoryBytes: number;
52
- /** Memory reduction factor */
53
- memoryReduction: number;
54
- }
55
- export declare class FlashAttention {
56
- private config;
57
- private lastSpeedup;
58
- private benchmarkHistory;
59
- private scoreBuffer;
60
- private expBuffer;
61
- private accumBuffer;
62
- constructor(config?: Partial<FlashAttentionConfig>);
63
- /**
64
- * Main attention computation using Flash Attention algorithm
65
- *
66
- * @param queries - Query vectors [N x D]
67
- * @param keys - Key vectors [M x D]
68
- * @param values - Value vectors [M x D]
69
- * @returns Attention output [N x D]
70
- */
71
- attention(queries: Float32Array[], keys: Float32Array[], values: Float32Array[]): AttentionResult;
72
- /**
73
- * CPU-optimized attention with aggressive optimizations
74
- *
75
- * Key optimizations:
76
- * - Blocked score computation (better cache utilization)
77
- * - Top-K sparse attention (only use most relevant keys)
78
- * - Pre-allocated buffers to avoid GC pressure
79
- * - 8x loop unrolling for dot products
80
- * - Fused max-finding during score computation
81
- */
82
- private cpuOptimizedAttention;
83
- /**
84
- * Partial dot product using only first N dimensions (for screening)
85
- */
86
- private partialDotProduct;
87
- /**
88
- * Partial sort to get top-K elements (QuickSelect-like)
89
- * Only ensures first K elements are the largest, not sorted
90
- */
91
- private partialSort;
92
- /**
93
- * Swap two indices in array
94
- */
95
- private swapIndices;
96
- /**
97
- * Fast dot product with 8x unrolling
98
- */
99
- private fastDotProduct;
100
- /**
101
- * Block-wise attention computation (Flash Attention core algorithm)
102
- *
103
- * Algorithm:
104
- * For each block of queries Q_b:
105
- * For each block of keys K_b:
106
- * S_b = Q_b @ K_b.T / sqrt(d) // Block scores
107
- * P_b = softmax(S_b) // Block attention
108
- * O_b += P_b @ V_b // Accumulate output
109
- *
110
- * @param Q - Query vectors
111
- * @param K - Key vectors
112
- * @param V - Value vectors
113
- * @param blockSize - Block size for tiling
114
- */
115
- blockAttention(Q: Float32Array[], K: Float32Array[], V: Float32Array[], blockSize: number): Float32Array[];
116
- /**
117
- * Get the speedup factor from the last benchmark
118
- */
119
- getSpeedup(): number;
120
- /**
121
- * Run benchmark comparing naive vs CPU-optimized attention
122
- *
123
- * @param numVectors - Number of vectors to test
124
- * @param dimensions - Dimensions per vector
125
- * @param iterations - Number of iterations for averaging
126
- */
127
- benchmark(numVectors?: number, dimensions?: number, iterations?: number): BenchmarkResult;
128
- /**
129
- * Get benchmark history
130
- */
131
- getBenchmarkHistory(): BenchmarkResult[];
132
- /**
133
- * Get configuration
134
- */
135
- getConfig(): FlashAttentionConfig;
136
- /**
137
- * Update configuration
138
- */
139
- setConfig(config: Partial<FlashAttentionConfig>): void;
140
- /**
141
- * Naive O(N^2) attention implementation for comparison
142
- */
143
- private naiveAttention;
144
- /**
145
- * Compute block of attention scores
146
- */
147
- private computeBlockScores;
148
- /**
149
- * Online softmax with output accumulation (key to Flash Attention)
150
- *
151
- * Uses the online softmax trick to maintain numerical stability
152
- * while processing blocks incrementally.
153
- */
154
- private onlineSoftmaxAccumulate;
155
- /**
156
- * Compute dot product of two vectors
157
- */
158
- private dotProduct;
159
- /**
160
- * Stable softmax implementation
161
- */
162
- private softmax;
163
- /**
164
- * Generate random vectors for benchmarking
165
- */
166
- private generateRandomVectors;
167
- /**
168
- * Validate input arrays
169
- */
170
- private validateInputs;
171
- }
172
- /**
173
- * Get singleton FlashAttention instance
174
- *
175
- * @param config - Optional configuration (only used on first call)
176
- * @returns FlashAttention instance
177
- */
178
- export declare function getFlashAttention(config?: Partial<FlashAttentionConfig>): FlashAttention;
179
- /**
180
- * Reset singleton (for testing)
181
- */
182
- export declare function resetFlashAttention(): void;
183
- /**
184
- * Compute attention using Flash Attention
185
- */
186
- export declare function computeAttention(queries: Float32Array[], keys: Float32Array[], values: Float32Array[], config?: Partial<FlashAttentionConfig>): AttentionResult;
187
- /**
188
- * Run Flash Attention benchmark
189
- */
190
- export declare function benchmarkFlashAttention(numVectors?: number, dimensions?: number, iterations?: number): BenchmarkResult;
191
- /**
192
- * Get current speedup from last benchmark
193
- */
194
- export declare function getFlashAttentionSpeedup(): number;
195
- //# sourceMappingURL=flash-attention.d.ts.map