@sparkleideas/plugin-cognitive-kernel 3.0.0-alpha.11

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 (2) hide show
  1. package/README.md +315 -0
  2. package/package.json +83 -0
package/README.md ADDED
@@ -0,0 +1,315 @@
1
+ # @claude-flow/plugin-cognitive-kernel
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@claude-flow/plugin-cognitive-kernel.svg)](https://www.npmjs.com/package/@claude-flow/plugin-cognitive-kernel)
4
+ [![license](https://img.shields.io/npm/l/@claude-flow/plugin-cognitive-kernel.svg)](https://github.com/ruvnet/claude-flow/blob/main/LICENSE)
5
+ [![downloads](https://img.shields.io/npm/dm/@claude-flow/plugin-cognitive-kernel.svg)](https://www.npmjs.com/package/@claude-flow/plugin-cognitive-kernel)
6
+
7
+ A cutting-edge cognitive augmentation plugin combining the Cognitum Gate Kernel with SONA self-optimizing architecture to provide LLMs with enhanced cognitive capabilities. The plugin enables dynamic working memory, attention control mechanisms, meta-cognitive self-monitoring, and cognitive scaffolding while maintaining low latency through WASM acceleration.
8
+
9
+ ## Installation
10
+
11
+ ### npm
12
+
13
+ ```bash
14
+ npm install @claude-flow/plugin-cognitive-kernel
15
+ ```
16
+
17
+ ### CLI
18
+
19
+ ```bash
20
+ npx claude-flow plugins install --name @claude-flow/plugin-cognitive-kernel
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```typescript
26
+ import { CognitiveKernelPlugin } from '@claude-flow/plugin-cognitive-kernel';
27
+
28
+ // Initialize the plugin
29
+ const plugin = new CognitiveKernelPlugin();
30
+ await plugin.initialize();
31
+
32
+ // Allocate working memory for a complex reasoning task
33
+ const memorySlot = await plugin.workingMemory({
34
+ action: 'allocate',
35
+ slot: {
36
+ id: 'current-problem',
37
+ content: { problem: 'Design authentication system', context: {...} },
38
+ priority: 0.9,
39
+ decay: 0.05
40
+ },
41
+ capacity: 7 // Miller's number
42
+ });
43
+
44
+ // Control attention for focused analysis
45
+ await plugin.attentionControl({
46
+ mode: 'focus',
47
+ targets: [
48
+ { entity: 'security-requirements', weight: 0.8, duration: 300 },
49
+ { entity: 'user-experience', weight: 0.6, duration: 300 }
50
+ ],
51
+ filters: {
52
+ includePatterns: ['auth*', 'security*', 'token*'],
53
+ noveltyBias: 0.3
54
+ }
55
+ });
56
+
57
+ console.log('Cognitive context established');
58
+ ```
59
+
60
+ ## Available MCP Tools
61
+
62
+ ### 1. `cognition/working-memory`
63
+
64
+ Manage dynamic working memory slots for complex reasoning tasks.
65
+
66
+ ```typescript
67
+ const result = await mcp.call('cognition/working-memory', {
68
+ action: 'allocate',
69
+ slot: {
70
+ id: 'task-context',
71
+ content: {
72
+ goal: 'Refactor authentication module',
73
+ constraints: ['maintain backward compatibility', 'improve security'],
74
+ progress: []
75
+ },
76
+ priority: 0.8,
77
+ decay: 0.1
78
+ },
79
+ capacity: 7,
80
+ consolidationTarget: 'episodic'
81
+ });
82
+ ```
83
+
84
+ **Actions:** `allocate`, `update`, `retrieve`, `clear`, `consolidate`
85
+
86
+ **Returns:** Memory slot state with current contents and decay status.
87
+
88
+ ### 2. `cognition/attention-control`
89
+
90
+ Control cognitive attention and information filtering.
91
+
92
+ ```typescript
93
+ const result = await mcp.call('cognition/attention-control', {
94
+ mode: 'selective',
95
+ targets: [
96
+ { entity: 'error-handling', weight: 0.9, duration: 600 },
97
+ { entity: 'input-validation', weight: 0.7, duration: 600 }
98
+ ],
99
+ filters: {
100
+ includePatterns: ['error*', 'exception*', 'validation*'],
101
+ excludePatterns: ['deprecated*', 'legacy*'],
102
+ noveltyBias: 0.5
103
+ }
104
+ });
105
+ ```
106
+
107
+ **Modes:** `focus`, `diffuse`, `selective`, `divided`, `sustained`
108
+
109
+ **Returns:** Attention state with active targets and filter configuration.
110
+
111
+ ### 3. `cognition/meta-monitor`
112
+
113
+ Meta-cognitive monitoring of reasoning quality and self-reflection.
114
+
115
+ ```typescript
116
+ const result = await mcp.call('cognition/meta-monitor', {
117
+ monitoring: [
118
+ 'confidence_calibration',
119
+ 'reasoning_coherence',
120
+ 'goal_tracking',
121
+ 'error_detection'
122
+ ],
123
+ reflection: {
124
+ trigger: 'on_uncertainty',
125
+ depth: 'medium'
126
+ },
127
+ interventions: true
128
+ });
129
+ ```
130
+
131
+ **Returns:** Meta-cognitive assessment with confidence scores, detected issues, and suggested interventions.
132
+
133
+ ### 4. `cognition/scaffold`
134
+
135
+ Provide cognitive scaffolding for complex reasoning tasks.
136
+
137
+ ```typescript
138
+ const result = await mcp.call('cognition/scaffold', {
139
+ task: {
140
+ description: 'Design a distributed caching system',
141
+ complexity: 'complex',
142
+ domain: 'distributed-systems'
143
+ },
144
+ scaffoldType: 'decomposition',
145
+ adaptivity: {
146
+ fading: true,
147
+ monitoring: true
148
+ }
149
+ });
150
+ ```
151
+
152
+ **Scaffold Types:** `decomposition`, `analogy`, `worked_example`, `socratic`, `metacognitive_prompting`, `chain_of_thought`
153
+
154
+ **Returns:** Structured scaffolding with step-by-step guidance adapted to task complexity.
155
+
156
+ ### 5. `cognition/cognitive-load`
157
+
158
+ Monitor and balance cognitive load during reasoning.
159
+
160
+ ```typescript
161
+ const result = await mcp.call('cognition/cognitive-load', {
162
+ assessment: {
163
+ intrinsic: 0.7, // Task complexity
164
+ extraneous: 0.3, // Presentation complexity
165
+ germane: 0.5 // Learning investment
166
+ },
167
+ optimization: 'reduce_extraneous',
168
+ threshold: 0.8
169
+ });
170
+ ```
171
+
172
+ **Optimizations:** `reduce_extraneous`, `chunk_intrinsic`, `maximize_germane`, `balanced`
173
+
174
+ **Returns:** Load assessment with optimization recommendations and intervention triggers.
175
+
176
+ ## Configuration Options
177
+
178
+ ```typescript
179
+ interface CognitiveKernelConfig {
180
+ // Maximum working memory slots (default: 7, Miller's number)
181
+ maxWorkingMemorySlots: number;
182
+
183
+ // Memory limit in MB (default: 256)
184
+ memoryLimit: number;
185
+
186
+ // CPU time limit per operation in seconds (default: 10)
187
+ cpuTimeLimit: number;
188
+
189
+ // Enable session isolation (default: true)
190
+ sessionIsolation: boolean;
191
+
192
+ // Scaffold fading configuration
193
+ scaffolding: {
194
+ enableFading: boolean;
195
+ fadingRate: number;
196
+ };
197
+
198
+ // Meta-cognitive intervention thresholds
199
+ metaCognition: {
200
+ confidenceThreshold: number;
201
+ coherenceThreshold: number;
202
+ autoIntervene: boolean;
203
+ };
204
+ }
205
+ ```
206
+
207
+ ## Performance Targets
208
+
209
+ | Metric | Target | Notes |
210
+ |--------|--------|-------|
211
+ | Working memory operations | <1ms per slot | 10x faster than naive cache |
212
+ | Attention steering | <5ms for reallocation | 10x faster than context rebuild |
213
+ | Meta-cognitive check | <10ms per assessment | Novel capability |
214
+ | Memory consolidation | <100ms batch | 10x faster than full reindex |
215
+ | Scaffold generation | <50ms per step | Novel capability |
216
+
217
+ ## Cognitive Theories Implemented
218
+
219
+ | Theory | Implementation |
220
+ |--------|----------------|
221
+ | Baddeley's Working Memory | Multi-component memory system with phonological loop, visuospatial sketchpad, and episodic buffer |
222
+ | Cognitive Load Theory | Intrinsic/extraneous/germane load management |
223
+ | Metacognition | Self-monitoring, error detection, and regulation |
224
+ | Zone of Proximal Development | Adaptive scaffolding with gradual fading |
225
+ | Dual Process Theory | Fast/slow thinking modes |
226
+
227
+ ## Security Considerations
228
+
229
+ - **Session Isolation**: Each cognitive session has isolated working memory with session-specific encryption keys (AES-256-GCM)
230
+ - **Secure Clearing**: Working memory is securely cleared and overwritten (zero-fill) at session end
231
+ - **Prompt Injection Prevention**: Scaffold content is sanitized to remove potential prompt injection patterns (special tokens, control sequences)
232
+ - **Input Validation**: All inputs validated with Zod schemas with strict limits
233
+ - **Rate Limiting**: Prevents abuse of cognitive resources
234
+ - **Content Filtering**: Memory content scanned for sensitive data patterns before storage
235
+
236
+ ### WASM Security Constraints
237
+
238
+ | Constraint | Value | Rationale |
239
+ |------------|-------|-----------|
240
+ | Memory Limit | 256MB | Sufficient for cognitive operations |
241
+ | CPU Time per Operation | 10 seconds | Prevent runaway processing |
242
+ | No Network Access | Enforced | Prevent data exfiltration |
243
+ | Session Isolation | Enforced | Per-session WASM instances |
244
+ | Secure Memory Clear | Zero-fill on exit | Prevent memory forensics |
245
+
246
+ ### Input Limits
247
+
248
+ | Constraint | Limit |
249
+ |------------|-------|
250
+ | Working memory slots | 20 max |
251
+ | Memory limit | 256MB |
252
+ | CPU time per operation | 10 seconds |
253
+ | Attention targets | 50 max |
254
+ | Scaffold description | 5,000 characters |
255
+
256
+ ### Rate Limits
257
+
258
+ | Tool | Requests/Minute | Max Concurrent |
259
+ |------|-----------------|----------------|
260
+ | `working-memory` | 120 | 10 |
261
+ | `attention-control` | 60 | 5 |
262
+ | `meta-monitor` | 60 | 5 |
263
+ | `scaffold` | 30 | 3 |
264
+ | `cognitive-load` | 60 | 5 |
265
+
266
+ ## Dependencies
267
+
268
+ - `cognitum-gate-kernel` - Core cognitive kernel for memory gating and attention control
269
+ - `sona` - Self-Optimizing Neural Architecture for adaptive cognition
270
+ - `ruvector-attention-wasm` - Multi-head attention for cognitive focus
271
+ - `ruvector-nervous-system-wasm` - Coordination between cognitive subsystems
272
+ - `micro-hnsw-wasm` - Fast retrieval for episodic memory
273
+
274
+ ## Use Cases
275
+
276
+ 1. **Complex Reasoning**: Support multi-step reasoning with working memory persistence
277
+ 2. **Research Synthesis**: Maintain focus across long document analysis sessions
278
+ 3. **Learning Enhancement**: Adaptive scaffolding for skill acquisition
279
+ 4. **Error Prevention**: Meta-cognitive monitoring catches reasoning errors before output
280
+ 5. **Context Management**: Intelligent attention control for managing long contexts
281
+
282
+ ## Related Plugins
283
+
284
+ | Plugin | Description | Synergy |
285
+ |--------|-------------|---------|
286
+ | [@claude-flow/plugin-neural-coordination](https://www.npmjs.com/package/@claude-flow/plugin-neural-coordination) | Multi-agent coordination | Cognitive kernel provides enhanced reasoning for coordinated agents |
287
+ | [@claude-flow/plugin-hyperbolic-reasoning](https://www.npmjs.com/package/@claude-flow/plugin-hyperbolic-reasoning) | Hierarchical reasoning | Combines hierarchical structure with cognitive scaffolding |
288
+ | [@claude-flow/plugin-quantum-optimizer](https://www.npmjs.com/package/@claude-flow/plugin-quantum-optimizer) | Quantum-inspired optimization | Optimizes cognitive resource allocation and attention scheduling |
289
+
290
+ ## Architecture
291
+
292
+ ```
293
+ +------------------+ +----------------------+ +------------------+
294
+ | LLM Input |---->| Cognitive Kernel |---->| Enhanced Output |
295
+ | (Prompts) | | (WASM Accelerated) | | (Augmented) |
296
+ +------------------+ +----------------------+ +------------------+
297
+ |
298
+ +--------------------+--------------------+
299
+ | | |
300
+ +------+------+ +-------+-------+ +------+------+
301
+ | Cognitum | | SONA | | Attention |
302
+ | Gate Kernel | | Self-Optimize | | Control |
303
+ +-------------+ +---------------+ +-------------+
304
+ | | |
305
+ +--------------------+--------------------+
306
+ |
307
+ +-------+-------+
308
+ | Working Memory |
309
+ | (HNSW Index) |
310
+ +---------------+
311
+ ```
312
+
313
+ ## License
314
+
315
+ MIT
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@sparkleideas/plugin-cognitive-kernel",
3
+ "version": "3.0.0-alpha.11",
4
+ "description": "Cognitive kernel plugin for LLM augmentation with working memory, attention control, meta-cognition, and scaffolding",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./tools": {
15
+ "import": "./dist/mcp-tools.js",
16
+ "types": "./dist/mcp-tools.d.ts"
17
+ },
18
+ "./bridges": {
19
+ "import": "./dist/bridges/index.js",
20
+ "types": "./dist/bridges/index.d.ts"
21
+ },
22
+ "./types": {
23
+ "import": "./dist/types.js",
24
+ "types": "./dist/types.d.ts"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md",
30
+ "plugin.yaml"
31
+ ],
32
+ "scripts": {
33
+ "build": "tsc",
34
+ "dev": "tsc --watch",
35
+ "clean": "rimraf dist",
36
+ "test": "vitest run",
37
+ "test:watch": "vitest",
38
+ "lint": "eslint src --ext .ts",
39
+ "typecheck": "tsc --noEmit",
40
+ "prepublishOnly": "npm run clean && npm run build && npm run typecheck"
41
+ },
42
+ "keywords": [
43
+ "claude-flow",
44
+ "cognitive-kernel",
45
+ "working-memory",
46
+ "attention",
47
+ "meta-cognition",
48
+ "scaffolding",
49
+ "sona",
50
+ "cognitum"
51
+ ],
52
+ "author": "Claude Flow Team",
53
+ "license": "MIT",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/ruvnet/claude-flow.git",
57
+ "directory": "v3/plugins/cognitive-kernel"
58
+ },
59
+ "dependencies": {
60
+ "zod": "^3.22.4"
61
+ },
62
+ "devDependencies": {
63
+ "@types/node": "^20.10.0",
64
+ "rimraf": "^5.0.5",
65
+ "typescript": "^5.3.0",
66
+ "vitest": "^4.0.16"
67
+ },
68
+ "peerDependencies": {
69
+ "@sparkleideas/ruvector-upstream": "*"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "@claude-flow/ruvector-upstream": {
73
+ "optional": true
74
+ }
75
+ },
76
+ "engines": {
77
+ "node": ">=18.0.0"
78
+ },
79
+ "publishConfig": {
80
+ "access": "public",
81
+ "tag": "v3alpha"
82
+ }
83
+ }