@sashabogi/foundation 0.1.13 → 2.0.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.
- package/README.md +632 -238
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +159 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +4 -6
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/fireworks.d.ts +5 -0
- package/dist/providers/fireworks.d.ts.map +1 -1
- package/dist/providers/fireworks.js +18 -0
- package/dist/providers/fireworks.js.map +1 -1
- package/dist/providers/kimi-code.d.ts +5 -0
- package/dist/providers/kimi-code.d.ts.map +1 -1
- package/dist/providers/kimi-code.js +18 -0
- package/dist/providers/kimi-code.js.map +1 -1
- package/dist/providers/zai.d.ts +5 -0
- package/dist/providers/zai.d.ts.map +1 -1
- package/dist/providers/zai.js +18 -0
- package/dist/providers/zai.js.map +1 -1
- package/dist/tools/gaia/index.d.ts +29 -15
- package/dist/tools/gaia/index.d.ts.map +1 -1
- package/dist/tools/gaia/index.js +1206 -274
- package/dist/tools/gaia/index.js.map +1 -1
- package/dist/tools/gaia/storage.d.ts +72 -0
- package/dist/tools/gaia/storage.d.ts.map +1 -0
- package/dist/tools/gaia/storage.js +344 -0
- package/dist/tools/gaia/storage.js.map +1 -0
- package/dist/tools/gaia/test-storage-manual.d.ts +6 -0
- package/dist/tools/gaia/test-storage-manual.d.ts.map +1 -0
- package/dist/tools/gaia/test-storage-manual.js +120 -0
- package/dist/tools/gaia/test-storage-manual.js.map +1 -0
- package/dist/tools/memoria/index.d.ts +25 -0
- package/dist/tools/memoria/index.d.ts.map +1 -0
- package/dist/tools/memoria/index.js +269 -0
- package/dist/tools/memoria/index.js.map +1 -0
- package/dist/tools/memoria/storage.d.ts +72 -0
- package/dist/tools/memoria/storage.d.ts.map +1 -0
- package/dist/tools/memoria/storage.js +344 -0
- package/dist/tools/memoria/storage.js.map +1 -0
- package/dist/tools/memoria/storage.test.d.ts +7 -0
- package/dist/tools/memoria/storage.test.d.ts.map +1 -0
- package/dist/tools/memoria/storage.test.js +350 -0
- package/dist/tools/memoria/storage.test.js.map +1 -0
- package/dist/tools/memoria/test-storage-manual.d.ts +6 -0
- package/dist/tools/memoria/test-storage-manual.d.ts.map +1 -0
- package/dist/tools/memoria/test-storage-manual.js +120 -0
- package/dist/tools/memoria/test-storage-manual.js.map +1 -0
- package/dist/types/index.d.ts +38 -0
- package/dist/types/index.d.ts.map +1 -1
- package/docs/MIGRATION-GUIDE.md +771 -0
- package/package.json +2 -2
- package/docs/REFACTORING-PLAN.md +0 -374
- package/docs/TESTING-WITH-NATIVE-SWARM.md +0 -266
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
# Migration Guide: Foundation v1.x → v2.0
|
|
2
|
+
|
|
3
|
+
This guide helps you upgrade from Foundation v1.x to v2.0 with **Gaia's advanced memory system**.
|
|
4
|
+
|
|
5
|
+
**Good news:** v2.0 is **100% backward compatible**. All v1.x tools work identically. The new memory features are additive, not breaking.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
- [Quick Summary](#quick-summary)
|
|
12
|
+
- [What Changed](#what-changed)
|
|
13
|
+
- [Upgrade Steps](#upgrade-steps)
|
|
14
|
+
- [New Features](#new-features)
|
|
15
|
+
- [Code Migration Examples](#code-migration-examples)
|
|
16
|
+
- [Performance Improvements](#performance-improvements)
|
|
17
|
+
- [Breaking Changes](#breaking-changes)
|
|
18
|
+
- [Troubleshooting](#troubleshooting)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quick Summary
|
|
23
|
+
|
|
24
|
+
### v1.x → v2.0 Changes
|
|
25
|
+
|
|
26
|
+
| Area | v1.x | v2.0 | Impact |
|
|
27
|
+
|------|------|------|--------|
|
|
28
|
+
| **Checkpoint tools** | 9 tools | 9 tools + handoff + observe + migrate | ✅ 3 new tools |
|
|
29
|
+
| **Learning tools** | 3 tools | Same 3 tools | ✅ No changes |
|
|
30
|
+
| **Memory system** | None | 7 new tools | ✅ Additive only |
|
|
31
|
+
| **Database** | JSON files | SQLite + FTS5 | ✅ Auto-migrated |
|
|
32
|
+
| **Tool prefixes** | `gaia_*` | `gaia_*` | ✅ No changes |
|
|
33
|
+
| **Breaking changes** | - | - | ✅ None! |
|
|
34
|
+
|
|
35
|
+
**TL;DR:** Update the package, restart, start using new memory tools. All existing code works unchanged.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## What Changed
|
|
40
|
+
|
|
41
|
+
### Architecture Evolution
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
Foundation v1.x
|
|
45
|
+
├─ Demerzel (9 tools) - Codebase intelligence
|
|
46
|
+
├─ Seldon (12 tools) - Multi-agent orchestration
|
|
47
|
+
└─ Gaia (9 tools) - Workflow patterns
|
|
48
|
+
├─ Checkpoints (session state)
|
|
49
|
+
├─ Learning system (CLAUDE.md)
|
|
50
|
+
└─ JSON file storage
|
|
51
|
+
|
|
52
|
+
Foundation v2.0
|
|
53
|
+
├─ Demerzel (9 tools) - Codebase intelligence
|
|
54
|
+
├─ Seldon (12 tools) - Multi-agent orchestration
|
|
55
|
+
└─ Gaia (19 tools) - Workflow patterns + Advanced memory
|
|
56
|
+
├─ Workflow (12 tools) - Same as v1.x + handoff + observe + migrate ⭐
|
|
57
|
+
├─ Memory (5 tools) - NEW: SQLite + FTS5 + BM25 ⭐
|
|
58
|
+
└─ Linking (2 tools) - NEW: Cross-prompt dependency graphs ⭐
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Gaia v2.0 Upgrades
|
|
62
|
+
|
|
63
|
+
1. **SQLite + FTS5 Backend**
|
|
64
|
+
- Replaces JSON file storage
|
|
65
|
+
- Full-text search with BM25 ranking
|
|
66
|
+
- Production-grade persistence
|
|
67
|
+
|
|
68
|
+
2. **5-Tier Memory Hierarchy**
|
|
69
|
+
- session (ephemeral)
|
|
70
|
+
- project (cwd-scoped)
|
|
71
|
+
- global (user-wide)
|
|
72
|
+
- note (manual KB)
|
|
73
|
+
- observation (auto-learned)
|
|
74
|
+
|
|
75
|
+
3. **Cross-Prompt Linking**
|
|
76
|
+
- `depends_on`, `extends`, `reverts`, `related`, `contradicts`
|
|
77
|
+
- Build dependency graphs
|
|
78
|
+
- Trace decision chains
|
|
79
|
+
|
|
80
|
+
4. **Composite Scoring**
|
|
81
|
+
- BM25 relevance (40%)
|
|
82
|
+
- Recency (25%)
|
|
83
|
+
- Tier priority (15%)
|
|
84
|
+
- File proximity (10%)
|
|
85
|
+
- Access frequency (10%)
|
|
86
|
+
|
|
87
|
+
5. **Performance**
|
|
88
|
+
- 0.1ms inserts (110x target)
|
|
89
|
+
- 2ms search (25x target)
|
|
90
|
+
- ~1ms get by ID (5x target)
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Upgrade Steps
|
|
95
|
+
|
|
96
|
+
### Step 1: Update Package
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm install -g @sashabogi/foundation@latest
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Step 2: Verify Version
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
foundation status
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Should output:
|
|
109
|
+
```
|
|
110
|
+
🏛️ Foundation v2.0.0
|
|
111
|
+
Modules: Demerzel (codebase) | Seldon (agents) | Gaia (workflow + memory)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Step 3: Restart Claude Code
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Restart Claude Code to reload the MCP server
|
|
118
|
+
# No configuration changes needed
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Step 4: Test Existing Tools
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
// v1.x checkpoint tools still work identically
|
|
125
|
+
gaia_checkpoint({
|
|
126
|
+
summary: "Test upgrade",
|
|
127
|
+
decisions: [{ topic: "test", decision: "works", rationale: "testing" }]
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
// Should return success
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Step 5: Start Using New Tools
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// Save a memory
|
|
137
|
+
gaia_save({
|
|
138
|
+
tier: "project",
|
|
139
|
+
content: "Successfully upgraded to Foundation v2.0",
|
|
140
|
+
tags: ["upgrade", "milestone"]
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
// Search memories
|
|
144
|
+
gaia_search({ query: "upgrade" })
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Done!** Your v1.x tools still work, plus you have 11 new memory tools.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## New Features
|
|
152
|
+
|
|
153
|
+
### 1. Persistent Memory with gaia_save
|
|
154
|
+
|
|
155
|
+
**v1.x approach:**
|
|
156
|
+
```typescript
|
|
157
|
+
// Only checkpoints - not searchable
|
|
158
|
+
gaia_checkpoint({
|
|
159
|
+
summary: "Implemented auth with JWT",
|
|
160
|
+
decisions: [{
|
|
161
|
+
topic: "Authentication",
|
|
162
|
+
decision: "Use JWT with RS256",
|
|
163
|
+
rationale: "Industry standard, secure"
|
|
164
|
+
}]
|
|
165
|
+
})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**v2.0 approach (recommended):**
|
|
169
|
+
```typescript
|
|
170
|
+
// Searchable, linkable, persistent
|
|
171
|
+
gaia_save({
|
|
172
|
+
tier: "project",
|
|
173
|
+
content: "Decision: Use JWT with RS256 for authentication. Industry standard, secure.",
|
|
174
|
+
tags: ["decision", "auth", "jwt", "security"],
|
|
175
|
+
related_files: ["src/auth/jwt.ts"],
|
|
176
|
+
metadata: { decision_type: "technical", impact: "high" }
|
|
177
|
+
})
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Benefits:**
|
|
181
|
+
- ✅ Full-text search across all decisions
|
|
182
|
+
- ✅ Links to related decisions
|
|
183
|
+
- ✅ Survives session restarts
|
|
184
|
+
- ✅ Ranked by relevance + recency
|
|
185
|
+
|
|
186
|
+
### 2. Search with gaia_search
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
// Find all authentication-related decisions
|
|
190
|
+
gaia_search({
|
|
191
|
+
query: "authentication JWT security",
|
|
192
|
+
tiers: ["project", "global"],
|
|
193
|
+
limit: 10,
|
|
194
|
+
current_file: "src/auth/verify.ts" // Boosts related memories
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
// Returns ranked results with scores
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Search supports:**
|
|
201
|
+
- FTS5 syntax: `"exact phrase"`, `word*` (wildcard)
|
|
202
|
+
- Tier filtering
|
|
203
|
+
- File proximity boosting
|
|
204
|
+
- Composite scoring
|
|
205
|
+
|
|
206
|
+
### 3. Link Memories with gaia_link
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
// Day 1: Make a decision
|
|
210
|
+
const decision = gaia_save({
|
|
211
|
+
tier: "project",
|
|
212
|
+
content: "Decision: Use React 18 with TypeScript",
|
|
213
|
+
tags: ["decision", "react"]
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
// Day 2: Implement it
|
|
217
|
+
const impl = gaia_save({
|
|
218
|
+
tier: "project",
|
|
219
|
+
content: "Set up React 18 + Vite + TypeScript",
|
|
220
|
+
tags: ["implementation"]
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
// Link them
|
|
224
|
+
gaia_link({
|
|
225
|
+
from_memory_id: impl.memory.id,
|
|
226
|
+
to_memory_id: decision.memory.id,
|
|
227
|
+
link_type: "depends_on"
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
// Later: trace dependencies
|
|
231
|
+
gaia_graph({ memory_id: impl.memory.id })
|
|
232
|
+
// Shows: implementation → depends_on → decision
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Link types:**
|
|
236
|
+
- `depends_on` - Requires/builds on
|
|
237
|
+
- `extends` - Enhances/extends
|
|
238
|
+
- `reverts` - Undoes/reverses
|
|
239
|
+
- `related` - Associated
|
|
240
|
+
- `contradicts` - Conflicts with
|
|
241
|
+
|
|
242
|
+
### 4. Memory Statistics with gaia_stats
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
gaia_stats()
|
|
246
|
+
|
|
247
|
+
// Returns:
|
|
248
|
+
{
|
|
249
|
+
"total_memories": 247,
|
|
250
|
+
"by_tier": {
|
|
251
|
+
"session": 5,
|
|
252
|
+
"project": 89,
|
|
253
|
+
"global": 42,
|
|
254
|
+
"note": 111,
|
|
255
|
+
"observation": 0
|
|
256
|
+
},
|
|
257
|
+
"total_links": 34,
|
|
258
|
+
"database_size_mb": 0.18,
|
|
259
|
+
"age_range_days": 127
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 5. Session Handoff with gaia_handoff
|
|
264
|
+
|
|
265
|
+
**NEW in v2.0:** Create comprehensive handoff documents for session transitions.
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
// At session end - create checkpoint + handoff
|
|
269
|
+
gaia_checkpoint({
|
|
270
|
+
summary: "Implemented auth system",
|
|
271
|
+
purpose: "Build secure authentication",
|
|
272
|
+
decisions: [/* ... */],
|
|
273
|
+
progress: [/* ... */],
|
|
274
|
+
changes: [/* ... */]
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
// Generate handoff document
|
|
278
|
+
gaia_handoff({
|
|
279
|
+
next_steps: [
|
|
280
|
+
"Implement refresh token rotation",
|
|
281
|
+
"Add rate limiting to login endpoint",
|
|
282
|
+
"Write integration tests for auth flow"
|
|
283
|
+
],
|
|
284
|
+
context_notes: "Auth system 80% complete. Main work remaining is refresh token security.",
|
|
285
|
+
include_memories: true,
|
|
286
|
+
memory_query: "authentication JWT"
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
// Saves to: ~/.foundation/handoffs/handoff-2026-02-16T10-30-00.md
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Handoff document includes:**
|
|
293
|
+
- ✅ Current session state from checkpoint
|
|
294
|
+
- ✅ Recent decisions with rationales
|
|
295
|
+
- ✅ Task progress (completed/in_progress/blocked)
|
|
296
|
+
- ✅ Files changed in session
|
|
297
|
+
- ✅ Open questions for next session
|
|
298
|
+
- ✅ Relevant memories (BM25 ranked)
|
|
299
|
+
- ✅ Next steps (user-provided)
|
|
300
|
+
- ✅ Additional context notes
|
|
301
|
+
|
|
302
|
+
**Use cases:**
|
|
303
|
+
- Transitioning between work sessions
|
|
304
|
+
- Handing off work to team members
|
|
305
|
+
- Documenting project state at milestones
|
|
306
|
+
- Creating context for future AI sessions
|
|
307
|
+
|
|
308
|
+
### 6. Autonomous Observation with gaia_observe
|
|
309
|
+
|
|
310
|
+
**NEW in v2.0:** Automatically detect patterns and anti-patterns from session activity.
|
|
311
|
+
|
|
312
|
+
```typescript
|
|
313
|
+
// Analyze current session for patterns
|
|
314
|
+
gaia_observe({
|
|
315
|
+
lookback_days: 30,
|
|
316
|
+
auto_save: true,
|
|
317
|
+
min_confidence: "medium"
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
// Returns detected patterns like:
|
|
321
|
+
// 1. 🔴 Repeated decision-making on: Authentication (high confidence)
|
|
322
|
+
// 2. 🔴 Task blockers detected (high confidence)
|
|
323
|
+
// 3. 🟡 Frequent modifications to: src/auth/jwt.ts (medium)
|
|
324
|
+
// 4. 🟡 Multiple open questions - potential knowledge gaps (medium)
|
|
325
|
+
// 5. 🔴 High activity in areas: authentication, security (high)
|
|
326
|
+
// 6. 🟡 File created and deleted: src/temp/test.ts (medium)
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Pattern types detected:**
|
|
330
|
+
- ✅ Repeated topics (same decisions multiple times)
|
|
331
|
+
- ✅ Task blockers (blocked status in progress tracking)
|
|
332
|
+
- ✅ Frequent file changes (same file modified 3+ times)
|
|
333
|
+
- ✅ Knowledge gaps (multiple unresolved questions)
|
|
334
|
+
- ✅ Activity hotspots (frequent tags in recent memories)
|
|
335
|
+
- ✅ Anti-patterns (created then deleted files)
|
|
336
|
+
|
|
337
|
+
**How it works:**
|
|
338
|
+
1. Analyzes latest checkpoint (decisions, progress, changes)
|
|
339
|
+
2. Scans recent memories for tag frequency patterns
|
|
340
|
+
3. Detects patterns with confidence scoring (low/medium/high)
|
|
341
|
+
4. Auto-saves to `observation` tier in memory system
|
|
342
|
+
5. Enriches with metadata for future pattern analysis
|
|
343
|
+
|
|
344
|
+
**Complements manual learning:**
|
|
345
|
+
- `gaia_learn` - Manual corrections for CLAUDE.md
|
|
346
|
+
- `gaia_observe` - Automatic pattern detection for observations
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## Code Migration Examples
|
|
351
|
+
|
|
352
|
+
### Example 1: Architecture Decisions
|
|
353
|
+
|
|
354
|
+
**v1.x:**
|
|
355
|
+
```typescript
|
|
356
|
+
// Save decision in checkpoint
|
|
357
|
+
gaia_checkpoint({
|
|
358
|
+
summary: "Chose PostgreSQL",
|
|
359
|
+
decisions: [{
|
|
360
|
+
topic: "Database",
|
|
361
|
+
decision: "PostgreSQL with Drizzle ORM",
|
|
362
|
+
rationale: "Type safety, migrations"
|
|
363
|
+
}]
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
// Later - retrieve decisions
|
|
367
|
+
gaia_get_decisions()
|
|
368
|
+
// Returns all decisions from latest checkpoint
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**v2.0 (recommended):**
|
|
372
|
+
```typescript
|
|
373
|
+
// Save as searchable memory
|
|
374
|
+
gaia_save({
|
|
375
|
+
tier: "project",
|
|
376
|
+
content: "Database decision: PostgreSQL with Drizzle ORM for type safety and migrations",
|
|
377
|
+
tags: ["decision", "database", "postgresql", "drizzle"],
|
|
378
|
+
related_files: ["drizzle.config.ts", "src/db/schema.ts"],
|
|
379
|
+
metadata: { decision_type: "technical", confidence: "high" }
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
// Later - search decisions
|
|
383
|
+
gaia_search({
|
|
384
|
+
query: "database PostgreSQL",
|
|
385
|
+
tiers: ["project"],
|
|
386
|
+
limit: 5
|
|
387
|
+
})
|
|
388
|
+
// Returns ranked results across all sessions
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Benefits:**
|
|
392
|
+
- Survives session restarts
|
|
393
|
+
- Searchable across all time
|
|
394
|
+
- Linkable to implementations
|
|
395
|
+
- File-scoped proximity
|
|
396
|
+
|
|
397
|
+
### Example 2: Session Workflow
|
|
398
|
+
|
|
399
|
+
**v1.x:**
|
|
400
|
+
```typescript
|
|
401
|
+
// Session checkpoint
|
|
402
|
+
gaia_checkpoint({
|
|
403
|
+
summary: "Fixed login bug",
|
|
404
|
+
changes: [{
|
|
405
|
+
file: "src/auth/login.ts",
|
|
406
|
+
action: "modified",
|
|
407
|
+
summary: "Fixed token validation"
|
|
408
|
+
}]
|
|
409
|
+
})
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
**v2.0 (hybrid approach):**
|
|
413
|
+
```typescript
|
|
414
|
+
// Use both: checkpoint for session state + memory for knowledge
|
|
415
|
+
gaia_checkpoint({
|
|
416
|
+
summary: "Fixed login bug",
|
|
417
|
+
changes: [...]
|
|
418
|
+
})
|
|
419
|
+
|
|
420
|
+
// ALSO save as searchable memory
|
|
421
|
+
gaia_save({
|
|
422
|
+
tier: "project",
|
|
423
|
+
content: "Bug fix: Token validation was failing on expired tokens. Now returns 401 with clear error message.",
|
|
424
|
+
tags: ["bugfix", "auth", "tokens", "validation"],
|
|
425
|
+
related_files: ["src/auth/login.ts"]
|
|
426
|
+
})
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
**Why both?**
|
|
430
|
+
- **Checkpoint**: Session-specific state (progress, changes)
|
|
431
|
+
- **Memory**: Long-term searchable knowledge
|
|
432
|
+
|
|
433
|
+
### Example 3: Learning from Mistakes
|
|
434
|
+
|
|
435
|
+
**v1.x:**
|
|
436
|
+
```typescript
|
|
437
|
+
// Capture learning
|
|
438
|
+
gaia_learn({
|
|
439
|
+
mistake: "Hardcoded API URL",
|
|
440
|
+
correction: "Use environment variables",
|
|
441
|
+
category: "architecture",
|
|
442
|
+
scope: "global"
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
// Apply to CLAUDE.md
|
|
446
|
+
gaia_apply()
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
**v2.0 (enhanced):**
|
|
450
|
+
```typescript
|
|
451
|
+
// Still use v1.x learning tools for CLAUDE.md
|
|
452
|
+
gaia_learn({
|
|
453
|
+
mistake: "Hardcoded API URL",
|
|
454
|
+
correction: "Use environment variables",
|
|
455
|
+
category: "architecture",
|
|
456
|
+
scope: "global"
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
gaia_apply()
|
|
460
|
+
|
|
461
|
+
// ALSO save as searchable memory
|
|
462
|
+
gaia_save({
|
|
463
|
+
tier: "global",
|
|
464
|
+
content: "Best practice: Always use environment variables for API URLs. Never hardcode configuration.",
|
|
465
|
+
tags: ["best-practice", "configuration", "environment-variables"],
|
|
466
|
+
metadata: { learned_from: "mistake", severity: "medium" }
|
|
467
|
+
})
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
**Benefits:**
|
|
471
|
+
- CLAUDE.md gets updated (v1.x behavior)
|
|
472
|
+
- Memory is searchable (v2.0 feature)
|
|
473
|
+
- Applies globally across projects
|
|
474
|
+
|
|
475
|
+
---
|
|
476
|
+
|
|
477
|
+
## Performance Improvements
|
|
478
|
+
|
|
479
|
+
### Storage Performance
|
|
480
|
+
|
|
481
|
+
| Operation | v1.x (JSON) | v2.0 (SQLite) | Improvement |
|
|
482
|
+
|-----------|-------------|---------------|-------------|
|
|
483
|
+
| Save memory | ~5ms | 0.1ms | **50x faster** |
|
|
484
|
+
| Search | N/A | 2ms | **NEW** |
|
|
485
|
+
| Get by ID | ~2ms | ~1ms | **2x faster** |
|
|
486
|
+
| List all | ~10ms | ~3ms | **3x faster** |
|
|
487
|
+
|
|
488
|
+
### Database Size
|
|
489
|
+
|
|
490
|
+
| Memories | v1.x (JSON) | v2.0 (SQLite) | Efficiency |
|
|
491
|
+
|----------|-------------|---------------|------------|
|
|
492
|
+
| 100 | ~0.8 MB | ~0.04 MB | **20x smaller** |
|
|
493
|
+
| 1000 | ~8 MB | ~0.43 MB | **18x smaller** |
|
|
494
|
+
| 10000 | ~80 MB | ~4.3 MB | **18x smaller** |
|
|
495
|
+
|
|
496
|
+
### Search Capabilities
|
|
497
|
+
|
|
498
|
+
| Feature | v1.x | v2.0 |
|
|
499
|
+
|---------|------|------|
|
|
500
|
+
| Full-text search | ❌ | ✅ FTS5 + BM25 |
|
|
501
|
+
| Ranked results | ❌ | ✅ Composite scoring |
|
|
502
|
+
| Wildcard search | ❌ | ✅ `word*` |
|
|
503
|
+
| Phrase search | ❌ | ✅ `"exact phrase"` |
|
|
504
|
+
| Tier filtering | ❌ | ✅ Filter by scope |
|
|
505
|
+
| File proximity | ❌ | ✅ Boost by current file |
|
|
506
|
+
|
|
507
|
+
---
|
|
508
|
+
|
|
509
|
+
## Breaking Changes
|
|
510
|
+
|
|
511
|
+
### None!
|
|
512
|
+
|
|
513
|
+
Foundation v2.0 has **zero breaking changes**. All v1.x code works identically.
|
|
514
|
+
|
|
515
|
+
### Module Renaming (Informational Only)
|
|
516
|
+
|
|
517
|
+
Internal module names changed for clarity, but **tool names are unchanged**:
|
|
518
|
+
|
|
519
|
+
| v1.x Internal | v2.0 Internal | Tool Prefix | Change Impact |
|
|
520
|
+
|---------------|---------------|-------------|---------------|
|
|
521
|
+
| Argus | Demerzel | `demerzel_*` | ❌ Tool names unchanged |
|
|
522
|
+
| Orchestrator | Gaia | `gaia_*` | ❌ Tool names unchanged |
|
|
523
|
+
| Seldon | Seldon | `seldon_*` | ❌ No change |
|
|
524
|
+
|
|
525
|
+
**You don't need to update any code.** The module renames are internal only.
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## Troubleshooting
|
|
530
|
+
|
|
531
|
+
### Issue: "Database locked"
|
|
532
|
+
|
|
533
|
+
**Cause:** Multiple Foundation instances running
|
|
534
|
+
|
|
535
|
+
**Solution:**
|
|
536
|
+
```bash
|
|
537
|
+
# Kill all Foundation processes
|
|
538
|
+
pkill -f foundation
|
|
539
|
+
|
|
540
|
+
# Restart Claude Code
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### Issue: "Memory not found"
|
|
544
|
+
|
|
545
|
+
**Cause:** Looking for v1.x checkpoint data in v2.0 memory
|
|
546
|
+
|
|
547
|
+
**Solution:**
|
|
548
|
+
```typescript
|
|
549
|
+
// v1.x checkpoints still use:
|
|
550
|
+
gaia_get_decisions() // Works in v2.0
|
|
551
|
+
|
|
552
|
+
// v2.0 memories use:
|
|
553
|
+
gaia_search({ query: "..." }) // New in v2.0
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**They're separate systems** - checkpoints vs. memories.
|
|
557
|
+
|
|
558
|
+
### Issue: "FTS5 syntax error"
|
|
559
|
+
|
|
560
|
+
**Cause:** Invalid search query
|
|
561
|
+
|
|
562
|
+
**Solution:**
|
|
563
|
+
```typescript
|
|
564
|
+
// ✅ Valid queries
|
|
565
|
+
gaia_search({ query: "JWT authentication" })
|
|
566
|
+
gaia_search({ query: "auth*" })
|
|
567
|
+
gaia_search({ query: '"exact phrase"' })
|
|
568
|
+
|
|
569
|
+
// ❌ Invalid queries
|
|
570
|
+
gaia_search({ query: 'unclosed "quote' }) // Syntax error
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Issue: "Slow search performance"
|
|
574
|
+
|
|
575
|
+
**Cause:** Too many results, no tier filtering
|
|
576
|
+
|
|
577
|
+
**Solution:**
|
|
578
|
+
```typescript
|
|
579
|
+
// ❌ Slow (searches all tiers, all time)
|
|
580
|
+
gaia_search({ query: "auth", limit: 1000 })
|
|
581
|
+
|
|
582
|
+
// ✅ Fast (filter by tier, reasonable limit)
|
|
583
|
+
gaia_search({
|
|
584
|
+
query: "auth",
|
|
585
|
+
tiers: ["project"],
|
|
586
|
+
limit: 20
|
|
587
|
+
})
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
### Issue: "Database file too large"
|
|
591
|
+
|
|
592
|
+
**Cause:** Too many session-tier memories not cleaned up
|
|
593
|
+
|
|
594
|
+
**Solution:**
|
|
595
|
+
```typescript
|
|
596
|
+
// Delete old session memories
|
|
597
|
+
gaia_search({ tiers: ["session"] })
|
|
598
|
+
// Review results, then:
|
|
599
|
+
gaia_delete({ id: "mem_old_session_123" })
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
**Prevention:** Use `tier: "session"` only for truly ephemeral data.
|
|
603
|
+
|
|
604
|
+
---
|
|
605
|
+
|
|
606
|
+
## Data Migration
|
|
607
|
+
|
|
608
|
+
### Automatic Migration
|
|
609
|
+
|
|
610
|
+
Foundation v2.0 automatically creates the SQLite database on first use. No migration needed.
|
|
611
|
+
|
|
612
|
+
### Manual Data Preservation
|
|
613
|
+
|
|
614
|
+
If you want to preserve v1.x checkpoint data:
|
|
615
|
+
|
|
616
|
+
```bash
|
|
617
|
+
# v1.x checkpoints are stored here:
|
|
618
|
+
~/.foundation/sessions/
|
|
619
|
+
|
|
620
|
+
# They still work in v2.0!
|
|
621
|
+
# No migration needed.
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
### Migrating v1.x Checkpoints to v2.0 Memories (Automated)
|
|
625
|
+
|
|
626
|
+
**NEW in v2.0:** Use `gaia_migrate` to automatically convert v1 checkpoint data to v2 memories.
|
|
627
|
+
|
|
628
|
+
```typescript
|
|
629
|
+
// Step 1: Preview what will be migrated (dry run)
|
|
630
|
+
gaia_migrate({
|
|
631
|
+
dry_run: true,
|
|
632
|
+
include_checkpoints: true,
|
|
633
|
+
sessions_limit: 10 // Preview first 10 sessions
|
|
634
|
+
})
|
|
635
|
+
|
|
636
|
+
// Returns:
|
|
637
|
+
// ## Gaia v1 → v2 Migration (DRY RUN)
|
|
638
|
+
//
|
|
639
|
+
// ### Checkpoint Migration
|
|
640
|
+
// Found 15 session(s)
|
|
641
|
+
// Processing 10 session(s)
|
|
642
|
+
//
|
|
643
|
+
// #### Session: ckpt_abc123
|
|
644
|
+
// Project: acme-auth
|
|
645
|
+
// Purpose: Build authentication system
|
|
646
|
+
//
|
|
647
|
+
// • Decision: Authentication
|
|
648
|
+
// • Decision: Token Storage
|
|
649
|
+
// • Progress: Implement JWT generation
|
|
650
|
+
// • Progress: Add token validation middleware
|
|
651
|
+
//
|
|
652
|
+
// ---
|
|
653
|
+
// ### Migration Summary
|
|
654
|
+
// Sessions processed: 10
|
|
655
|
+
// Decisions: 23
|
|
656
|
+
// Completed tasks: 15
|
|
657
|
+
// Total items: 38
|
|
658
|
+
//
|
|
659
|
+
// ⚠️ DRY RUN MODE - No data was saved
|
|
660
|
+
|
|
661
|
+
// Step 2: Perform actual migration
|
|
662
|
+
gaia_migrate({
|
|
663
|
+
dry_run: false,
|
|
664
|
+
include_checkpoints: true
|
|
665
|
+
})
|
|
666
|
+
|
|
667
|
+
// Returns:
|
|
668
|
+
// ✓ Migrated 38 memories to v2 system
|
|
669
|
+
//
|
|
670
|
+
// Next steps:
|
|
671
|
+
// 1. Search migrated data: gaia_search({ query: "migrated-v1", tags: ["migrated-v1"] })
|
|
672
|
+
// 2. Verify decisions: gaia_search({ query: "decision", tiers: ["project"] })
|
|
673
|
+
// 3. Review in context: Use current_file parameter for proximity boosting
|
|
674
|
+
|
|
675
|
+
// Step 3: Search your migrated data
|
|
676
|
+
gaia_search({
|
|
677
|
+
query: "authentication decision",
|
|
678
|
+
tiers: ["project"],
|
|
679
|
+
limit: 10
|
|
680
|
+
})
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
**What gets migrated:**
|
|
684
|
+
- ✅ Decisions → `project` tier with tags: `["migrated-v1", "decision", topic-tag]`
|
|
685
|
+
- ✅ Completed tasks → `session` tier with tags: `["migrated-v1", "completed", "progress"]`
|
|
686
|
+
- ✅ Metadata preserved: original checkpoint ID, timestamps, topics
|
|
687
|
+
- ✅ Files linked: relevant_files from checkpoint context
|
|
688
|
+
- ✅ Searchable: Full FTS5 + BM25 ranking immediately available
|
|
689
|
+
|
|
690
|
+
---
|
|
691
|
+
|
|
692
|
+
## Best Practices for v2.0
|
|
693
|
+
|
|
694
|
+
### 1. Choose the Right Tier
|
|
695
|
+
|
|
696
|
+
```typescript
|
|
697
|
+
// ✅ Good tier usage
|
|
698
|
+
gaia_save({ tier: "session", content: "TODO: Review PR #123" })
|
|
699
|
+
gaia_save({ tier: "project", content: "Decision: Use tRPC" })
|
|
700
|
+
gaia_save({ tier: "global", content: "Best practice: Always validate input" })
|
|
701
|
+
gaia_save({ tier: "note", content: "Tutorial: How to use React Query" })
|
|
702
|
+
gaia_save({ tier: "observation", content: "User often forgets to commit .env.example" })
|
|
703
|
+
|
|
704
|
+
// ❌ Bad tier usage
|
|
705
|
+
gaia_save({ tier: "global", content: "TODO: Fix bug" }) // Should be session
|
|
706
|
+
gaia_save({ tier: "session", content: "Best practice: ..." }) // Should be global
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
### 2. Tag Strategically
|
|
710
|
+
|
|
711
|
+
```typescript
|
|
712
|
+
// ✅ Good tags (3-5, specific)
|
|
713
|
+
tags: ["decision", "database", "postgresql", "architecture"]
|
|
714
|
+
|
|
715
|
+
// ❌ Bad tags (too many, too generic)
|
|
716
|
+
tags: ["tech", "dev", "code", "work", "project", "database", "sql", "data", ...]
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
### 3. Link Related Memories
|
|
720
|
+
|
|
721
|
+
```typescript
|
|
722
|
+
// Save decision
|
|
723
|
+
const decision = gaia_save({ tier: "project", content: "..." })
|
|
724
|
+
|
|
725
|
+
// Save implementation
|
|
726
|
+
const impl = gaia_save({ tier: "project", content: "..." })
|
|
727
|
+
|
|
728
|
+
// Link them
|
|
729
|
+
gaia_link({
|
|
730
|
+
from_memory_id: impl.memory.id,
|
|
731
|
+
to_memory_id: decision.memory.id,
|
|
732
|
+
link_type: "depends_on"
|
|
733
|
+
})
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
### 4. Use Both Checkpoints and Memories
|
|
737
|
+
|
|
738
|
+
```typescript
|
|
739
|
+
// Checkpoint: Session state
|
|
740
|
+
gaia_checkpoint({
|
|
741
|
+
summary: "Implemented feature X",
|
|
742
|
+
progress: [...],
|
|
743
|
+
changes: [...]
|
|
744
|
+
})
|
|
745
|
+
|
|
746
|
+
// Memory: Long-term knowledge
|
|
747
|
+
gaia_save({
|
|
748
|
+
tier: "project",
|
|
749
|
+
content: "Feature X uses pattern Y because Z",
|
|
750
|
+
tags: ["implementation", "pattern"]
|
|
751
|
+
})
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
---
|
|
755
|
+
|
|
756
|
+
## Summary
|
|
757
|
+
|
|
758
|
+
Foundation v2.0 is a **non-breaking upgrade** that adds powerful memory features while preserving all v1.x functionality.
|
|
759
|
+
|
|
760
|
+
**Upgrade checklist:**
|
|
761
|
+
- ✅ Update package: `npm install -g @sashabogi/foundation@latest`
|
|
762
|
+
- ✅ Restart Claude Code
|
|
763
|
+
- ✅ Test existing tools (they work unchanged)
|
|
764
|
+
- ✅ Start using `gaia_save`, `gaia_search`, `gaia_link`
|
|
765
|
+
- ✅ Read [README.md](../README.md) for deep dive
|
|
766
|
+
|
|
767
|
+
**Questions?** Open an issue on [GitHub](https://github.com/sashabogi/foundation/issues).
|
|
768
|
+
|
|
769
|
+
---
|
|
770
|
+
|
|
771
|
+
**Welcome to Foundation v2.0!** 🎉
|