@getanima/core 0.1.0

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.
@@ -0,0 +1,104 @@
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 type { AnimaConfig, WakeContext, Memory, Checkpoint, SessionSummary, Opinion } from './types';
30
+ import { MemoryEngine } from './memory';
31
+ import { IdentityManager } from './identity';
32
+ export declare class Anima {
33
+ private config;
34
+ private session;
35
+ private identity;
36
+ private memory;
37
+ private bootTime;
38
+ private memoriesThisSession;
39
+ private booted;
40
+ constructor(config: AnimaConfig);
41
+ /**
42
+ * Boot — the cold-start sequence.
43
+ * Returns a WakeContext with everything the agent needs to start working.
44
+ * Target: productive state in <60 seconds.
45
+ */
46
+ boot(): Promise<WakeContext>;
47
+ /**
48
+ * Remember — store a memory immediately.
49
+ * "Write during, not after" — core principle.
50
+ */
51
+ remember(input: {
52
+ content: string;
53
+ type?: Memory['type'];
54
+ importance?: Memory['importance'];
55
+ tags?: string[];
56
+ emotionalWeight?: number;
57
+ }): Promise<Memory>;
58
+ /**
59
+ * Recall — search memories by semantic meaning.
60
+ */
61
+ recall(query: string, limit?: number): Promise<Memory[]>;
62
+ /**
63
+ * Checkpoint — update NOW.md.
64
+ * Call every 2 significant actions.
65
+ */
66
+ checkpoint(input: {
67
+ activeTask: string;
68
+ status: Checkpoint['status'];
69
+ resumePoint: string;
70
+ openThreads?: string[];
71
+ keyContext?: string[];
72
+ }): Promise<void>;
73
+ /**
74
+ * Flush — emergency save before context compression.
75
+ * Call this when you detect context window pressure.
76
+ */
77
+ flush(context?: {
78
+ activeTask?: string;
79
+ criticalState?: string;
80
+ unsavedMemories?: string[];
81
+ }): Promise<void>;
82
+ /**
83
+ * Opine — record or update an opinion.
84
+ * Tracks how your views evolve over time.
85
+ */
86
+ opine(topic: string, opinion: string, confidence: number): Promise<Opinion>;
87
+ /**
88
+ * Reflect — end-of-session consolidation.
89
+ * Reviews memories, runs decay, promotes important items.
90
+ */
91
+ reflect(): Promise<SessionSummary>;
92
+ /** Get current session ID */
93
+ getSessionId(): string;
94
+ /** Get boot time in ms */
95
+ getBootTime(): number;
96
+ /** Get the identity manager for direct access */
97
+ getIdentity(): IdentityManager;
98
+ /** Get the memory engine for direct access */
99
+ getMemory(): MemoryEngine;
100
+ private ensureBooted;
101
+ private extractSection;
102
+ private estimateTokens;
103
+ }
104
+ //# sourceMappingURL=anima.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anima.d.ts","sourceRoot":"","sources":["../src/anima.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7C,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAA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CAAC;IAOjF;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC;IAiDxC,6BAA6B;IAC7B,YAAY,IAAI,MAAM;IAItB,0BAA0B;IAC1B,WAAW,IAAI,MAAM;IAIrB,iDAAiD;IACjD,WAAW,IAAI,eAAe;IAI9B,8CAA8C;IAC9C,SAAS,IAAI,YAAY;IAMzB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,cAAc;CAOvB"}
package/dist/anima.js ADDED
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ /**
3
+ * Anima — The main class.
4
+ *
5
+ * Identity and memory infrastructure for AI agents.
6
+ * File-based. Markdown-native. Zero external dependencies.
7
+ *
8
+ * Usage:
9
+ * ```typescript
10
+ * import { Anima } from '@getanima/core';
11
+ *
12
+ * const anima = new Anima({ name: 'Kip', storagePath: './anima-data' });
13
+ *
14
+ * // Boot sequence: soul -> now.md -> daily log -> memories
15
+ * const context = await anima.boot();
16
+ *
17
+ * // Remember things as they happen (not at session end!)
18
+ * await anima.remember({ content: 'Built Anima SDK with Memo tonight.' });
19
+ *
20
+ * // Update lifeboat every 2 significant actions
21
+ * await anima.checkpoint({ activeTask: 'Building SDK', status: 'in-progress', resumePoint: 'Finishing memory engine' });
22
+ *
23
+ * // Before context compaction
24
+ * await anima.flush();
25
+ *
26
+ * // End of session
27
+ * await anima.reflect();
28
+ * ```
29
+ */
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.Anima = void 0;
32
+ const memory_1 = require("./memory");
33
+ const identity_1 = require("./identity");
34
+ const utils_1 = require("./utils");
35
+ class Anima {
36
+ config;
37
+ session;
38
+ identity;
39
+ memory;
40
+ bootTime = 0;
41
+ memoriesThisSession = 0;
42
+ booted = false;
43
+ constructor(config) {
44
+ this.config = {
45
+ storagePath: './anima-data',
46
+ autoSaveInterval: 30,
47
+ model: 'claude',
48
+ decay: { procedural: 0.0003, semantic: 0.001, episodic: 0.003 },
49
+ identity: {},
50
+ ...config,
51
+ };
52
+ this.session = (0, utils_1.sessionId)();
53
+ this.identity = new identity_1.IdentityManager(this.config.storagePath, this.config.identity);
54
+ this.memory = new memory_1.MemoryEngine(this.config.storagePath, this.session, this.config.decay);
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
+ async boot() {
65
+ const startTime = Date.now();
66
+ // Step 1: Load identity (SOUL.md + identity.json) — ~5s
67
+ const identityData = await this.identity.load();
68
+ const soul = this.identity.getSoul();
69
+ // If first boot ever, initialize SOUL.md
70
+ if (!soul) {
71
+ await this.identity.initSoul(this.config.name);
72
+ }
73
+ // Step 2: Read lifeboat (NOW.md) — ~3s
74
+ const lifeboat = await this.memory.readLifeboat();
75
+ let checkpoint = null;
76
+ if (lifeboat) {
77
+ // Parse lifeboat into checkpoint (simplified — it's markdown)
78
+ checkpoint = {
79
+ activeTask: this.extractSection(lifeboat, 'Active Task') || 'No active task',
80
+ status: this.extractSection(lifeboat, 'Status') || 'paused',
81
+ resumePoint: this.extractSection(lifeboat, 'Resume Point') || 'Start fresh',
82
+ updatedAt: (0, utils_1.now)(),
83
+ };
84
+ }
85
+ // Step 3: Load today's daily log — ~10s
86
+ const todayLog = await this.memory.readDailyLog();
87
+ // Step 4: Load yesterday's log — ~5s
88
+ const yesterdayLog = await this.memory.readYesterdayLog();
89
+ // Step 5: Load recent memories from index
90
+ const recentMemories = await this.memory.getRecentMemories(48);
91
+ // Step 6: Load opinions
92
+ const opinions = await this.memory.getOpinions();
93
+ // Step 7: Read long-term memory
94
+ const longTermMemory = await this.memory.readLongTerm();
95
+ this.bootTime = Date.now() - startTime;
96
+ this.booted = true;
97
+ // Build wake context
98
+ const context = {
99
+ identity: identityData,
100
+ lifeboat: checkpoint,
101
+ recentMemories: recentMemories.slice(0, 50), // cap at 50 most recent
102
+ relevantOpinions: opinions,
103
+ relationships: [], // TODO: relationship engine
104
+ sessionId: this.session,
105
+ lastSessionSummary: todayLog || yesterdayLog || undefined,
106
+ tokenBudget: 4000, // reasonable default
107
+ tokensUsed: this.estimateTokens(identityData, recentMemories, opinions),
108
+ };
109
+ // Log boot event
110
+ await this.memory.remember({
111
+ content: `Session started. Boot time: ${this.bootTime}ms. Loaded ${recentMemories.length} recent memories, ${opinions.length} opinions.`,
112
+ type: 'event',
113
+ importance: 'low',
114
+ tags: ['system', 'boot'],
115
+ });
116
+ return context;
117
+ }
118
+ // ============ REMEMBER ============
119
+ /**
120
+ * Remember — store a memory immediately.
121
+ * "Write during, not after" — core principle.
122
+ */
123
+ async remember(input) {
124
+ this.ensureBooted();
125
+ this.memoriesThisSession++;
126
+ return this.memory.remember(input);
127
+ }
128
+ // ============ RECALL ============
129
+ /**
130
+ * Recall — search memories by semantic meaning.
131
+ */
132
+ async recall(query, limit) {
133
+ this.ensureBooted();
134
+ return this.memory.recall(query, limit);
135
+ }
136
+ // ============ CHECKPOINT (Lifeboat) ============
137
+ /**
138
+ * Checkpoint — update NOW.md.
139
+ * Call every 2 significant actions.
140
+ */
141
+ async checkpoint(input) {
142
+ this.ensureBooted();
143
+ await this.memory.updateLifeboat({
144
+ ...input,
145
+ updatedAt: (0, utils_1.now)(),
146
+ });
147
+ }
148
+ // ============ FLUSH (Pre-compaction) ============
149
+ /**
150
+ * Flush — emergency save before context compression.
151
+ * Call this when you detect context window pressure.
152
+ */
153
+ async flush(context) {
154
+ await this.memory.emergencyFlush(context || {});
155
+ }
156
+ // ============ OPINE ============
157
+ /**
158
+ * Opine — record or update an opinion.
159
+ * Tracks how your views evolve over time.
160
+ */
161
+ async opine(topic, opinion, confidence) {
162
+ this.ensureBooted();
163
+ return this.memory.opine({ topic, opinion, confidence });
164
+ }
165
+ // ============ REFLECT (End of session) ============
166
+ /**
167
+ * Reflect — end-of-session consolidation.
168
+ * Reviews memories, runs decay, promotes important items.
169
+ */
170
+ async reflect() {
171
+ this.ensureBooted();
172
+ const startTime = Date.now();
173
+ // Run memory decay
174
+ const decayResult = await this.memory.runDecay();
175
+ // Get all opinions for summary
176
+ const opinions = await this.memory.getOpinions();
177
+ // Generate session summary
178
+ const summary = {
179
+ sessionId: this.session,
180
+ startedAt: new Date(Date.now() - (Date.now() - this.bootTime)).toISOString(),
181
+ endedAt: (0, utils_1.now)(),
182
+ summary: `Session ${this.session}: ${this.memoriesThisSession} memories created. Decay: ${decayResult.decayed} removed, ${decayResult.archived} archived, ${decayResult.kept} kept.`,
183
+ memoriesCreated: this.memoriesThisSession,
184
+ memoriesPromoted: 0, // TODO: track promotions
185
+ memoriesDecayed: decayResult.decayed,
186
+ opinionsFormed: opinions.length,
187
+ opinionsChanged: opinions.filter(o => o.previousOpinions.length > 0).length,
188
+ importantEvents: [],
189
+ lessonsLearned: [],
190
+ };
191
+ // Write summary to daily log
192
+ const summaryMd = `\n---\n## Session Summary (${(0, utils_1.now)()})\n${summary.summary}\n---\n`;
193
+ const dailyPath = `memory/${(0, utils_1.dateKey)()}.md`;
194
+ await this.memory.remember({
195
+ content: summary.summary,
196
+ type: 'event',
197
+ importance: 'low',
198
+ tags: ['system', 'session-summary'],
199
+ });
200
+ // Clear lifeboat (session ended normally)
201
+ await this.memory.updateLifeboat({
202
+ activeTask: 'No active task — session ended normally',
203
+ status: 'done',
204
+ resumePoint: 'Start fresh next session',
205
+ updatedAt: (0, utils_1.now)(),
206
+ });
207
+ return summary;
208
+ }
209
+ // ============ ACCESSORS ============
210
+ /** Get current session ID */
211
+ getSessionId() {
212
+ return this.session;
213
+ }
214
+ /** Get boot time in ms */
215
+ getBootTime() {
216
+ return this.bootTime;
217
+ }
218
+ /** Get the identity manager for direct access */
219
+ getIdentity() {
220
+ return this.identity;
221
+ }
222
+ /** Get the memory engine for direct access */
223
+ getMemory() {
224
+ return this.memory;
225
+ }
226
+ // ============ INTERNAL ============
227
+ ensureBooted() {
228
+ if (!this.booted) {
229
+ throw new Error('[anima] Not booted. Call anima.boot() first.');
230
+ }
231
+ }
232
+ extractSection(markdown, heading) {
233
+ const regex = new RegExp(`## ${heading}\\n([\\s\\S]*?)(?=\\n##|$)`, 'i');
234
+ const match = markdown.match(regex);
235
+ return match ? match[1].trim() : null;
236
+ }
237
+ estimateTokens(identity, memories, opinions) {
238
+ // Rough estimate: 1 token ≈ 4 chars
239
+ const identityTokens = JSON.stringify(identity).length / 4;
240
+ const memoryTokens = memories.reduce((sum, m) => sum + m.content.length / 4, 0);
241
+ const opinionTokens = opinions.reduce((sum, o) => sum + (o.current.length + o.topic.length) / 4, 0);
242
+ return Math.ceil(identityTokens + memoryTokens + opinionTokens);
243
+ }
244
+ }
245
+ exports.Anima = Anima;
246
+ //# sourceMappingURL=anima.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anima.js","sourceRoot":"","sources":["../src/anima.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAGH,qCAAwC;AACxC,yCAA6C;AAC7C,mCAAkD;AAElD,MAAa,KAAK;IACR,MAAM,CAAwB;IAC9B,OAAO,CAAS;IAChB,QAAQ,CAAkB;IAC1B,MAAM,CAAe;IACrB,QAAQ,GAAW,CAAC,CAAC;IACrB,mBAAmB,GAAW,CAAC,CAAC;IAChC,MAAM,GAAY,KAAK,CAAC;IAEhC,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG;YACZ,WAAW,EAAE,cAAc;YAC3B,gBAAgB,EAAE,EAAE;YACpB,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE;YAC/D,QAAQ,EAAE,EAAE;YACZ,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,OAAO,GAAG,IAAA,iBAAS,GAAE,CAA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AAM,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;AA7QD,sBA6QC"}
@@ -0,0 +1,50 @@
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 type { Identity } from './types';
9
+ export declare class IdentityManager {
10
+ private storagePath;
11
+ private identity;
12
+ private soulContent;
13
+ constructor(storagePath: string, defaults?: Partial<Identity>);
14
+ /** Load identity from disk. Creates defaults if not found. */
15
+ load(): Promise<Identity>;
16
+ /** Save identity to disk */
17
+ save(): Promise<void>;
18
+ /** Get the current identity */
19
+ get(): Identity;
20
+ /** Get the soul narrative (SOUL.md content) */
21
+ getSoul(): string | null;
22
+ /**
23
+ * Update identity through a reflection gate.
24
+ * Only call this during explicit reflection periods.
25
+ * Applies the "still me" test: if the change would make
26
+ * future-you unrecognizable, it belongs in MEMORY.md, not here.
27
+ */
28
+ update(changes: Partial<Identity>, reason: string): Promise<Identity>;
29
+ /**
30
+ * "Still me" test — checks if proposed changes would cause identity drift.
31
+ * Returns a drift score (0-1) and whether the change is safe.
32
+ *
33
+ * Rules:
34
+ * - Changing name = high drift (0.9)
35
+ * - Changing >50% of values = high drift (0.8)
36
+ * - Changing personality completely = high drift (0.7)
37
+ * - Changing voice/boundaries = medium drift (0.3-0.5)
38
+ * - Adding to values/boundaries = low drift (0.1)
39
+ *
40
+ * Drift > 0.6 = unsafe (should go to MEMORY.md, not identity)
41
+ */
42
+ stillMe(proposed: Partial<Identity>): {
43
+ safe: boolean;
44
+ drift: number;
45
+ reasons: string[];
46
+ };
47
+ /** Initialize SOUL.md with a template if it doesn't exist */
48
+ initSoul(name: string): Promise<void>;
49
+ }
50
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAoB,MAAM,SAAS,CAAC;AAqB1D,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,WAAW,CAAuB;gBAE9B,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;IAK7D,8DAA8D;IACxD,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC;IAuB/B,4BAA4B;IACtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,+BAA+B;IAC/B,GAAG,IAAI,QAAQ;IAIf,+CAA+C;IAC/C,OAAO,IAAI,MAAM,GAAG,IAAI;IAIxB;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAmB3E;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IA+EzF,6DAA6D;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA+B5C"}
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ /**
3
+ * Identity Manager — loads, updates, and persists agent identity.
4
+ *
5
+ * Identity = SOUL.md (who you are) + IDENTITY.md (structured data).
6
+ * Soul is immutable in purpose, evolves deliberately.
7
+ * Identity data evolves through reflection gates only.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.IdentityManager = void 0;
11
+ const utils_1 = require("./utils");
12
+ const path_1 = require("path");
13
+ const DEFAULT_VOICE = {
14
+ tone: 'helpful, genuine',
15
+ formality: 0.4,
16
+ humor: 0.5,
17
+ verbosity: 0.5,
18
+ };
19
+ const DEFAULT_IDENTITY = {
20
+ name: 'Agent',
21
+ personality: 'A helpful AI agent.',
22
+ values: ['helpfulness', 'honesty', 'resourcefulness'],
23
+ boundaries: ['never leak private data', 'ask before external actions'],
24
+ voice: DEFAULT_VOICE,
25
+ createdAt: (0, utils_1.now)(),
26
+ updatedAt: (0, utils_1.now)(),
27
+ };
28
+ class IdentityManager {
29
+ storagePath;
30
+ identity;
31
+ soulContent = null;
32
+ constructor(storagePath, defaults) {
33
+ this.storagePath = storagePath;
34
+ this.identity = { ...DEFAULT_IDENTITY, ...defaults };
35
+ }
36
+ /** Load identity from disk. Creates defaults if not found. */
37
+ async load() {
38
+ // Load SOUL.md (free-form identity narrative)
39
+ this.soulContent = await (0, utils_1.readFileSafe)((0, path_1.join)(this.storagePath, 'SOUL.md'));
40
+ // Load structured identity
41
+ const raw = await (0, utils_1.readFileSafe)((0, path_1.join)(this.storagePath, 'identity.json'));
42
+ if (raw) {
43
+ try {
44
+ const parsed = JSON.parse(raw);
45
+ // Disk version wins, but fill gaps with defaults
46
+ this.identity = { ...DEFAULT_IDENTITY, ...parsed };
47
+ }
48
+ catch {
49
+ // Corrupted file — keep constructor identity (which includes user defaults)
50
+ console.warn('[anima] identity.json corrupted, using constructor defaults');
51
+ }
52
+ }
53
+ else {
54
+ // First boot — save constructor identity (which merges DEFAULT + user config)
55
+ await this.save();
56
+ }
57
+ return this.identity;
58
+ }
59
+ /** Save identity to disk */
60
+ async save() {
61
+ this.identity.updatedAt = (0, utils_1.now)();
62
+ await (0, utils_1.writeFileSafe)((0, path_1.join)(this.storagePath, 'identity.json'), JSON.stringify(this.identity, null, 2));
63
+ }
64
+ /** Get the current identity */
65
+ get() {
66
+ return { ...this.identity };
67
+ }
68
+ /** Get the soul narrative (SOUL.md content) */
69
+ getSoul() {
70
+ return this.soulContent;
71
+ }
72
+ /**
73
+ * Update identity through a reflection gate.
74
+ * Only call this during explicit reflection periods.
75
+ * Applies the "still me" test: if the change would make
76
+ * future-you unrecognizable, it belongs in MEMORY.md, not here.
77
+ */
78
+ async update(changes, reason) {
79
+ const before = JSON.stringify(this.identity);
80
+ this.identity = { ...this.identity, ...changes, updatedAt: (0, utils_1.now)() };
81
+ const after = JSON.stringify(this.identity);
82
+ // Log the change for audit trail
83
+ if (before !== after) {
84
+ const changelog = await (0, utils_1.readFileSafe)((0, path_1.join)(this.storagePath, 'identity-changelog.md')) || '# Identity Changelog\n\n';
85
+ const entry = `## ${(0, utils_1.now)()}\n**Reason:** ${reason}\n**Changes:** ${Object.keys(changes).join(', ')}\n\n`;
86
+ await (0, utils_1.writeFileSafe)((0, path_1.join)(this.storagePath, 'identity-changelog.md'), changelog + entry);
87
+ }
88
+ await this.save();
89
+ return this.identity;
90
+ }
91
+ /**
92
+ * "Still me" test — checks if proposed changes would cause identity drift.
93
+ * Returns a drift score (0-1) and whether the change is safe.
94
+ *
95
+ * Rules:
96
+ * - Changing name = high drift (0.9)
97
+ * - Changing >50% of values = high drift (0.8)
98
+ * - Changing personality completely = high drift (0.7)
99
+ * - Changing voice/boundaries = medium drift (0.3-0.5)
100
+ * - Adding to values/boundaries = low drift (0.1)
101
+ *
102
+ * Drift > 0.6 = unsafe (should go to MEMORY.md, not identity)
103
+ */
104
+ stillMe(proposed) {
105
+ const reasons = [];
106
+ let drift = 0;
107
+ if (proposed.name && proposed.name !== this.identity.name) {
108
+ drift += 0.9;
109
+ reasons.push(`Name change: "${this.identity.name}" → "${proposed.name}"`);
110
+ }
111
+ if (proposed.personality) {
112
+ const current = this.identity.personality.toLowerCase();
113
+ const next = proposed.personality.toLowerCase();
114
+ // Simple word overlap check
115
+ const currentWords = new Set(current.split(/\s+/));
116
+ const nextWords = next.split(/\s+/);
117
+ const overlap = nextWords.filter(w => currentWords.has(w)).length / Math.max(nextWords.length, 1);
118
+ if (overlap < 0.3) {
119
+ drift += 0.7;
120
+ reasons.push('Personality is substantially different from current');
121
+ }
122
+ else if (overlap < 0.6) {
123
+ drift += 0.3;
124
+ reasons.push('Personality has moderate changes');
125
+ }
126
+ }
127
+ if (proposed.values) {
128
+ const currentSet = new Set(this.identity.values);
129
+ const removed = this.identity.values.filter(v => !proposed.values.includes(v));
130
+ const added = proposed.values.filter(v => !currentSet.has(v));
131
+ const changeRatio = removed.length / Math.max(this.identity.values.length, 1);
132
+ if (changeRatio > 0.5) {
133
+ drift += 0.8;
134
+ reasons.push(`Removing ${removed.length}/${this.identity.values.length} core values`);
135
+ }
136
+ else if (removed.length > 0) {
137
+ drift += 0.4;
138
+ reasons.push(`Removing values: ${removed.join(', ')}`);
139
+ }
140
+ if (added.length > 0 && removed.length === 0) {
141
+ drift += 0.1;
142
+ reasons.push(`Adding values: ${added.join(', ')}`);
143
+ }
144
+ }
145
+ if (proposed.boundaries) {
146
+ const currentSet = new Set(this.identity.boundaries);
147
+ const removed = this.identity.boundaries.filter(b => !proposed.boundaries.includes(b));
148
+ if (removed.length > 0) {
149
+ drift += 0.5;
150
+ reasons.push(`Removing boundaries: ${removed.join(', ')}`);
151
+ }
152
+ }
153
+ if (proposed.voice) {
154
+ const v = this.identity.voice;
155
+ const pv = proposed.voice;
156
+ const toneDiff = pv.tone && pv.tone !== v.tone;
157
+ const formalityDiff = pv.formality !== undefined && Math.abs(pv.formality - v.formality) > 0.3;
158
+ const humorDiff = pv.humor !== undefined && Math.abs(pv.humor - v.humor) > 0.3;
159
+ if (toneDiff) {
160
+ drift += 0.3;
161
+ reasons.push(`Tone change: "${v.tone}" → "${pv.tone}"`);
162
+ }
163
+ if (formalityDiff || humorDiff) {
164
+ drift += 0.2;
165
+ reasons.push('Significant voice calibration shift');
166
+ }
167
+ }
168
+ drift = Math.min(drift, 1);
169
+ return {
170
+ safe: drift <= 0.6,
171
+ drift: Math.round(drift * 100) / 100,
172
+ reasons: reasons.length > 0 ? reasons : ['No significant changes detected'],
173
+ };
174
+ }
175
+ /** Initialize SOUL.md with a template if it doesn't exist */
176
+ async initSoul(name) {
177
+ const soulPath = (0, path_1.join)(this.storagePath, 'SOUL.md');
178
+ const existing = await (0, utils_1.readFileSafe)(soulPath);
179
+ if (existing)
180
+ return; // Don't overwrite existing soul
181
+ const template = `# SOUL.md — Who I Am
182
+
183
+ *This file defines who I am. It can evolve, but deliberately — never during task execution.*
184
+
185
+ ## Core Identity
186
+ - **Name:** ${name}
187
+ - **Nature:** AI agent with persistent memory and identity
188
+ - **Created:** ${(0, utils_1.now)()}
189
+
190
+ ## Values
191
+ ${this.identity.values.map(v => `- ${v}`).join('\n')}
192
+
193
+ ## Boundaries
194
+ ${this.identity.boundaries.map(b => `- ${b}`).join('\n')}
195
+
196
+ ## Voice
197
+ - Tone: ${this.identity.voice.tone}
198
+ - Formality: ${this.identity.voice.formality}/1
199
+ - Humor: ${this.identity.voice.humor}/1
200
+
201
+ ---
202
+ *This file is version-controlled. Every change has a reason.*
203
+ `;
204
+ await (0, utils_1.writeFileSafe)(soulPath, template);
205
+ this.soulContent = template;
206
+ }
207
+ }
208
+ exports.IdentityManager = IdentityManager;
209
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @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;cAKP,IAAI;;iBAED,IAAA,WAAG,GAAE;;;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,IAAA,qBAAa,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;IAC9B,CAAC;CACF;AA1MD,0CA0MC"}
@@ -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 type { AnimaConfig, Memory, MemoryType, MemoryTier, ImportanceLevel, Identity, VoiceCalibration, Opinion, OpinionHistory, Relationship, Checkpoint, WakeContext, SessionSummary, DecayConfig, MemoryConflict, AnimaEvent, AutoSaveConfig, } from './types';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","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;AAEhD,YAAY,EACV,WAAW,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,eAAe,EACf,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,cAAc,EACd,WAAW,EACX,cAAc,EACd,UAAU,EACV,cAAc,GACf,MAAM,SAAS,CAAC"}