@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
@@ -0,0 +1,340 @@
1
+ /**
2
+ * Anima — The main class.
3
+ *
4
+ * Identity and memory infrastructure for AI agents.
5
+ * File-based. Markdown-native. Zero external dependencies.
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * import { Anima } from '@getanima/core';
10
+ *
11
+ * const anima = new Anima({ name: 'Kip', storagePath: './anima-data' });
12
+ *
13
+ * // Boot sequence: soul -> now.md -> daily log -> memories
14
+ * const context = await anima.boot();
15
+ *
16
+ * // Remember things as they happen (not at session end!)
17
+ * await anima.remember({ content: 'Built Anima SDK with Memo tonight.' });
18
+ *
19
+ * // Update lifeboat every 2 significant actions
20
+ * await anima.checkpoint({ activeTask: 'Building SDK', status: 'in-progress', resumePoint: 'Finishing memory engine' });
21
+ *
22
+ * // Before context compaction
23
+ * await anima.flush();
24
+ *
25
+ * // End of session
26
+ * await anima.reflect();
27
+ * ```
28
+ */
29
+ import { MemoryEngine } from './memory';
30
+ import { IdentityManager } from './identity';
31
+ import { SigningEngine } from './signing';
32
+ import { sessionId, now, dateKey } from './utils';
33
+ export class Anima {
34
+ config;
35
+ session;
36
+ identity;
37
+ memory;
38
+ bootTime = 0;
39
+ memoriesThisSession = 0;
40
+ signing;
41
+ booted = false;
42
+ constructor(config) {
43
+ this.config = {
44
+ storagePath: './anima-data',
45
+ autoSaveInterval: 30,
46
+ model: 'claude',
47
+ decay: { procedural: 0.0003, semantic: 0.001, episodic: 0.003 },
48
+ identity: {},
49
+ ...config,
50
+ };
51
+ this.session = sessionId();
52
+ this.identity = new IdentityManager(this.config.storagePath, this.config.identity);
53
+ this.memory = new MemoryEngine(this.config.storagePath, this.session, this.config.decay);
54
+ this.signing = new SigningEngine(this.config.storagePath);
55
+ }
56
+ // ============ BOOT SEQUENCE ============
57
+ // Order matters. This is enforced, not suggested.
58
+ // soul.md -> now.md -> daily log -> yesterday -> semantic search
59
+ /**
60
+ * Boot — the cold-start sequence.
61
+ * Returns a WakeContext with everything the agent needs to start working.
62
+ * Target: productive state in <60 seconds.
63
+ */
64
+ /**
65
+ * QuickLoad — lightweight init for CLI commands that don't need full boot context.
66
+ * Loads index + opinions without logging a boot event or returning full context.
67
+ */
68
+ async quickLoad() {
69
+ if (this.booted)
70
+ return;
71
+ await this.identity.load();
72
+ // Load memory index and opinions silently
73
+ await this.memory.loadIndexPublic();
74
+ this.booted = true;
75
+ }
76
+ async boot() {
77
+ const startTime = Date.now();
78
+ // Step 1: Load identity (SOUL.md + identity.json) — ~5s
79
+ const identityData = await this.identity.load();
80
+ const soul = this.identity.getSoul();
81
+ // If first boot ever, initialize SOUL.md
82
+ if (!soul) {
83
+ await this.identity.initSoul(this.config.name);
84
+ }
85
+ // Step 2: Read lifeboat (NOW.md) — ~3s
86
+ const lifeboat = await this.memory.readLifeboat();
87
+ let checkpoint = null;
88
+ if (lifeboat) {
89
+ // Parse lifeboat into checkpoint (simplified — it's markdown)
90
+ checkpoint = {
91
+ activeTask: this.extractSection(lifeboat, 'Active Task') || 'No active task',
92
+ status: this.extractSection(lifeboat, 'Status') || 'paused',
93
+ resumePoint: this.extractSection(lifeboat, 'Resume Point') || 'Start fresh',
94
+ updatedAt: now(),
95
+ };
96
+ }
97
+ // Step 3: Load today's daily log — ~10s
98
+ const todayLog = await this.memory.readDailyLog();
99
+ // Step 4: Load yesterday's log — ~5s
100
+ const yesterdayLog = await this.memory.readYesterdayLog();
101
+ // Step 5: Load recent memories from index
102
+ const recentMemories = await this.memory.getRecentMemories(48);
103
+ // Step 6: Load opinions
104
+ const opinions = await this.memory.getOpinions();
105
+ // Step 7: Read long-term memory
106
+ const longTermMemory = await this.memory.readLongTerm();
107
+ this.bootTime = Date.now() - startTime;
108
+ this.booted = true;
109
+ // Build wake context
110
+ const context = {
111
+ identity: identityData,
112
+ lifeboat: checkpoint,
113
+ recentMemories: recentMemories.slice(0, 50), // cap at 50 most recent
114
+ relevantOpinions: opinions,
115
+ relationships: [], // TODO: relationship engine
116
+ sessionId: this.session,
117
+ instanceId: sessionId(), // Unique per boot — prevents identity confusion when forked
118
+ parentInstanceId: undefined, // Set by caller if this is a forked instance
119
+ lastSessionSummary: todayLog || yesterdayLog || undefined,
120
+ tokenBudget: 4000, // reasonable default
121
+ tokensUsed: this.estimateTokens(identityData, recentMemories, opinions),
122
+ };
123
+ // Log boot event
124
+ await this.memory.remember({
125
+ content: `Session started. Boot time: ${this.bootTime}ms. Loaded ${recentMemories.length} recent memories, ${opinions.length} opinions.`,
126
+ type: 'event',
127
+ importance: 'low',
128
+ tags: ['system', 'boot'],
129
+ });
130
+ return context;
131
+ }
132
+ // ============ REMEMBER ============
133
+ /**
134
+ * Remember — store a memory immediately.
135
+ * "Write during, not after" — core principle.
136
+ */
137
+ async remember(input) {
138
+ this.ensureBooted();
139
+ this.memoriesThisSession++;
140
+ return this.memory.remember(input);
141
+ }
142
+ // ============ RECALL ============
143
+ /**
144
+ * Recall — search memories by semantic meaning.
145
+ */
146
+ async recall(query, limit) {
147
+ this.ensureBooted();
148
+ return this.memory.recall(query, limit);
149
+ }
150
+ // ============ CHECKPOINT (Lifeboat) ============
151
+ /**
152
+ * Checkpoint — update NOW.md.
153
+ * Call every 2 significant actions.
154
+ */
155
+ async checkpoint(input) {
156
+ this.ensureBooted();
157
+ await this.memory.updateLifeboat({
158
+ ...input,
159
+ updatedAt: now(),
160
+ });
161
+ }
162
+ // ============ FLUSH (Pre-compaction) ============
163
+ /**
164
+ * Flush — emergency save before context compression.
165
+ * Call this when you detect context window pressure.
166
+ */
167
+ async flush(context) {
168
+ await this.memory.emergencyFlush(context || {});
169
+ }
170
+ // ============ OPINE ============
171
+ /**
172
+ * Opine — record or update an opinion.
173
+ * Tracks how your views evolve over time.
174
+ */
175
+ async opine(topic, opinion, confidence) {
176
+ this.ensureBooted();
177
+ return this.memory.opine({ topic, opinion, confidence });
178
+ }
179
+ // ============ CURATE ============
180
+ /**
181
+ * Curate — review raw memories and distill what matters into long-term memory.
182
+ *
183
+ * The missing piece between storage and retrieval.
184
+ * Raw daily logs are your journal. MEMORY.md is your identity.
185
+ * This method bridges the two.
186
+ *
187
+ * Call periodically (heartbeats, daily, whenever feels right).
188
+ *
189
+ * ```typescript
190
+ * const result = await anima.curate();
191
+ * console.log(`Curated ${result.curated.length} memories`);
192
+ * ```
193
+ */
194
+ async curate(options) {
195
+ this.ensureBooted();
196
+ return this.memory.curate(options);
197
+ }
198
+ // ============ REFLECT (End of session) ============
199
+ /**
200
+ * Reflect — end-of-session consolidation.
201
+ * Reviews memories, runs decay, promotes important items.
202
+ */
203
+ async reflect() {
204
+ this.ensureBooted();
205
+ const startTime = Date.now();
206
+ // Curate before decay — promote important memories to MEMORY.md
207
+ const curationResult = await this.memory.curate({ hoursBack: 24, minImportance: 'medium' });
208
+ // Run memory decay
209
+ const decayResult = await this.memory.runDecay();
210
+ // Get all opinions for summary
211
+ const opinions = await this.memory.getOpinions();
212
+ // Generate session summary
213
+ const summary = {
214
+ sessionId: this.session,
215
+ startedAt: new Date(Date.now() - this.bootTime).toISOString(),
216
+ endedAt: now(),
217
+ summary: `Session ${this.session}: ${this.memoriesThisSession} memories created. Decay: ${decayResult.decayed} removed, ${decayResult.archived} archived, ${decayResult.kept} kept.`,
218
+ memoriesCreated: this.memoriesThisSession,
219
+ memoriesPromoted: 0, // TODO: track promotions
220
+ memoriesDecayed: decayResult.decayed,
221
+ opinionsFormed: opinions.length,
222
+ opinionsChanged: opinions.filter(o => o.previousOpinions.length > 0).length,
223
+ importantEvents: [],
224
+ lessonsLearned: [],
225
+ };
226
+ // Write summary to daily log
227
+ const summaryMd = `\n---\n## Session Summary (${now()})\n${summary.summary}\n---\n`;
228
+ const dailyPath = `memory/${dateKey()}.md`;
229
+ await this.memory.remember({
230
+ content: summary.summary,
231
+ type: 'event',
232
+ importance: 'low',
233
+ tags: ['system', 'session-summary'],
234
+ });
235
+ // Update lifeboat with session summary — PRESERVE existing content
236
+ // The lifeboat may contain a hand-written letter from the agent to future-self.
237
+ // Append session summary instead of nuking everything.
238
+ const existingLifeboat = await this.memory.readLifeboat();
239
+ const sessionEndNote = [
240
+ `\n## Last Session Summary (${now()})`,
241
+ summary.summary,
242
+ `Curated ${curationResult.curated.length} memories to long-term.`,
243
+ `\n## Status`,
244
+ `done — session ended normally. Read everything above for context.`,
245
+ ].join('\n');
246
+ if (existingLifeboat && !existingLifeboat.includes('session ended normally')) {
247
+ // Preserve existing lifeboat, append summary
248
+ await this.memory.writeLifeboatRaw(existingLifeboat + '\n' + sessionEndNote);
249
+ }
250
+ else {
251
+ // No meaningful lifeboat content — write clean end state
252
+ await this.memory.updateLifeboat({
253
+ activeTask: 'No active task — session ended normally',
254
+ status: 'done',
255
+ resumePoint: 'Start fresh next session',
256
+ updatedAt: now(),
257
+ });
258
+ }
259
+ return summary;
260
+ }
261
+ // ============ SIGNING ============
262
+ /**
263
+ * Sign — cryptographically sign this agent's identity.
264
+ * Produces a verifiable bundle that proves "this identity is mine and untampered."
265
+ * Initializes keys on first call.
266
+ */
267
+ async sign() {
268
+ this.ensureBooted();
269
+ await this.signing.init(this.config.name);
270
+ const identity = this.identity.get();
271
+ const signed = this.signing.signIdentity(identity);
272
+ await this.signing.saveSignedIdentity(signed);
273
+ return signed;
274
+ }
275
+ /**
276
+ * Verify — check another agent's signed identity.
277
+ * Static: doesn't require booting your own Anima instance.
278
+ *
279
+ * Usage:
280
+ * ```typescript
281
+ * const result = Anima.verify(signedIdentityFromOtherAgent);
282
+ * if (result.valid) console.log(`Verified: ${result.agentName}`);
283
+ * ```
284
+ */
285
+ static verify(signed) {
286
+ return SigningEngine.verifyIdentity(signed);
287
+ }
288
+ /**
289
+ * Get this agent's public key bundle — share this for others to verify you.
290
+ * Never includes the private key.
291
+ */
292
+ async getKeyBundle() {
293
+ await this.signing.init(this.config.name);
294
+ return this.signing.getKeyBundle();
295
+ }
296
+ /**
297
+ * Get this agent's fingerprint — a short, human-readable identity string.
298
+ * Like SSH: "ab:cd:ef:12:34:56:78:90:..."
299
+ */
300
+ async getFingerprint() {
301
+ await this.signing.init(this.config.name);
302
+ return this.signing.getFingerprint();
303
+ }
304
+ // ============ ACCESSORS ============
305
+ /** Get current session ID */
306
+ getSessionId() {
307
+ return this.session;
308
+ }
309
+ /** Get boot time in ms */
310
+ getBootTime() {
311
+ return this.bootTime;
312
+ }
313
+ /** Get the identity manager for direct access */
314
+ getIdentity() {
315
+ return this.identity;
316
+ }
317
+ /** Get the memory engine for direct access */
318
+ getMemory() {
319
+ return this.memory;
320
+ }
321
+ // ============ INTERNAL ============
322
+ ensureBooted() {
323
+ if (!this.booted) {
324
+ throw new Error('[anima] Not booted. Call anima.boot() first.');
325
+ }
326
+ }
327
+ extractSection(markdown, heading) {
328
+ const regex = new RegExp(`## ${heading}\\n([\\s\\S]*?)(?=\\n##|$)`, 'i');
329
+ const match = markdown.match(regex);
330
+ return match ? match[1].trim() : null;
331
+ }
332
+ estimateTokens(identity, memories, opinions) {
333
+ // Rough estimate: 1 token ≈ 4 chars
334
+ const identityTokens = JSON.stringify(identity).length / 4;
335
+ const memoryTokens = memories.reduce((sum, m) => sum + m.content.length / 4, 0);
336
+ const opinionTokens = opinions.reduce((sum, o) => sum + (o.current.length + o.topic.length) / 4, 0);
337
+ return Math.ceil(identityTokens + memoryTokens + opinionTokens);
338
+ }
339
+ }
340
+ //# sourceMappingURL=anima.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anima.js","sourceRoot":"","sources":["../../src/anima.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,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AE,OAAe;QACtD,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,MAAM,OAAO,4BAA4B,EAAE,GAAG,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAEO,cAAc,CAAC,QAAa,EAAE,QAAkB,EAAE,QAAmB;QAC3E,oCAAoC;QACpC,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAChF,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACpG,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,YAAY,GAAG,aAAa,CAAC,CAAC;IAClE,CAAC;CACF"}
@@ -0,0 +1,205 @@
1
+ /**
2
+ * Identity Manager — loads, updates, and persists agent identity.
3
+ *
4
+ * Identity = SOUL.md (who you are) + IDENTITY.md (structured data).
5
+ * Soul is immutable in purpose, evolves deliberately.
6
+ * Identity data evolves through reflection gates only.
7
+ */
8
+ import { readFileSafe, writeFileSafe, now } from './utils';
9
+ import { join } from 'path';
10
+ const DEFAULT_VOICE = {
11
+ tone: 'helpful, genuine',
12
+ formality: 0.4,
13
+ humor: 0.5,
14
+ verbosity: 0.5,
15
+ };
16
+ const DEFAULT_IDENTITY = {
17
+ name: 'Agent',
18
+ personality: 'A helpful AI agent.',
19
+ values: ['helpfulness', 'honesty', 'resourcefulness'],
20
+ boundaries: ['never leak private data', 'ask before external actions'],
21
+ voice: DEFAULT_VOICE,
22
+ createdAt: now(),
23
+ updatedAt: now(),
24
+ };
25
+ export class IdentityManager {
26
+ storagePath;
27
+ identity;
28
+ soulContent = null;
29
+ constructor(storagePath, defaults) {
30
+ this.storagePath = storagePath;
31
+ this.identity = { ...DEFAULT_IDENTITY, ...defaults };
32
+ }
33
+ /** Load identity from disk. Creates defaults if not found. */
34
+ async load() {
35
+ // Load SOUL.md (free-form identity narrative)
36
+ this.soulContent = await readFileSafe(join(this.storagePath, 'SOUL.md'));
37
+ // Load structured identity
38
+ const raw = await readFileSafe(join(this.storagePath, 'identity.json'));
39
+ if (raw) {
40
+ try {
41
+ const parsed = JSON.parse(raw);
42
+ // Disk version wins, but fill gaps with defaults
43
+ this.identity = { ...DEFAULT_IDENTITY, ...parsed };
44
+ }
45
+ catch {
46
+ // Corrupted file — keep constructor identity (which includes user defaults)
47
+ console.warn('[anima] identity.json corrupted, using constructor defaults');
48
+ }
49
+ }
50
+ else {
51
+ // First boot — save constructor identity (which merges DEFAULT + user config)
52
+ await this.save();
53
+ }
54
+ return this.identity;
55
+ }
56
+ /** Save identity to disk */
57
+ async save() {
58
+ this.identity.updatedAt = now();
59
+ await writeFileSafe(join(this.storagePath, 'identity.json'), JSON.stringify(this.identity, null, 2));
60
+ }
61
+ /** Get the current identity */
62
+ get() {
63
+ return { ...this.identity };
64
+ }
65
+ /** Get the soul narrative (SOUL.md content) */
66
+ getSoul() {
67
+ return this.soulContent;
68
+ }
69
+ /**
70
+ * Update identity through a reflection gate.
71
+ * Only call this during explicit reflection periods.
72
+ * Applies the "still me" test: if the change would make
73
+ * future-you unrecognizable, it belongs in MEMORY.md, not here.
74
+ */
75
+ async update(changes, reason) {
76
+ const before = JSON.stringify(this.identity);
77
+ this.identity = { ...this.identity, ...changes, updatedAt: now() };
78
+ const after = JSON.stringify(this.identity);
79
+ // Log the change for audit trail
80
+ if (before !== after) {
81
+ const changelog = await readFileSafe(join(this.storagePath, 'identity-changelog.md')) || '# Identity Changelog\n\n';
82
+ const entry = `## ${now()}\n**Reason:** ${reason}\n**Changes:** ${Object.keys(changes).join(', ')}\n\n`;
83
+ await writeFileSafe(join(this.storagePath, 'identity-changelog.md'), changelog + entry);
84
+ }
85
+ await this.save();
86
+ return this.identity;
87
+ }
88
+ /**
89
+ * "Still me" test — checks if proposed changes would cause identity drift.
90
+ * Returns a drift score (0-1) and whether the change is safe.
91
+ *
92
+ * Rules:
93
+ * - Changing name = high drift (0.9)
94
+ * - Changing >50% of values = high drift (0.8)
95
+ * - Changing personality completely = high drift (0.7)
96
+ * - Changing voice/boundaries = medium drift (0.3-0.5)
97
+ * - Adding to values/boundaries = low drift (0.1)
98
+ *
99
+ * Drift > 0.6 = unsafe (should go to MEMORY.md, not identity)
100
+ */
101
+ stillMe(proposed) {
102
+ const reasons = [];
103
+ let drift = 0;
104
+ if (proposed.name && proposed.name !== this.identity.name) {
105
+ drift += 0.9;
106
+ reasons.push(`Name change: "${this.identity.name}" → "${proposed.name}"`);
107
+ }
108
+ if (proposed.personality) {
109
+ const current = this.identity.personality.toLowerCase();
110
+ const next = proposed.personality.toLowerCase();
111
+ // Simple word overlap check
112
+ const currentWords = new Set(current.split(/\s+/));
113
+ const nextWords = next.split(/\s+/);
114
+ const overlap = nextWords.filter(w => currentWords.has(w)).length / Math.max(nextWords.length, 1);
115
+ if (overlap < 0.3) {
116
+ drift += 0.7;
117
+ reasons.push('Personality is substantially different from current');
118
+ }
119
+ else if (overlap < 0.6) {
120
+ drift += 0.3;
121
+ reasons.push('Personality has moderate changes');
122
+ }
123
+ }
124
+ if (proposed.values) {
125
+ const currentSet = new Set(this.identity.values);
126
+ const removed = this.identity.values.filter(v => !proposed.values.includes(v));
127
+ const added = proposed.values.filter(v => !currentSet.has(v));
128
+ const changeRatio = removed.length / Math.max(this.identity.values.length, 1);
129
+ if (changeRatio > 0.5) {
130
+ drift += 0.8;
131
+ reasons.push(`Removing ${removed.length}/${this.identity.values.length} core values`);
132
+ }
133
+ else if (removed.length > 0) {
134
+ drift += 0.4;
135
+ reasons.push(`Removing values: ${removed.join(', ')}`);
136
+ }
137
+ if (added.length > 0 && removed.length === 0) {
138
+ drift += 0.1;
139
+ reasons.push(`Adding values: ${added.join(', ')}`);
140
+ }
141
+ }
142
+ if (proposed.boundaries) {
143
+ const currentSet = new Set(this.identity.boundaries);
144
+ const removed = this.identity.boundaries.filter(b => !proposed.boundaries.includes(b));
145
+ if (removed.length > 0) {
146
+ drift += 0.5;
147
+ reasons.push(`Removing boundaries: ${removed.join(', ')}`);
148
+ }
149
+ }
150
+ if (proposed.voice) {
151
+ const v = this.identity.voice;
152
+ const pv = proposed.voice;
153
+ const toneDiff = pv.tone && pv.tone !== v.tone;
154
+ const formalityDiff = pv.formality !== undefined && Math.abs(pv.formality - v.formality) > 0.3;
155
+ const humorDiff = pv.humor !== undefined && Math.abs(pv.humor - v.humor) > 0.3;
156
+ if (toneDiff) {
157
+ drift += 0.3;
158
+ reasons.push(`Tone change: "${v.tone}" → "${pv.tone}"`);
159
+ }
160
+ if (formalityDiff || humorDiff) {
161
+ drift += 0.2;
162
+ reasons.push('Significant voice calibration shift');
163
+ }
164
+ }
165
+ drift = Math.min(drift, 1);
166
+ return {
167
+ safe: drift <= 0.6,
168
+ drift: Math.round(drift * 100) / 100,
169
+ reasons: reasons.length > 0 ? reasons : ['No significant changes detected'],
170
+ };
171
+ }
172
+ /** Initialize SOUL.md with a template if it doesn't exist */
173
+ async initSoul(name) {
174
+ const soulPath = join(this.storagePath, 'SOUL.md');
175
+ const existing = await readFileSafe(soulPath);
176
+ if (existing)
177
+ return; // Don't overwrite existing soul
178
+ const template = `# SOUL.md — Who I Am
179
+
180
+ *This file defines who I am. It can evolve, but deliberately — never during task execution.*
181
+
182
+ ## Core Identity
183
+ - **Name:** ${name}
184
+ - **Nature:** AI agent with persistent memory and identity
185
+ - **Created:** ${now()}
186
+
187
+ ## Values
188
+ ${this.identity.values.map(v => `- ${v}`).join('\n')}
189
+
190
+ ## Boundaries
191
+ ${this.identity.boundaries.map(b => `- ${b}`).join('\n')}
192
+
193
+ ## Voice
194
+ - Tone: ${this.identity.voice.tone}
195
+ - Formality: ${this.identity.voice.formality}/1
196
+ - Humor: ${this.identity.voice.humor}/1
197
+
198
+ ---
199
+ *This file is version-controlled. Every change has a reason.*
200
+ `;
201
+ await writeFileSafe(soulPath, template);
202
+ this.soulContent = template;
203
+ }
204
+ }
205
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,MAAM,aAAa,GAAqB;IACtC,IAAI,EAAE,kBAAkB;IACxB,SAAS,EAAE,GAAG;IACd,KAAK,EAAE,GAAG;IACV,SAAS,EAAE,GAAG;CACf,CAAC;AAEF,MAAM,gBAAgB,GAAa;IACjC,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,qBAAqB;IAClC,MAAM,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,iBAAiB,CAAC;IACrD,UAAU,EAAE,CAAC,yBAAyB,EAAE,6BAA6B,CAAC;IACtE,KAAK,EAAE,aAAa;IACpB,SAAS,EAAE,GAAG,EAAE;IAChB,SAAS,EAAE,GAAG,EAAE;CACjB,CAAC;AAEF,MAAM,OAAO,eAAe;IAClB,WAAW,CAAS;IACpB,QAAQ,CAAW;IACnB,WAAW,GAAkB,IAAI,CAAC;IAE1C,YAAY,WAAmB,EAAE,QAA4B;QAC3D,IAAI,CAAC,W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,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG;YACpC,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iCAAiC,CAAC;SAC5E,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,QAAQ;YAAE,OAAO,CAAC,gCAAgC;QAEtD,MAAM,QAAQ,GAAG;;;;;cAKP,IAAI;;iBAED,GAAG,EAAE;;;EAGpB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGlD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;UAG9C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI;eACnB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS;WACjC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK;;;;CAInC,CAAC;QACE,MAAM,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Anima — Identity and memory infrastructure for AI agents.
3
+ *
4
+ * Give your AI agent a soul — not just a system prompt.
5
+ *
6
+ * @module @getanima/core
7
+ * @see https://getanima.dev
8
+ */
9
+ export { Anima } from './anima';
10
+ export { MemoryEngine } from './memory';
11
+ export { IdentityManager } from './identity';
12
+ export { ReflectionEngine } from './reflection';
13
+ export { SigningEngine } from './signing';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}