# Testing Foundation with Native Swarm (claudesp)

## Overview

This guide explains how to test Foundation's multi-provider routing alongside Claude Code's native swarm features.

---

## Prerequisites

### 1. claudesp (Native Swarm Enabled)

```bash
# Already installed at:
/Users/sashabogojevic/.local/bin/claudesp

# Verify
claudesp --version
# Expected: 2.1.22 (Claude Code)
```

### 2. Foundation MCP Server

```bash
cd /Users/sashabogojevic/development/foundation/foundation
npm install
npm run build
```

### 3. Provider API Keys

Ensure these are set in `~/.foundation/config.yaml` or environment:
- `ANTHROPIC_API_KEY`
- `OPENAI_API_KEY` (optional)
- `DEEPSEEK_API_KEY` (optional)
- `KIMI_API_KEY` (optional)
- `ZAI_API_KEY` (optional)

---

## Setup: Connect Foundation to claudesp

### Option A: MCP Config File

Create/edit `~/.claude-sneakpeek/claudesp/config/settings.json`:

```json
{
  "mcpServers": {
    "foundation": {
      "command": "node",
      "args": ["/Users/sashabogojevic/development/foundation/foundation/dist/index.js"],
      "env": {
        "ANTHROPIC_API_KEY": "${ANTHROPIC_API_KEY}"
      }
    }
  }
}
```

### Option B: CLI Flag

```bash
claudesp --dangerously-skip-permissions --mcp-config /path/to/mcp-config.json
```

Where `mcp-config.json`:
```json
{
  "mcpServers": {
    "foundation": {
      "command": "node",
      "args": ["/Users/sashabogojevic/development/foundation/foundation/dist/index.js"]
    }
  }
}
```

---

## Test Scenarios

### Test 1: Verify Foundation Tools Available

```
List all MCP tools available. Show any that start with "demerzel", "seldon", or "gaia".
```

**Expected:** 41 tools listed (before refactoring) or 23 tools (after)

---

### Test 2: Multi-Provider Routing (Foundation Core Value)

```
Use seldon_invoke with role "coder" and prompt "Write a Python function to calculate fibonacci numbers"
```

**Expected:**
- Routes to configured coder provider (Kimi, DeepSeek, etc.)
- Returns generated code
- NOT using Claude (uses external provider)

---

### Test 3: Provider Comparison

```
Use seldon_compare to run "Write a hello world in Rust" through both the "coder" and "reviewer" roles
```

**Expected:**
- Two different responses
- Different providers used for each role

---

### Test 4: Native Swarm Team Creation

```
Use the Teammate tool to create a team called "foundation-test"
```

**Expected:**
- Team created
- You become team leader

---

### Test 5: Hybrid Workflow (Native + Foundation)

This is the key test for the integrated architecture:

```
1. Create a team called "hybrid-test" using Teammate tool
2. Use seldon_invoke with role "coder" to generate a Python script
3. Use native SendMessage to broadcast the result to the team
4. Create a task using TaskCreate for review
```

**Expected:**
- Native swarm handles team/messaging
- Foundation handles multi-provider routing
- Both work together seamlessly

---

### Test 6: Verification Loop (Foundation Unique)

```
1. Use seldon_invoke role "coder" to write a function with this spec:
   "Function that validates email addresses using regex"

2. Use seldon_verify to check if it handles:
   - Empty strings
   - Missing @ symbol
   - Invalid TLD

3. Use seldon_fix if any issues found
```

**Expected:**
- Code generated via external provider
- Verification identifies gaps
- Fix generates improvements

---

### Test 7: Demerzel Codebase Intelligence

```
1. Use demerzel_snapshot to create a snapshot of /Users/sashabogojevic/development/foundation/foundation
2. Use demerzel_search to find "ProviderManager"
3. Use demerzel_find_importers to see what uses ProviderManager
```

**Expected:**
- Snapshot created
- Search finds provider manager
- Import graph shows dependencies

---

### Test 8: Gaia Learning (Post-Refactor)

```
1. Use gaia_learn to record: "Always use TypeScript strict mode"
2. Use gaia_review to see accumulated learnings
3. Use gaia_apply to write to CLAUDE.md
```

**Expected:**
- Learning recorded
- Can review learnings
- Applied to CLAUDE.md

---

## Debugging

### Check MCP Connection

```bash
# In claudesp, run:
/mcp
```

Should show Foundation server connected.

### Check Foundation Logs

```bash
# Run Foundation with debug logging:
DEBUG=foundation:* node /Users/sashabogojevic/development/foundation/foundation/dist/index.js
```

### Check Provider Health

```
Use seldon_providers_list to see all providers and their health status
```

---

## Common Issues

### "Tool not found: seldon_invoke"

Foundation MCP server not connected. Check:
1. MCP config path is correct
2. Foundation is built (`npm run build`)
3. Node can execute the dist/index.js

### "Provider error: 401"

API key not set. Check:
1. Environment variables
2. `~/.foundation/config.yaml`

### "Native swarm tools not available"

Using regular `claude` instead of `claudesp`. The native swarm tools (Teammate, SendMessage) only appear in the patched version.

---

## Next Steps After Testing

1. If all tests pass → Proceed with refactoring
2. If Foundation tests fail → Debug MCP connection
3. If hybrid tests fail → Check tool naming conflicts
4. Document any issues in GitHub

---

## Test Results Log

| Test | Date | Result | Notes |
|------|------|--------|-------|
| 1. Foundation tools | | | |
| 2. Multi-provider | | | |
| 3. Provider compare | | | |
| 4. Native team | | | |
| 5. Hybrid workflow | | | |
| 6. Verification loop | | | |
| 7. Demerzel | | | |
| 8. Gaia learning | | | |
