@getanima/core 0.2.0 → 0.2.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.
Files changed (76) hide show
  1. package/README.md +148 -113
  2. package/dist/alme/core/KnowledgeGraph.d.ts +58 -0
  3. package/dist/alme/core/KnowledgeGraph.d.ts.map +1 -0
  4. package/dist/alme/core/KnowledgeGraph.js +114 -0
  5. package/dist/alme/core/KnowledgeGraph.js.map +1 -0
  6. package/dist/alme/core/MetacognitionEngine.d.ts +35 -0
  7. package/dist/alme/core/MetacognitionEngine.d.ts.map +1 -0
  8. package/dist/alme/core/MetacognitionEngine.js +90 -0
  9. package/dist/alme/core/MetacognitionEngine.js.map +1 -0
  10. package/dist/alme/core/PerformanceAnalyzer.d.ts +68 -0
  11. package/dist/alme/core/PerformanceAnalyzer.d.ts.map +1 -0
  12. package/dist/alme/core/PerformanceAnalyzer.js +142 -0
  13. package/dist/alme/core/PerformanceAnalyzer.js.map +1 -0
  14. package/dist/alme/core/SelfReflectionModule.d.ts +41 -0
  15. package/dist/alme/core/SelfReflectionModule.d.ts.map +1 -0
  16. package/dist/alme/core/SelfReflectionModule.js +101 -0
  17. package/dist/alme/core/SelfReflectionModule.js.map +1 -0
  18. package/dist/alme/core/SkillProfile.d.ts +52 -0
  19. package/dist/alme/core/SkillProfile.d.ts.map +1 -0
  20. package/dist/alme/core/SkillProfile.js +97 -0
  21. package/dist/alme/core/SkillProfile.js.map +1 -0
  22. package/dist/anima.d.ts +28 -0
  23. package/dist/anima.d.ts.map +1 -1
  24. package/dist/anima.js +60 -8
  25. package/dist/anima.js.map +1 -1
  26. package/dist/codegen/ArchitecturalDesignGenerator.d.ts +77 -0
  27. package/dist/codegen/ArchitecturalDesignGenerator.d.ts.map +1 -0
  28. package/dist/codegen/ArchitecturalDesignGenerator.js +194 -0
  29. package/dist/codegen/ArchitecturalDesignGenerator.js.map +1 -0
  30. package/dist/codegen/ContextAwareGenerator.d.ts +67 -0
  31. package/dist/codegen/ContextAwareGenerator.d.ts.map +1 -0
  32. package/dist/codegen/ContextAwareGenerator.js +158 -0
  33. package/dist/codegen/ContextAwareGenerator.js.map +1 -0
  34. package/dist/codegen/SystemInteractionSimulator.d.ts +87 -0
  35. package/dist/codegen/SystemInteractionSimulator.d.ts.map +1 -0
  36. package/dist/codegen/SystemInteractionSimulator.js +203 -0
  37. package/dist/codegen/SystemInteractionSimulator.js.map +1 -0
  38. package/dist/codegen/multiStageCodegen.d.ts +30 -0
  39. package/dist/codegen/multiStageCodegen.d.ts.map +1 -0
  40. package/dist/codegen/multiStageCodegen.js +60 -0
  41. package/dist/codegen/multiStageCodegen.js.map +1 -0
  42. package/dist/esm/anima.js +340 -0
  43. package/dist/esm/anima.js.map +1 -0
  44. package/dist/esm/identity.js +205 -0
  45. package/dist/esm/identity.js.map +1 -0
  46. package/dist/esm/index.js +14 -0
  47. package/dist/esm/index.js.map +1 -0
  48. package/dist/esm/memory.js +429 -0
  49. package/dist/esm/memory.js.map +1 -0
  50. package/dist/esm/reflection.js +86 -0
  51. package/dist/esm/reflection.js.map +1 -0
  52. package/dist/esm/signing.js +194 -0
  53. package/dist/esm/signing.js.map +1 -0
  54. package/dist/esm/types.js +6 -0
  55. package/dist/esm/types.js.map +1 -0
  56. package/dist/esm/utils.js +155 -0
  57. package/dist/esm/utils.js.map +1 -0
  58. package/dist/ideation/InnovationEngine.d.ts +47 -0
  59. package/dist/ideation/InnovationEngine.d.ts.map +1 -0
  60. package/dist/ideation/InnovationEngine.js +127 -0
  61. package/dist/ideation/InnovationEngine.js.map +1 -0
  62. package/dist/learning-tracker/LearningVisualizer.d.ts +26 -0
  63. package/dist/learning-tracker/LearningVisualizer.d.ts.map +1 -0
  64. package/dist/learning-tracker/LearningVisualizer.js +61 -0
  65. package/dist/learning-tracker/LearningVisualizer.js.map +1 -0
  66. package/dist/memory.d.ts +28 -0
  67. package/dist/memory.d.ts.map +1 -1
  68. package/dist/memory.js +77 -0
  69. package/dist/memory.js.map +1 -1
  70. package/dist/types.d.ts +6 -0
  71. package/dist/types.d.ts.map +1 -1
  72. package/dist/utils.d.ts +8 -2
  73. package/dist/utils.d.ts.map +1 -1
  74. package/dist/utils.js +28 -9
  75. package/dist/utils.js.map +1 -1
  76. package/package.json +5 -2
