@sashabogi/foundation 0.1.10 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,374 @@
1
+ # Foundation Refactoring Plan: Native Swarm Integration
2
+
3
+ **Date:** February 1, 2026
4
+ **Branch:** `feature/native-swarm-integration`
5
+ **Status:** Planning
6
+
7
+ ---
8
+
9
+ ## Executive Summary
10
+
11
+ Claude Code has native multi-agent orchestration (swarm mode) behind a feature flag. This changes Foundation's role from "full orchestration stack" to "multi-provider routing layer." This plan documents what to keep, remove, and modify.
12
+
13
+ ---
14
+
15
+ ## Context
16
+
17
+ ### Native Swarm Capabilities (confirmed working)
18
+
19
+ | Tool | Operations | What It Does |
20
+ |------|------------|--------------|
21
+ | **Teammate** | 6 ops | Team creation, discovery, join/approve workflow |
22
+ | **SendMessage** | 4 ops | Direct messages, broadcasts, protocol requests |
23
+ | **Task*** | 4 tools | Shared task list across teammates |
24
+ | **ExitPlanMode** | Extended | `launchSwarm`, `teammateCount` parameters |
25
+
26
+ ### What Native Swarm Does NOT Have
27
+
28
+ - Multi-provider support (Claude only)
29
+ - Role-based routing (coder → Kimi, designer → Gemini)
30
+ - Provider failover and health tracking
31
+ - Verification loops (verify → fix → re-verify)
32
+ - Codebase intelligence (Demerzel)
33
+ - Self-learning CLAUDE.md (Gaia learning)
34
+
35
+ ---
36
+
37
+ ## Refactoring Strategy
38
+
39
+ ### Principle: Foundation = Provider Layer, Native = Orchestration Layer
40
+
41
+ ```
42
+ ┌─────────────────────────────────────────────────────────────┐
43
+ │ CLAUDE CODE (with native swarm) │
44
+ │ • Teammate tool (team management) │
45
+ │ • SendMessage tool (inter-agent communication) │
46
+ │ • Task* tools (shared task list) │
47
+ │ • Worktree management (built-in) │
48
+ └──────────────────────────┬──────────────────────────────────┘
49
+ │ MCP Connection
50
+
51
+ ┌─────────────────────────────────────────────────────────────┐
52
+ │ FOUNDATION (Refactored) │
53
+ │ │
54
+ │ DEMERZEL (unchanged) SELDON (simplified) GAIA │
55
+ │ ├─ snapshot ├─ invoke (learning │
56
+ │ ├─ search ├─ compare only) │
57
+ │ ├─ find_files ├─ verify ├─ learn │
58
+ │ ├─ find_symbol ├─ fix ├─ apply │
59
+ │ ├─ find_importers ├─ execute_verified ├─ review │
60
+ │ ├─ get_deps ├─ providers_list ├─ remember │
61
+ │ ├─ get_context └─ providers_test └─ recall │
62
+ │ ├─ analyze │
63
+ │ └─ semantic_search │
64
+ │ │
65
+ │ REMOVED: │
66
+ │ ✗ gaia_worktree_* (use native) │
67
+ │ ✗ gaia_session_* (use native Teammate) │
68
+ │ ✗ seldon_task_* (use native Task*) │
69
+ │ ✗ seldon_phase_* (use native launchSwarm) │
70
+ │ ✗ seldon_pipeline_* (simplify to invoke/verify) │
71
+ └─────────────────────────────────────────────────────────────┘
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Detailed Changes
77
+
78
+ ### DEMERZEL Module (9 tools) — NO CHANGES
79
+
80
+ All Demerzel tools remain unchanged. Native swarm has no codebase intelligence.
81
+
82
+ | Tool | Status | Reason |
83
+ |------|--------|--------|
84
+ | `demerzel_snapshot` | ✅ Keep | Unique value |
85
+ | `demerzel_search` | ✅ Keep | Unique value |
86
+ | `demerzel_find_files` | ✅ Keep | Unique value |
87
+ | `demerzel_find_symbol` | ✅ Keep | Unique value |
88
+ | `demerzel_find_importers` | ✅ Keep | Unique value |
89
+ | `demerzel_get_deps` | ✅ Keep | Unique value |
90
+ | `demerzel_get_context` | ✅ Keep | Unique value |
91
+ | `demerzel_analyze` | ✅ Keep | Unique value |
92
+ | `demerzel_semantic_search` | ✅ Keep | Unique value |
93
+
94
+ ---
95
+
96
+ ### SELDON Module (19 → 7 tools) — MAJOR SIMPLIFICATION
97
+
98
+ #### Keep (7 tools)
99
+
100
+ | Tool | Reason |
101
+ |------|--------|
102
+ | `seldon_invoke` | Core multi-provider routing |
103
+ | `seldon_compare` | Run task through multiple providers |
104
+ | `seldon_critique` | Convenience wrapper for critic role |
105
+ | `seldon_review` | Convenience wrapper for reviewer role |
106
+ | `seldon_verify` | Verification against plan (unique) |
107
+ | `seldon_fix` | Generate fixes for issues (unique) |
108
+ | `seldon_execute_verified` | Verify/fix loop (unique) |
109
+ | `seldon_providers_list` | Provider health visibility |
110
+ | `seldon_providers_test` | Provider connectivity check |
111
+
112
+ #### Remove (12 tools)
113
+
114
+ | Tool | Reason | Native Replacement |
115
+ |------|--------|-------------------|
116
+ | `seldon_plan` | Use Claude's native planning | `EnterPlanMode` |
117
+ | `seldon_phase_create` | Use native swarm | `ExitPlanMode({ launchSwarm })` |
118
+ | `seldon_phase_list` | Use native swarm | `TaskList` |
119
+ | `seldon_execute_parallel` | Use native swarm | `launchSwarm` + `teammateCount` |
120
+ | `seldon_pipeline_create` | Over-engineered | Remove |
121
+ | `seldon_pipeline_execute` | Over-engineered | Remove |
122
+ | `seldon_pipeline_status` | Over-engineered | Remove |
123
+ | `seldon_task_execute` | Use native | `Task` with `team_name` |
124
+ | `seldon_task_claim` | Use native | `TaskUpdate` with owner |
125
+ | `seldon_design` | Rarely used | Keep `seldon_invoke` with role |
126
+
127
+ ---
128
+
129
+ ### GAIA Module (13 → 5 tools) — MAJOR SIMPLIFICATION
130
+
131
+ #### Keep (5 tools)
132
+
133
+ | Tool | Reason |
134
+ |------|--------|
135
+ | `gaia_learn` | Self-learning CLAUDE.md (unique) |
136
+ | `gaia_apply` | Write learnings (unique) |
137
+ | `gaia_review` | Review learnings (unique) |
138
+ | `gaia_remember` | Context snapshots (useful) |
139
+ | `gaia_recall` | Restore context (useful) |
140
+
141
+ #### Remove (8 tools)
142
+
143
+ | Tool | Reason | Native Replacement |
144
+ |------|--------|-------------------|
145
+ | `gaia_worktree_create` | Native has worktrees | Native swarm worktrees |
146
+ | `gaia_worktree_list` | Native has worktrees | Native swarm |
147
+ | `gaia_worktree_switch` | Native has worktrees | Native swarm |
148
+ | `gaia_worktree_cleanup` | Native has worktrees | `Teammate({ operation: "cleanup" })` |
149
+ | `gaia_session_register` | Native has teams | `Teammate({ operation: "spawnTeam" })` |
150
+ | `gaia_session_status` | Native has teams | `Teammate({ operation: "discoverTeams" })` |
151
+ | `gaia_session_handoff` | Simplify | Can be done manually |
152
+ | `gaia_session_complete` | Native has teams | `Teammate({ operation: "cleanup" })` |
153
+
154
+ ---
155
+
156
+ ## Tool Count Summary
157
+
158
+ | Module | Before | After | Removed |
159
+ |--------|--------|-------|---------|
160
+ | Demerzel | 9 | 9 | 0 |
161
+ | Seldon | 19 | 9 | 10 |
162
+ | Gaia | 13 | 5 | 8 |
163
+ | **Total** | **41** | **23** | **18** |
164
+
165
+ **44% reduction in tool count** while maintaining core value.
166
+
167
+ ---
168
+
169
+ ## Services Changes
170
+
171
+ ### Keep Unchanged
172
+ - `ConfigService` — Still needed for provider config
173
+ - `ProviderService` — Core value, multi-provider routing
174
+ - `StorageService` — Still needed for learnings, provider health
175
+
176
+ ### Simplify
177
+ - `GitService` — Remove worktree functions, keep only diff/branch utilities
178
+
179
+ ### Remove
180
+ - Worktree state management in StorageService
181
+ - Session state management in StorageService
182
+
183
+ ---
184
+
185
+ ## Configuration Simplification
186
+
187
+ ### Before (`~/.foundation/config.yaml`)
188
+
189
+ ```yaml
190
+ version: "1.0"
191
+
192
+ providers:
193
+ anthropic: { ... }
194
+ openai: { ... }
195
+ deepseek: { ... }
196
+ kimi: { ... }
197
+ zai: { ... }
198
+
199
+ roles:
200
+ orchestrator: { provider: anthropic, model: claude-sonnet-4 }
201
+ coder: { provider: kimi, model: kimi-2.5, fallback_chain: [...] }
202
+ critic: { provider: deepseek, model: deepseek-reasoner }
203
+ reviewer: { provider: openai, model: gpt-4o }
204
+ designer: { provider: google, model: gemini-2.5-pro }
205
+
206
+ demerzel: { ... }
207
+
208
+ # REMOVE THESE:
209
+ worktrees:
210
+ base_dir: .foundation/worktrees
211
+ max_count: 10
212
+
213
+ sessions:
214
+ auto_handoff: true
215
+ ```
216
+
217
+ ### After
218
+
219
+ ```yaml
220
+ version: "2.0"
221
+
222
+ providers:
223
+ anthropic: { ... }
224
+ openai: { ... }
225
+ deepseek: { ... }
226
+ kimi: { ... }
227
+ zai: { ... }
228
+
229
+ roles:
230
+ orchestrator: { provider: anthropic, model: claude-sonnet-4 }
231
+ coder: { provider: kimi, model: kimi-2.5, fallback_chain: [...] }
232
+ critic: { provider: deepseek, model: deepseek-reasoner }
233
+ reviewer: { provider: openai, model: gpt-4o }
234
+
235
+ demerzel:
236
+ provider: ollama
237
+ model: qwen2.5-coder:7b
238
+
239
+ learning:
240
+ auto_apply: false
241
+ target_file: CLAUDE.md
242
+ ```
243
+
244
+ ---
245
+
246
+ ## Migration Path
247
+
248
+ ### Phase 1: Create Branch & Scaffold (Day 1)
249
+ 1. Create `feature/native-swarm-integration` branch
250
+ 2. Update package.json version to 0.2.0-alpha
251
+ 3. Create feature flag for gradual rollout
252
+
253
+ ### Phase 2: Remove Gaia Session/Worktree Tools (Day 1-2)
254
+ 1. Remove 8 Gaia tools
255
+ 2. Update Gaia index.ts
256
+ 3. Remove worktree state from StorageService
257
+ 4. Remove session state from StorageService
258
+ 5. Update tests
259
+
260
+ ### Phase 3: Simplify Seldon (Day 2-3)
261
+ 1. Remove 10 Seldon tools
262
+ 2. Keep verification loop intact
263
+ 3. Update Seldon index.ts
264
+ 4. Update tests
265
+
266
+ ### Phase 4: Update Configuration (Day 3)
267
+ 1. Bump config version to 2.0
268
+ 2. Remove worktree/session config sections
269
+ 3. Add migration script for existing configs
270
+
271
+ ### Phase 5: Documentation & Testing (Day 4)
272
+ 1. Update README
273
+ 2. Update USER-GUIDE
274
+ 3. Test with claudesp (native swarm)
275
+ 4. Test with regular Claude Code (fallback mode)
276
+
277
+ ### Phase 6: Ludicrous Ralphy Integration (Day 5+)
278
+ 1. Remove AgentRouter from LR
279
+ 2. Remove old Hari Seldon from LR
280
+ 3. Add Foundation MCP connection
281
+ 4. Test full flow: LR Dashboard → Foundation → Providers
282
+
283
+ ---
284
+
285
+ ## Testing Strategy
286
+
287
+ ### Test Environment
288
+
289
+ ```bash
290
+ # Terminal 1: Foundation MCP server
291
+ cd /Users/sashabogojevic/development/foundation/foundation
292
+ npm run dev
293
+
294
+ # Terminal 2: Claude Code with native swarm + Foundation
295
+ claudesp --dangerously-skip-permissions --mcp-config ~/.claude/mcp.json
296
+ ```
297
+
298
+ ### Test Cases
299
+
300
+ #### 1. Multi-Provider Routing (Foundation)
301
+ ```
302
+ Use seldon_invoke with role "coder" to write a Python function
303
+ ```
304
+ Expected: Routes to Kimi/GLM per config
305
+
306
+ #### 2. Native Swarm Team Creation
307
+ ```
308
+ Use Teammate tool to create a team called "test-team"
309
+ ```
310
+ Expected: Team created, can spawn workers
311
+
312
+ #### 3. Hybrid Flow (Foundation + Native)
313
+ ```
314
+ 1. Create a team with Teammate
315
+ 2. Use seldon_invoke to get code from Kimi
316
+ 3. Use SendMessage to coordinate
317
+ ```
318
+ Expected: Best of both worlds
319
+
320
+ #### 4. Verification Loop (Foundation)
321
+ ```
322
+ 1. seldon_invoke: Generate code with coder role
323
+ 2. seldon_verify: Check against requirements
324
+ 3. seldon_fix: Fix any issues
325
+ ```
326
+ Expected: Verify/fix loop works
327
+
328
+ ---
329
+
330
+ ## Rollback Plan
331
+
332
+ If native swarm is disabled or changes:
333
+
334
+ 1. Foundation maintains full functionality independently
335
+ 2. Feature flag allows reverting to full tool set
336
+ 3. Config version 1.0 still supported
337
+
338
+ ---
339
+
340
+ ## Success Criteria
341
+
342
+ 1. **Tool count reduced** from 41 to 23 (44% reduction)
343
+ 2. **Multi-provider routing works** with Kimi, GLM, DeepSeek, etc.
344
+ 3. **Native swarm integration** works for team/task management
345
+ 4. **Verification loop** remains functional
346
+ 5. **Ludicrous Ralphy** can use Foundation as sole backend
347
+
348
+ ---
349
+
350
+ ## Open Questions
351
+
352
+ 1. Should we keep `seldon_plan` as convenience even though native has planning?
353
+ 2. Should `gaia_remember/recall` be moved to Demerzel (context = codebase)?
354
+ 3. Do we need a "compatibility mode" for non-swarm Claude Code users?
355
+
356
+ ---
357
+
358
+ ## Appendix: Native Swarm API Reference
359
+
360
+ See: `/Users/sashabogojevic/development/claude-native-swarm-analysis/CONFIRMED-API.md`
361
+
362
+ ### Teammate Tool
363
+ - `spawnTeam` — Create team (become leader)
364
+ - `discoverTeams` — Find available teams
365
+ - `requestJoin` — Request to join team
366
+ - `approveJoin` — Approve join (leader)
367
+ - `rejectJoin` — Reject join (leader)
368
+ - `cleanup` — Remove team files
369
+
370
+ ### SendMessage Tool
371
+ - `message` — Direct message to teammate
372
+ - `broadcast` — Message all teammates
373
+ - `request` — Protocol request (shutdown, plan_approval)
374
+ - `response` — Respond to request
@@ -0,0 +1,266 @@
1
+ # Testing Foundation with Native Swarm (claudesp)
2
+
3
+ ## Overview
4
+
5
+ This guide explains how to test Foundation's multi-provider routing alongside Claude Code's native swarm features.
6
+
7
+ ---
8
+
9
+ ## Prerequisites
10
+
11
+ ### 1. claudesp (Native Swarm Enabled)
12
+
13
+ ```bash
14
+ # Already installed at:
15
+ /Users/sashabogojevic/.local/bin/claudesp
16
+
17
+ # Verify
18
+ claudesp --version
19
+ # Expected: 2.1.22 (Claude Code)
20
+ ```
21
+
22
+ ### 2. Foundation MCP Server
23
+
24
+ ```bash
25
+ cd /Users/sashabogojevic/development/foundation/foundation
26
+ npm install
27
+ npm run build
28
+ ```
29
+
30
+ ### 3. Provider API Keys
31
+
32
+ Ensure these are set in `~/.foundation/config.yaml` or environment:
33
+ - `ANTHROPIC_API_KEY`
34
+ - `OPENAI_API_KEY` (optional)
35
+ - `DEEPSEEK_API_KEY` (optional)
36
+ - `KIMI_API_KEY` (optional)
37
+ - `ZAI_API_KEY` (optional)
38
+
39
+ ---
40
+
41
+ ## Setup: Connect Foundation to claudesp
42
+
43
+ ### Option A: MCP Config File
44
+
45
+ Create/edit `~/.claude-sneakpeek/claudesp/config/settings.json`:
46
+
47
+ ```json
48
+ {
49
+ "mcpServers": {
50
+ "foundation": {
51
+ "command": "node",
52
+ "args": ["/Users/sashabogojevic/development/foundation/foundation/dist/index.js"],
53
+ "env": {
54
+ "ANTHROPIC_API_KEY": "${ANTHROPIC_API_KEY}"
55
+ }
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ ### Option B: CLI Flag
62
+
63
+ ```bash
64
+ claudesp --dangerously-skip-permissions --mcp-config /path/to/mcp-config.json
65
+ ```
66
+
67
+ Where `mcp-config.json`:
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "foundation": {
72
+ "command": "node",
73
+ "args": ["/Users/sashabogojevic/development/foundation/foundation/dist/index.js"]
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Test Scenarios
82
+
83
+ ### Test 1: Verify Foundation Tools Available
84
+
85
+ ```
86
+ List all MCP tools available. Show any that start with "demerzel", "seldon", or "gaia".
87
+ ```
88
+
89
+ **Expected:** 41 tools listed (before refactoring) or 23 tools (after)
90
+
91
+ ---
92
+
93
+ ### Test 2: Multi-Provider Routing (Foundation Core Value)
94
+
95
+ ```
96
+ Use seldon_invoke with role "coder" and prompt "Write a Python function to calculate fibonacci numbers"
97
+ ```
98
+
99
+ **Expected:**
100
+ - Routes to configured coder provider (Kimi, DeepSeek, etc.)
101
+ - Returns generated code
102
+ - NOT using Claude (uses external provider)
103
+
104
+ ---
105
+
106
+ ### Test 3: Provider Comparison
107
+
108
+ ```
109
+ Use seldon_compare to run "Write a hello world in Rust" through both the "coder" and "reviewer" roles
110
+ ```
111
+
112
+ **Expected:**
113
+ - Two different responses
114
+ - Different providers used for each role
115
+
116
+ ---
117
+
118
+ ### Test 4: Native Swarm Team Creation
119
+
120
+ ```
121
+ Use the Teammate tool to create a team called "foundation-test"
122
+ ```
123
+
124
+ **Expected:**
125
+ - Team created
126
+ - You become team leader
127
+
128
+ ---
129
+
130
+ ### Test 5: Hybrid Workflow (Native + Foundation)
131
+
132
+ This is the key test for the integrated architecture:
133
+
134
+ ```
135
+ 1. Create a team called "hybrid-test" using Teammate tool
136
+ 2. Use seldon_invoke with role "coder" to generate a Python script
137
+ 3. Use native SendMessage to broadcast the result to the team
138
+ 4. Create a task using TaskCreate for review
139
+ ```
140
+
141
+ **Expected:**
142
+ - Native swarm handles team/messaging
143
+ - Foundation handles multi-provider routing
144
+ - Both work together seamlessly
145
+
146
+ ---
147
+
148
+ ### Test 6: Verification Loop (Foundation Unique)
149
+
150
+ ```
151
+ 1. Use seldon_invoke role "coder" to write a function with this spec:
152
+ "Function that validates email addresses using regex"
153
+
154
+ 2. Use seldon_verify to check if it handles:
155
+ - Empty strings
156
+ - Missing @ symbol
157
+ - Invalid TLD
158
+
159
+ 3. Use seldon_fix if any issues found
160
+ ```
161
+
162
+ **Expected:**
163
+ - Code generated via external provider
164
+ - Verification identifies gaps
165
+ - Fix generates improvements
166
+
167
+ ---
168
+
169
+ ### Test 7: Demerzel Codebase Intelligence
170
+
171
+ ```
172
+ 1. Use demerzel_snapshot to create a snapshot of /Users/sashabogojevic/development/foundation/foundation
173
+ 2. Use demerzel_search to find "ProviderManager"
174
+ 3. Use demerzel_find_importers to see what uses ProviderManager
175
+ ```
176
+
177
+ **Expected:**
178
+ - Snapshot created
179
+ - Search finds provider manager
180
+ - Import graph shows dependencies
181
+
182
+ ---
183
+
184
+ ### Test 8: Gaia Learning (Post-Refactor)
185
+
186
+ ```
187
+ 1. Use gaia_learn to record: "Always use TypeScript strict mode"
188
+ 2. Use gaia_review to see accumulated learnings
189
+ 3. Use gaia_apply to write to CLAUDE.md
190
+ ```
191
+
192
+ **Expected:**
193
+ - Learning recorded
194
+ - Can review learnings
195
+ - Applied to CLAUDE.md
196
+
197
+ ---
198
+
199
+ ## Debugging
200
+
201
+ ### Check MCP Connection
202
+
203
+ ```bash
204
+ # In claudesp, run:
205
+ /mcp
206
+ ```
207
+
208
+ Should show Foundation server connected.
209
+
210
+ ### Check Foundation Logs
211
+
212
+ ```bash
213
+ # Run Foundation with debug logging:
214
+ DEBUG=foundation:* node /Users/sashabogojevic/development/foundation/foundation/dist/index.js
215
+ ```
216
+
217
+ ### Check Provider Health
218
+
219
+ ```
220
+ Use seldon_providers_list to see all providers and their health status
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Common Issues
226
+
227
+ ### "Tool not found: seldon_invoke"
228
+
229
+ Foundation MCP server not connected. Check:
230
+ 1. MCP config path is correct
231
+ 2. Foundation is built (`npm run build`)
232
+ 3. Node can execute the dist/index.js
233
+
234
+ ### "Provider error: 401"
235
+
236
+ API key not set. Check:
237
+ 1. Environment variables
238
+ 2. `~/.foundation/config.yaml`
239
+
240
+ ### "Native swarm tools not available"
241
+
242
+ Using regular `claude` instead of `claudesp`. The native swarm tools (Teammate, SendMessage) only appear in the patched version.
243
+
244
+ ---
245
+
246
+ ## Next Steps After Testing
247
+
248
+ 1. If all tests pass → Proceed with refactoring
249
+ 2. If Foundation tests fail → Debug MCP connection
250
+ 3. If hybrid tests fail → Check tool naming conflicts
251
+ 4. Document any issues in GitHub
252
+
253
+ ---
254
+
255
+ ## Test Results Log
256
+
257
+ | Test | Date | Result | Notes |
258
+ |------|------|--------|-------|
259
+ | 1. Foundation tools | | | |
260
+ | 2. Multi-provider | | | |
261
+ | 3. Provider compare | | | |
262
+ | 4. Native team | | | |
263
+ | 5. Hybrid workflow | | | |
264
+ | 6. Verification loop | | | |
265
+ | 7. Demerzel | | | |
266
+ | 8. Gaia learning | | | |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sashabogi/foundation",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Unified MCP server for AI-assisted development: codebase intelligence, multi-agent orchestration, and workflow patterns",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",