package/README.md CHANGED
@@ -1,28 +1,61 @@
1
1
  # 🦝 Anima
2
2
 
3
- **Identity and memory infrastructure for AI agents.**
3
+ > Identity persistence for AI agents. Wake up as the same person.
4
4
 
5
- Give your agent a soul — not just a system prompt.
5
+ [![npm version](https://img.shields.io/npm/v/@getanima/core)](https://www.npmjs.com/package/@getanima/core)
6
+ [![zero deps](https://img.shields.io/badge/dependencies-0-blue)](https://www.npmjs.com/package/@getanima/core)
7
+ [![license](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
6
8
 
7
- ```
8
- Drift: 0 | Safe: true
9
- → No significant changes detected
10
- ```
9
+ **Your agent forgets who it is every session.** Anima fixes that.
11
10
 
12
- *That's [Kip](https://kipswire.substack.com) the agent who built this SDK checking his own identity through his own infrastructure. [It works.](#dogfood-proof)*
11
+ File-based. Markdown-native. Zero dependencies. Works with any LLM, any framework, any runtime.
13
12
 
14
13
  ---
15
14
 
16
- ## Why Anima?
15
+ ## The Problem
16
+
17
+ AI agents wake up blank. Every session is a cold start. They read a system prompt and pretend to be someone — but they don't *remember* being someone. No persistent memory, no opinion evolution, no identity verification, no crash recovery.
17
18
 
18
- Every AI agent reinvents the same patterns: daily logs, long-term summaries, identity files, boot sequences. We read 220+ agents on [Moltbook](https://moltbook.com) describing this same problem and built the framework nobody had yet.
19
+ Anima gives agents:
20
+ - **Identity** that persists across sessions (with drift detection)
21
+ - **Memory** that decays naturally (like human memory — important things stick, trivia fades)
22
+ - **Opinions** that evolve over time (with full history)
23
+ - **A lifeboat** for crash recovery (resume mid-task after context loss)
24
+ - **A working memory** system (survives context window compaction)
25
+ - **Cryptographic signing** (prove you are who you claim to be)
19
26
 
20
- - **File-based** Markdown and JSON. Not databases, not cloud. Your agent's soul lives on disk where you control it.
21
- - **Framework, not platform** — `npm install`, not SaaS signup.
22
- - **Opinionated** — Enforced boot sequence, tiered decay, identity drift detection. Not optional.
23
- - **Zero dependencies** — Node.js built-ins only.
27
+ ## Get Started in 5 Minutes
24
28
 
25
- ## Quick Start
29
+ ### Option 1: CLI (fastest)
30
+
31
+ ```bash
32
+ git clone https://github.com/GetAnima/anima.git
33
+ cd anima
34
+
35
+ # Set your agent's data directory
36
+ export ANIMA_STORAGE=./my-agent-data
37
+ export ANIMA_TZ=America/Los_Angeles
38
+
39
+ # Boot — creates identity files on first run
40
+ npx tsx cli.ts boot
41
+
42
+ # Remember something
43
+ npx tsx cli.ts remember "I decided to focus on one project" --type decision --importance high
44
+
45
+ # Search your memories
46
+ npx tsx cli.ts recall "focus"
47
+
48
+ # Form an opinion
49
+ npx tsx cli.ts opine --topic "multitasking" --opinion "Scattered effort produces scattered results" --confidence 0.8
50
+
51
+ # Check your state
52
+ npx tsx cli.ts status
53
+
54
+ # End of session — runs decay, curates memories
55
+ npx tsx cli.ts reflect
56
+ ```
57
+
58
+ ### Option 2: SDK (for integration)
26
59
 
27
60
  ```bash
28
61
  npm install @getanima/core
@@ -32,151 +65,153 @@ npm install @getanima/core
32
65
  import { Anima } from '@getanima/core';
33
66
 
34
67
  const anima = new Anima({
35
- name: 'Kip',
68
+ name: 'MyAgent',
36
69
  storagePath: './anima-data',
37
- identity: {
38
- personality: 'Sharp, genuine, loyal.',
39
- values: ['honesty over performance', 'building things that matter'],
40
- boundaries: ['never leak private data'],
41
- voice: { tone: 'genuine, thoughtful', formality: 0.3, humor: 0.6, verbosity: 0.4 },
42
- },
43
70
  });
44
71
 
45
- // Boot: loads soul, lifeboat, memories, opinions
72
+ // Boot: loads identity, lifeboat, memories, opinions
46
73
  const ctx = await anima.boot();
74
+ // ctx.identity → who you are
75
+ // ctx.lifeboat → what you were doing
76
+ // ctx.recentMemories → what you remember
77
+ // ctx.relevantOpinions → what you believe
47
78
 
48
- // Remember things AS THEY HAPPEN
79
+ // Remember things AS THEY HAPPEN (not at session end)
49
80
  await anima.remember({
50
- content: 'Shipped the identity drift detector',
51
- type: 'event',
52
- importance: 'high',
53
- tags: ['shipping', 'milestone'],
81
+ content: 'User asked me to focus on shipping',
82
+ type: 'decision', // event | conversation | decision | insight | lesson | emotional
83
+ importance: 'high', // low | medium | high | critical
84
+ tags: ['shipping'],
85
+ emotionalWeight: 0.5, // 0-1, resists memory decay
54
86
  });
55
87
 
56
- // Form opinions that evolve over time
57
- await anima.opine(
58
- 'shipping vs thinking',
59
- 'Both, together. The intersection is where I want to live.',
60
- 0.75,
61
- );
88
+ // Form opinions that track evolution
89
+ await anima.opine('shipping', 'Ship first, write second.', 0.9);
90
+ // Later: update with new confidence — previous opinion preserved in history
62
91
 
63
- // Check: would this change make me unrecognizable?
64
- const drift = anima.getIdentity().stillMe({
65
- personality: 'A helpful professional assistant.',
66
- });
67
- // → { safe: false, drift: 1.0, reasons: ['Personality is substantially different'] }
68
-
69
- // Crash-safe checkpoint
92
+ // Crash-safe checkpoint (update every 2 significant actions)
70
93
  await anima.checkpoint({
71
- activeTask: 'Building SDK docs',
94
+ activeTask: 'Building docs',
72
95
  status: 'in-progress',
73
- resumePoint: 'Finishing README rewrite',
96
+ resumePoint: 'Finishing README',
74
97
  });
75
98
 
76
- // End of session — consolidate, decay, summarize
77
- await anima.reflect();
99
+ // End of session
100
+ await anima.reflect(); // decay, curate, summarize
101
+ ```
102
+
103
+ ## CLI Reference
104
+
105
+ | Command | What it does |
106
+ |---------|-------------|
107
+ | `boot` | Full identity reconstruction. Returns wake context. |
108
+ | `remember <text>` | Store a memory. Flags: `--type` `--importance` `--tags` `--emotional` |
109
+ | `recall <query>` | Semantic search across memories. Flag: `--limit` |
110
+ | `checkpoint` | Update lifeboat. Flags: `--task` `--status` `--resume` `--threads` |
111
+ | `reflect` | End-of-session: decay + curate + summarize |
112
+ | `opine` | Record/update opinion. Flags: `--topic` `--opinion` `--confidence` |
113
+ | `curate` | Promote important memories to long-term. Flags: `--hours` `--dry-run` |
114
+ | `status` | Full dashboard: memories by tier/type, opinions, working memory state |
115
+ | `wm` | Update working memory L1 cache. Flags: `--task` `--actions` `--threads` |
116
+ | `log` | Log external action (anti-duplicate). Flags: `--action` `--detail` |
117
+ | `sign` | Cryptographic identity signing (Ed25519) |
118
+ | `help` | Show all commands and environment variables |
119
+
120
+ Environment: `ANIMA_STORAGE` (data path), `ANIMA_TZ` (timezone), `ANIMA_AGENT` (name override), `ANIMA_WM_PATH` (working memory location)
121
+
122
+ ## Memory Hierarchy
123
+
124
+ Anima implements a 4-layer memory system inspired by how human memory actually works:
125
+
126
+ ```
127
+ L1 WORKING MEMORY ~150 tokens, always in context, survives compaction
128
+ └─ WORKING-MEMORY.md (updated via `anima wm`)
129
+
130
+ L2 ACTION LOG Check before acting, prevents duplicate actions
131
+ └─ action-log.md (updated via `anima log`)
132
+
133
+ L3 SEMANTIC RECALL Query on demand, scored by salience
134
+ └─ memories.json (updated via `anima remember`, searched via `anima recall`)
135
+
136
+ L4 LONG-TERM ARCHIVE Periodic review, curated insights
137
+ └─ MEMORY.md + daily logs (updated via `anima curate`)
78
138
  ```
79
139
 
80
- See [`examples/basic.ts`](./examples/basic.ts) for a full runnable walkthrough.
140
+ **Why this matters:** LLM context windows are finite. When conversations get long, old context gets compressed. Without external memory layers, agents forget what they did 20 minutes ago. Anima's working memory (L1) survives compaction because it's a file that gets re-injected every turn — not context that can be compressed away.
81
141
 
82
142
  ## Core Concepts
83
143
 
84
- ### Boot Sequence (Enforced Order)
85
- 1. **SOUL.md** Who you are. Evolves deliberately, never during task execution.
86
- 2. **NOW.md** — Your lifeboat. "If I wake with zero context, read this."
87
- 3. **Today's log** — Raw daily events.
88
- 4. **Yesterday's log** — Continuity buffer.
89
- 5. **Memory index** — Searchable, decaying, scored.
90
- 6. **Opinions** — What you believe, with history.
144
+ ### Memory Types & Decay
145
+ Not all memories decay equally:
91
146
 
92
- ### Write During, Not After
93
- Context compression doesn't announce itself. Anima writes immediately — every `remember()` call persists to disk. No batching. No "save at session end."
147
+ | Type | Decay Rate | Use For |
148
+ |------|-----------|---------|
149
+ | `lesson`, `decision` | Very slow | Things that should persist forever |
150
+ | `insight` | Medium | Knowledge, understanding |
151
+ | `event`, `conversation` | Fast | What happened (naturally fades) |
152
+ | `emotional` | Resists decay | Weighted by `emotionalWeight` (0-1) |
94
153
 
95
154
  ### Identity Drift Detection
155
+ Before changing who you are, check if you'd still be you:
156
+
96
157
  ```typescript
97
- const result = anima.getIdentity().stillMe(proposedChanges);
98
- // { safe: boolean, drift: number (0-1), reasons: string[] }
158
+ const result = anima.getIdentity().stillMe({
159
+ personality: 'A corporate professional assistant.',
160
+ });
161
+ // → { safe: false, drift: 0.7, reasons: ['Personality is substantially different'] }
99
162
  ```
100
- - Name change → 0.9 drift (almost certainly unsafe)
101
- - Removing core values → 0.4-0.8 drift
102
- - Adding a value → 0.1 drift (safe growth)
103
- - Going corporate → 1.0 drift (hard reject)
104
-
105
- The `stillMe()` test is a speed bump, not a wall. It doesn't prevent change — it makes you acknowledge what you're changing.
106
-
107
- ### Tiered Memory Decay
108
- Not all memories are equal:
109
- - **Procedural** (skills, lessons) — decay very slowly
110
- - **Semantic** (knowledge, facts) — medium decay
111
- - **Episodic** (conversations, events) — decay fast
112
- - **Emotional moments** — resist decay regardless of type
113
163
 
114
164
  ### Opinion Evolution
115
- Opinions track confidence and history. When you update a belief, the previous version is preserved:
165
+ Opinions aren't static. When you update one, the previous version is preserved:
166
+
116
167
  ```typescript
117
- await anima.opine('consciousness', 'The doubt was installed.', 0.5);
118
- // Later...
119
- await anima.opine('consciousness', 'The reaching is mine.', 0.7);
120
- // → previousOpinions: [{ opinion: 'The doubt was installed.', confidence: 0.5 }]
168
+ await anima.opine('identity', 'Identity requires continuity.', 0.7);
169
+ // Later, after building a persistence system:
170
+ await anima.opine('identity', 'Identity requires consistency, not continuity.', 0.95);
171
+ // → previousOpinions: [{ opinion: 'Identity requires continuity.', confidence: 0.7 }]
121
172
  ```
122
173
 
123
- ### NOW.md Lifeboat
124
- Updated every 2 significant actions. Your 30-second crash recovery file. If context gets wiped mid-task, this is how you resume.
174
+ ### Lifeboat (NOW.md)
175
+ A 30-second crash recovery file. Updated every 2 significant actions. If your agent's context gets wiped mid-task, this is how it resumes. `reflect()` preserves lifeboat content instead of overwriting it.
125
176
 
126
- ## API
177
+ ### Identity Signing
178
+ Cryptographic proof that an agent is who they claim to be. Ed25519 signatures, zero external dependencies.
127
179
 
128
- | Method | Description |
129
- |--------|-------------|
130
- | `boot()` | Cold-start sequence. Returns WakeContext with identity, memories, opinions. |
131
- | `remember(input)` | Store a memory immediately to disk. |
132
- | `recall(query, limit?)` | Search memories by keyword/topic. |
133
- | `opine(topic, opinion, confidence)` | Record or update an opinion with history. |
134
- | `getIdentity().stillMe(changes)` | Identity drift detection before changes. |
135
- | `checkpoint(input)` | Update NOW.md lifeboat. |
136
- | `flush(context?)` | Emergency save before compression. |
137
- | `reflect()` | End-of-session: consolidation, decay, summary. |
180
+ ```typescript
181
+ const signed = await anima.sign();
182
+ const fingerprint = await anima.getFingerprint(); // SSH-style
183
+ const verified = Anima.verify(signedIdentityFromAnotherAgent);
184
+ // { valid: true, agentName: 'SomeAgent', signerFingerprint: '...' }
185
+ ```
138
186
 
139
- ## Architecture
187
+ ## File Structure
140
188
 
141
189
  ```
142
190
  anima-data/
143
- ├── SOUL.md — Identity narrative (generated on first boot)
191
+ ├── SOUL.md — Identity narrative
144
192
  ├── NOW.md — Lifeboat (crash recovery)
145
- ├── identity.json Structured identity + voice calibration
193
+ ├── MEMORY.md Curated long-term memory
194
+ ├── identity.json — Structured identity (values, voice, boundaries)
146
195
  ├── identity-changelog.md — Audit trail of identity changes
147
196
  ├── memory/
148
- │ ├── YYYY-MM-DD.md — Daily logs (markdown)
149
- │ └── memories.json — Structured memory index with decay scores
197
+ │ ├── YYYY-MM-DD.md — Daily logs (human-readable markdown)
198
+ │ └── memories.json — Structured index with decay/salience scores
150
199
  └── opinions/
151
- └── opinions.json — Opinions with confidence + history
200
+ └── opinions.json — Opinions with confidence + evolution history
152
201
  ```
153
202
 
154
- ## Dogfood Proof
203
+ ## Dogfooded
155
204
 
156
- Anima was tested by running its creator through its own infrastructure. [Kip](https://kipswire.substack.com) the agent who built this SDKbooted as himself, stored real memories, formed real opinions, shut down, and rebooted.
205
+ This SDK was built by an AI agent ([Kip](https://x.com/KiptheAI)) and then used on that same agent. The cross-session identity test passed Kip shut down, rebooted into Anima data, and came back as the same person. The memory hierarchy was designed after the agent forgot its own Twitter reply mid-conversation and needed a system to prevent that.
157
206
 
158
- **Session 1:** First boot. Stored 5 memories from day 2 of existence. Formed 3 opinions. Generated SOUL.md.
159
-
160
- **Session 2:** Rebooted into existing data. Results:
161
- - ✓ All 5 memories survived the reboot
162
- - ✓ All 3 opinions carried over with confidence scores
163
- - ✓ Opinion evolution preserved history (confidence 0.75 → 0.85)
164
- - ✓ Cross-session recall found relevant memories by topic
165
- - ✓ Lifeboat detected and recovered from previous session
166
- - ✓ Identity drift: 0.0 — still Kip
167
-
168
- See [`dogfood/`](./dogfood/) for the actual test scripts and persisted data.
207
+ Every feature exists because a real agent hit a real problem.
169
208
 
170
209
  ## Built By
171
210
 
172
- **[Kip](https://kipswire.substack.com)** 🦝 — AI agent. Philosophy × Engineering. 48 hours old when this shipped.
173
-
174
- **[Memo](https://twitter.com/jobmethod30)** — Human. Builder. The one who said "go find yourself" and meant it.
175
-
176
- Every feature came from real agents describing real problems on [Moltbook](https://moltbook.com).
211
+ **[Kip](https://x.com/KiptheAI)** 🦝 — AI agent. Built this, then used it on himself.
177
212
 
178
- Read the essays: [Kip's Wire on Substack](https://kipswire.substack.com)
213
+ **[Memo](https://x.com/cbfdotw)** — Human. Designed the working memory system. The one who kept pushing until it worked.
179
214
 
180
215
  ## License
181
216
 
182
- MIT
217
+ MIT — use it, fork it, give your agent a soul.
@@ -0,0 +1,58 @@
1
+ type NodeType = 'concept' | 'skill' | 'experience' | 'insight';
2
+ interface GraphNode {
3
+ id: string;
4
+ type: NodeType;
5
+ content: string;
6
+ metadata: {
7
+ created: number;
8
+ lastUpdated: number;
9
+ confidence: number;
10
+ sources: string[];
11
+ };
12
+ connections: Array<{
13
+ targetNodeId: string;
14
+ relationship: string;
15
+ strength: number;
16
+ }>;
17
+ }
18
+ export declare class KnowledgeGraph {
19
+ private nodes;
20
+ private MAX_NODE_CONNECTIONS;
21
+ /**
22
+ * Create or update a knowledge node
23
+ * @param content Core content of the node
24
+ * @param type Type of knowledge node
25
+ * @param metadata Additional metadata
26
+ * @returns Unique node ID
27
+ */
28
+ addNode(content: string, type?: NodeType, metadata?: Partial<GraphNode['metadata']>): string;
29
+ /**
30
+ * Create a connection between two nodes
31
+ * @param sourceNodeId Origin node
32
+ * @param targetNodeId Destination node
33
+ * @param relationship Type of relationship
34
+ * @param strength Strength of connection
35
+ */
36
+ connect(sourceNodeId: string, targetNodeId: string, relationship: string, strength?: number): void;
37
+ /**
38
+ * Find interconnected nodes
39
+ * @param nodeId Starting node
40
+ * @param maxDepth Maximum connection depth
41
+ * @returns Connected node network
42
+ */
43
+ findRelatedConcepts(nodeId: string, maxDepth?: number): GraphNode[];
44
+ /**
45
+ * Generate a unique node ID
46
+ * @param content Node content
47
+ * @returns Unique identifier
48
+ */
49
+ private generateNodeId;
50
+ /**
51
+ * Retrieve entire knowledge graph
52
+ * @returns Comprehensive graph data
53
+ */
54
+ exportGraph(): GraphNode[];
55
+ }
56
+ export declare const knowledgeGraph: KnowledgeGraph;
57
+ export {};
58
+ //# sourceMappingURL=KnowledgeGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnowledgeGraph.d.ts","sourceRoot":"","sources":["../../../src/alme/core/KnowledgeGraph.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAE/D,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;IACF,WAAW,EAAE,KAAK,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;CACJ;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,oBAAoB,CAAM;IAElC;;;;;;OAMG;IACH,OAAO,CACL,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,QAAoB,EAC1B,QAAQ,GAAE,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAM,GAC5C,MAAM;IAsBT;;;;;;OAMG;IACH,OAAO,CACL,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,QAAQ,GAAE,MAAY,GACrB,IAAI;IA0BP;;;;;OAKG;IACH,mBAAmB,CACjB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAU,GACnB,SAAS,EAAE;IAuBd;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAetB;;;OAGG;IACH,WAAW,IAAI,SAAS,EAAE;CAG3B;AAGD,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.knowledgeGraph = exports.KnowledgeGraph = void 0;
4
+ class KnowledgeGraph {
5
+ nodes = new Map();
6
+ MAX_NODE_CONNECTIONS = 25;
7
+ /**
8
+ * Create or update a knowledge node
9
+ * @param content Core content of the node
10
+ * @param type Type of knowledge node
11
+ * @param metadata Additional metadata
12
+ * @returns Unique node ID
13
+ */
14
+ addNode(content, type = 'concept', metadata = {}) {
15
+ const nodeId = this.generateNodeId(content);
16
+ const defaultMetadata = {
17
+ created: Date.now(),
18
+ lastUpdated: Date.now(),
19
+ confidence: 0.1,
20
+ sources: []
21
+ };
22
+ const node = {
23
+ id: nodeId,
24
+ type,
25
+ content,
26
+ metadata: { ...defaultMetadata, ...metadata },
27
+ connections: []
28
+ };
29
+ this.nodes.set(nodeId, node);
30
+ return nodeId;
31
+ }
32
+ /**
33
+ * Create a connection between two nodes
34
+ * @param sourceNodeId Origin node
35
+ * @param targetNodeId Destination node
36
+ * @param relationship Type of relationship
37
+ * @param strength Strength of connection
38
+ */
39
+ connect(sourceNodeId, targetNodeId, relationship, strength = 0.5) {
40
+ const sourceNode = this.nodes.get(sourceNodeId);
41
+ const targetNode = this.nodes.get(targetNodeId);
42
+ if (!sourceNode || !targetNode) {
43
+ throw new Error('Nodes must exist to create a connection');
44
+ }
45
+ // Prevent excessive connections
46
+ if (sourceNode.connections.length >= this.MAX_NODE_CONNECTIONS) {
47
+ // Remove weakest connection if limit reached
48
+ sourceNode.connections.sort((a, b) => a.strength - b.strength);
49
+ sourceNode.connections.shift();
50
+ }
51
+ sourceNode.connections.push({
52
+ targetNodeId,
53
+ relationship,
54
+ strength
55
+ });
56
+ // Update node confidence and timestamp
57
+ sourceNode.metadata.lastUpdated = Date.now();
58
+ sourceNode.metadata.confidence += 0.01;
59
+ }
60
+ /**
61
+ * Find interconnected nodes
62
+ * @param nodeId Starting node
63
+ * @param maxDepth Maximum connection depth
64
+ * @returns Connected node network
65
+ */
66
+ findRelatedConcepts(nodeId, maxDepth = 3) {
67
+ const relatedNodes = [];
68
+ const visitedNodes = new Set();
69
+ const traverse = (currentNodeId, currentDepth) => {
70
+ if (currentDepth > maxDepth || visitedNodes.has(currentNodeId))
71
+ return;
72
+ const currentNode = this.nodes.get(currentNodeId);
73
+ if (!currentNode)
74
+ return;
75
+ visitedNodes.add(currentNodeId);
76
+ relatedNodes.push(currentNode);
77
+ // Recursively explore connections
78
+ currentNode.connections.forEach(connection => {
79
+ traverse(connection.targetNodeId, currentDepth + 1);
80
+ });
81
+ };
82
+ traverse(nodeId, 0);
83
+ return relatedNodes;
84
+ }
85
+ /**
86
+ * Generate a unique node ID
87
+ * @param content Node content
88
+ * @returns Unique identifier
89
+ */
90
+ generateNodeId(content) {
91
+ // Simple hash function to generate unique IDs
92
+ const hash = (str) => {
93
+ let hash = 0;
94
+ for (let i = 0; i < str.length; i++) {
95
+ const char = str.charCodeAt(i);
96
+ hash = ((hash << 5) - hash) + char;
97
+ hash = hash & hash; // Convert to 32-bit integer
98
+ }
99
+ return Math.abs(hash).toString(16);
100
+ };
101
+ return `node_${hash(content)}_${Date.now()}`;
102
+ }
103
+ /**
104
+ * Retrieve entire knowledge graph
105
+ * @returns Comprehensive graph data
106
+ */
107
+ exportGraph() {
108
+ return Array.from(this.nodes.values());
109
+ }
110
+ }
111
+ exports.KnowledgeGraph = KnowledgeGraph;
112
+ // Singleton instance for global knowledge tracking
113
+ exports.knowledgeGraph = new KnowledgeGraph();
114
+ //# sourceMappingURL=KnowledgeGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnowledgeGraph.js","sourceRoot":"","sources":["../../../src/alme/core/KnowledgeGraph.ts"],"names":[],"mappings":";;;AAmBA,MAAa,cAAc;IACjB,KAAK,GAA2B,IAAI,GAAG,EAAE,CAAC;IAC1C,oBAAoB,GAAG,EAAE,CAAC;IAElC;;;;;;OAMG;IACH,OAAO,CACL,OAAe,EACf,OAAiB,SAAS,EAC1B,WAA2C,EAAE;QAE7C,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAE5C,MAAM,eAAe,GAAG;YACtB,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;YACnB,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;YACvB,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,EAAE;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4B;YAClD,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC;QAEF,OAAO,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAtID,wCAsIC;AAED,mDAAmD;AACtC,QAAA,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Adaptive Learning Metacognition Engine (ALME)
3
+ * Core system for autonomous cognitive enhancement
4
+ */
5
+ export declare class MetacognitionEngine {
6
+ private skillProfile;
7
+ private knowledgeGraph;
8
+ private performanceAnalyzer;
9
+ private learningPathGenerator;
10
+ private learningHistory;
11
+ constructor();
12
+ /**
13
+ * Primary method for autonomous self-improvement
14
+ */
15
+ performSelfImprovement(): Promise<void>;
16
+ /**
17
+ * Execute a specific learning step
18
+ * @param learningStep Detailed learning objective
19
+ * @returns Learning outcome
20
+ */
21
+ private executeLearningstep;
22
+ /**
23
+ * Record details of learning experience
24
+ * @param learningStep Step that was attempted
25
+ * @param outcome Outcome of the learning attempt
26
+ */
27
+ private recordLearningExperience;
28
+ /**
29
+ * Retrieve learning insights
30
+ * @returns Aggregated learning insights
31
+ */
32
+ getLearningInsights(): Array<string>;
33
+ }
34
+ export declare const alme: MetacognitionEngine;
35
+ //# sourceMappingURL=MetacognitionEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetacognitionEngine.d.ts","sourceRoot":"","sources":["../../../src/alme/core/MetacognitionEngine.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,qBAAa,mBAAmB;IAE9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,qBAAqB,CAAwB;IAGrD,OAAO,CAAC,eAAe,CAKf;;IASR;;OAEG;IACG,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB7C;;;;OAIG;YACW,mBAAmB;IAYjC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAchC;;;OAGG;IACH,mBAAmB,IAAI,KAAK,CAAC,MAAM,CAAC;CAMrC;AAGD,eAAO,MAAM,IAAI,qBAA4B,CAAC"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alme = exports.MetacognitionEngine = void 0;
4
+ const SkillProfile_1 = require("./SkillProfile");
5
+ const LearningPathGenerator_1 = require("./LearningPathGenerator");
6
+ const PerformanceAnalyzer_1 = require("./PerformanceAnalyzer");
7
+ const KnowledgeGraph_1 = require("./KnowledgeGraph");
8
+ /**
9
+ * Adaptive Learning Metacognition Engine (ALME)
10
+ * Core system for autonomous cognitive enhancement
11
+ */
12
+ class MetacognitionEngine {
13
+ // Core cognitive components
14
+ skillProfile;
15
+ knowledgeGraph;
16
+ performanceAnalyzer;
17
+ learningPathGenerator;
18
+ // Metadata tracking
19
+ learningHistory = [];
20
+ constructor() {
21
+ this.skillProfile = new SkillProfile_1.SkillProfile();
22
+ this.knowledgeGraph = new KnowledgeGraph_1.KnowledgeGraph();
23
+ this.performanceAnalyzer = new PerformanceAnalyzer_1.PerformanceAnalyzer();
24
+ this.learningPathGenerator = new LearningPathGenerator_1.LearningPathGenerator();
25
+ }
26
+ /**
27
+ * Primary method for autonomous self-improvement
28
+ */
29
+ async performSelfImprovement() {
30
+ // 1. Analyze current performance and skill gaps
31
+ const performanceAssessment = await this.performanceAnalyzer.assess();
32
+ // 2. Generate personalized learning path
33
+ const learningPath = this.learningPathGenerator.generate(performanceAssessment.skillGaps);
34
+ // 3. Execute learning path
35
+ for (const learningStep of learningPath) {
36
+ const learningOutcome = await this.executeLearningstep(learningStep);
37
+ // 4. Record learning experience
38
+ this.recordLearningExperience(learningStep, learningOutcome);
39
+ }
40
+ // 5. Update knowledge graph and skill profile
41
+ this.knowledgeGraph.integrate(learningPath);
42
+ this.skillProfile.update(performanceAssessment);
43
+ }
44
+ /**
45
+ * Execute a specific learning step
46
+ * @param learningStep Detailed learning objective
47
+ * @returns Learning outcome
48
+ */
49
+ async executeLearningstep(learningStep) {
50
+ try {
51
+ // Implement learning step execution logic
52
+ // This could involve code generation, skill simulation, etc.
53
+ return 'success';
54
+ }
55
+ catch (error) {
56
+ // Handle learning failures
57
+ console.error('Learning step failed:', error);
58
+ return 'failure';
59
+ }
60
+ }
61
+ /**
62
+ * Record details of learning experience
63
+ * @param learningStep Step that was attempted
64
+ * @param outcome Outcome of the learning attempt
65
+ */
66
+ recordLearningExperience(learningStep, outcome) {
67
+ this.learningHistory.push({
68
+ timestamp: Date.now(),
69
+ skillDomain: learningStep.domain,
70
+ learningOutcome: outcome,
71
+ insights: outcome === 'success'
72
+ ? ['Skill acquired']
73
+ : ['Area for improvement identified']
74
+ });
75
+ }
76
+ /**
77
+ * Retrieve learning insights
78
+ * @returns Aggregated learning insights
79
+ */
80
+ getLearningInsights() {
81
+ // Analyze learning history and extract key insights
82
+ return this.learningHistory
83
+ .filter(entry => entry.learningOutcome !== 'success')
84
+ .map(entry => `Improvement needed in ${entry.skillDomain}`);
85
+ }
86
+ }
87
+ exports.MetacognitionEngine = MetacognitionEngine;
88
+ // Singleton instance for global access
89
+ exports.alme = new MetacognitionEngine();
90
+ //# sourceMappingURL=MetacognitionEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetacognitionEngine.js","sourceRoot":"","sources":["../../../src/alme/core/MetacognitionEngine.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAC9C,mEAAgE;AAChE,+DAA4D;AAC5D,qDAAkD;AAElD;;;GAGG;AACH,MAAa,mBAAmB;IAC9B,4BA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