mamf 0.1.2

Multi-AI council TUI - orchestrate conversations between AI advisors
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# Me And My Friends

[![Crates.io](https://img.shields.io/crates/v/mamf.svg?style=flat-square)](https://crates.io/crates/mamf)
[![Docs.rs](https://img.shields.io/docsrs/mamf?style=flat-square&logo=docs.rs)](https://docs.rs/mamf)
[![License](https://img.shields.io/crates/l/mamf?style=flat-square)](LICENSE)
[![CI](https://github.com/hffmnnj/me-and-my-friends/actions/workflows/ci.yml/badge.svg)](https://github.com/hffmnnj/me-and-my-friends/actions/workflows/ci.yml)
[![MSRV](https://img.shields.io/badge/MSRV-1.80-blue?style=flat-square&logo=rust)](https://www.rust-lang.org)

A Rust TUI that orchestrates conversations between AI "advisors" (CFO, CTO, CMO, etc.) backed by Ollama, Gemini, OpenAI, or Claude CLI. Get diverse perspectives through council discussions, one-on-one chats, and deep research mode, with RAG-powered knowledge using Qdrant. 
 
![Dashboard](docs/images/dashboard.png)

## Features

- **Multi-Advisor Council** — Multiple AI personas discuss your question from different angles, then a chairman synthesizes the best answer
- **Provider Flexibility** — Mix and match models: Ollama for local privacy, Gemini for speed, Groq for cost, Claude for research
- **Knowledge Base (RAG)** — Index your documents so advisors have context about your domain
- **Living Council** — Advisors debate and iterate until they reach consensus
- **Beautiful TUI** — Full terminal interface with streaming responses, history, and settings

## Quick Demo: Cat Advisory Council

Try MAMF with a fun demo featuring a council of cat experts:

```bash
cd demos/cat-council
mamf knowledge index ./docs
mamf discuss "Should I get a cat if I have a 2-year-old toddler?"
```

The council includes:
- 🐱 **Whiskers McPurrface** — Obsessive cat lover
- 🐕 **Rex Barkington** — Reluctant dog person convert
- 🩺 **Dr. Mittens DVM** — Evidence-based veterinarian
- 🤧 **Sneezey Johnson** — Allergic but found workarounds
- 🎓 **Professor Meowington PhD** — Chairman who synthesizes all views

See [`demos/cat-council/README.md`](demos/cat-council/README.md) for full setup.

## Installation

```bash
# From crates.io (recommended)
cargo install mamf

# Or from source
git clone https://github.com/hffmnnj/me-and-my-friends
cd me-and-my-friends
cargo install --path .
```

### Prerequisites

```bash
# Ollama (recommended for local inference)
# Install from https://ollama.ai
ollama pull phi4:14b           # Or any model
ollama pull nomic-embed-text   # For RAG embeddings

# Qdrant (for knowledge base)
docker run -d -p 6333:6333 -p 6334:6334 qdrant/qdrant

# Optional: Claude CLI for deep research
npm install -g @anthropic-ai/claude-code
```

## Quick Start

```bash
# Initialize config file
mamf init

# Launch the TUI
mamf tui

# Or use CLI directly
mamf discuss "What should our pricing strategy be?"
mamf ask cfo "What's our runway?"
```

## How It Works

### 1. Define Your Advisors

Each advisor has a persona, expertise area, and backing LLM:

```yaml
advisors:
  cfo:
    name: "Chief Financial Officer"
    emoji: "💰"
    model: "llama-3.3-70b-versatile"
    provider: groq
    temperature: 0.3
    system_prompt: "You are a seasoned CFO focused on financial sustainability..."
```

### 2. Ask Your Question

```bash
mamf discuss "Should we raise a seed round or bootstrap?"
```

### 3. Get Diverse Perspectives

Each advisor responds from their expertise:
- **CFO** → Runway analysis, burn rate, dilution concerns
- **CTO** → Technical debt impact, team scaling needs
- **Investor** → Market timing, valuation expectations
- **Wildcard** → Unconventional alternatives

### 4. Chairman Synthesizes

The chairman weighs all perspectives and provides a balanced recommendation.

## Supported Providers

| Provider | Type | Setup |
|----------|------|-------|
| **Ollama** | Local/Self-hosted | `ollama serve` at localhost:11434 |
| **Google Gemini** | Cloud | `GOOGLE_API_KEY` or config |
| **OpenAI** | Cloud | `OPENAI_API_KEY` or config |
| **OpenRouter** | Cloud (Multi-model) | `OPENROUTER_API_KEY` or config |
| **Groq** | Cloud (Fast) | `GROQ_API_KEY` or config |
| **Claude CLI** | Local CLI | `npm install -g @anthropic-ai/claude-code` |

### Embedding Providers (for RAG)

| Provider | Model | Setup |
|----------|-------|-------|
| **Ollama** | nomic-embed-text | Default, local |
| **Voyage AI** | voyage-2 | `VOYAGE_API_KEY` |
| **Google** | text-embedding-004 | `GOOGLE_API_KEY` |

## TUI Interface

Launch with `mamf tui`. Navigate between screens using function keys:

### Dashboard (F1)
![Dashboard](docs/images/dashboard.png)

### Council Discussion (F2)
Start a discussion and watch advisors respond in real-time:

![Discussion Prompt](docs/images/discussion_prompt.png)

View completed responses with RAG source references:

![Discussion Finished](docs/images/discussion_finished.png)

Expand individual advisor responses for detailed reading:

![Discussion Response View](docs/images/discussion_response_view.png)

See which knowledge base documents informed the response:

![Discussion Qdrant Sources](docs/images/discussion_qdrant_sources.png)

### One-on-One Chat (F3)
Have a private conversation with a single advisor:

![One on One](docs/images/one_on_one.png)

### Session History (F4)
Review and continue past discussions:

![Session History](docs/images/session_history.png)

### Settings (F5)
Configure providers, advisors, and RAG settings:

![Settings Providers](docs/images/settings_providers.png)
![Settings Advisors](docs/images/settings_advisors.png)
![Settings Qdrant](docs/images/settings_qdrant.png)

### Knowledge Base (F6)
Index documents and query your knowledge base:

![Knowledge Base Index](docs/images/knowledgebase_index.png)
![Knowledge Base Query](docs/images/knowledgebase_query.png)

### Navigation Keys

| Key | Screen | Description |
|-----|--------|-------------|
| `F1` | Dashboard | Overview and quick actions |
| `F2` | Discussion | Council discussions |
| `F3` | Advisor | One-on-one chat with single advisor |
| `F4` | History | Past sessions |
| `F5` | Settings | Configuration |
| `F6` | Knowledge | RAG knowledge base |
| `q` || Quit (from dashboard) |
| `Ctrl+C` || Force quit |

### Discussion Screen Controls

| Key | Action |
|-----|--------|
| `Ctrl+1` | Council mode (all advisors) |
| `Ctrl+2` | Focus mode (filtered advisors) |
| `Ctrl+3` | Synthesis mode (quick summary) |
| `Ctrl+4` | Deep mode (multiple rounds) |
| `+`/`-` | Adjust rounds (in Deep mode) |
| `Tab` | Switch focus |
| `Enter` | Send message |
| `Esc` | Cancel/Back |

### Navigation

| Key | Action |
|-----|--------|
| `j`/`` | Move down |
| `k`/`` | Move up |
| `PgUp`/`PgDn` | Scroll pages |

## Discussion Modes

### Council Mode (Default)
All advisors respond sequentially, chairman synthesizes at the end.

```bash
mamf discuss "Should we raise funding?"
```

### Focus Mode
Filter to advisors relevant to a topic:

```bash
mamf discuss --focus=funding "Seed round strategy"
mamf discuss --focus=technical "Architecture decisions"
```

### Living Council
Advisors discuss with each other until consensus:

```bash
mamf living "Market expansion strategy"
mamf living --convergence=0.8 "Pricing model"  # Higher = more agreement needed
```

### Deep Mode
Multiple rounds for complex topics:

```bash
mamf discuss --rounds=3 "Product roadmap"
```

### One-on-One
Chat with a single advisor:

```bash
mamf ask cfo "Revenue projections"
mamf ask wildcard "Disrupt our own business model"
```

### Research Mode
Deep research using Claude CLI with MCP tools:

```bash
mamf research "Competitive analysis of smart ring market"
```

## Knowledge Base (RAG)

Index your documents so advisors have context about your domain:

```bash
# Index a directory of markdown files
mamf knowledge index ./docs

# Query the knowledge base
mamf knowledge query "pricing strategy"

# View statistics
mamf knowledge stats
```

RAG context is automatically injected into advisor prompts when `auto_inject: true` (default).

### Knowledge Base Structure

Organize your docs with YAML frontmatter:

```markdown
---
title: Pricing Strategy
category: business
tags: [pricing, revenue, monetization]
---

# Our Pricing Strategy

Content here...
```

## Configuration

Config file location: `~/.config/mamf/config.yaml` or `./mamf.yaml` (local takes priority)

```yaml
providers:
  ollama:
    base_url: "http://localhost:11434"

  google:
    api_key: "AIza..."  # Or use GOOGLE_API_KEY env var

  openai:
    api_key: "sk-..."   # Or use OPENAI_API_KEY env var

  groq:
    api_key: "gsk_..."  # Or use GROQ_API_KEY env var

  claude_cli:
    timeout_secs: 600
    model: "claude-sonnet-4-5-20250929"

# Assign models to advisors
advisors:
  cfo:
    model: "llama-3.3-70b-versatile"
    provider: groq
    temperature: 0.3
    order: 1

  cto:
    model: "phi4:14b"
    provider: ollama
    temperature: 0.4
    order: 2

  chairman:
    model: "gemini-2.5-flash"
    provider: google
    temperature: 0.5
    order: 100  # Always last (synthesis)

# RAG configuration
rag:
  qdrant_url: "http://localhost:6334"  # gRPC port
  collection: "mamf_docs"
  embedding_provider: ollama
  embedding_model: "nomic-embed-text"
  auto_inject: true
  min_relevance: 0.5
  top_k: 5

defaults:
  timeout_secs: 120
  max_tokens: 4096
  stream: true
```

## Built-in Advisors

| ID | Role | Expertise | Default Temp |
|----|------|-----------|--------------|
| `cfo` | Chief Financial Officer | Finance, funding, runway, pricing | 0.3 |
| `cto` | Chief Technology Officer | Technical, architecture, security | 0.4 |
| `cmo` | Chief Marketing Officer | Marketing, branding, growth | 0.7 |
| `coo` | Chief Operations Officer | Operations, execution, process | 0.4 |
| `cpo` | Chief Product Officer | Product strategy, roadmap, UX | 0.5 |
| `chro` | Chief HR Officer | People, culture, hiring | 0.6 |
| `legal` | General Counsel | Legal, compliance, contracts | 0.2 |
| `investor` | Board Advisor | Investment, valuation, exits | 0.6 |
| `strategy` | Strategy Consultant | Long-term planning, market analysis | 0.5 |
| `innovation` | R&D Lead | Unconventional ideas, disruption | 0.8 |
| `customer` | Customer Advocate | User needs, feedback, satisfaction | 0.5 |
| `wildcard` | Devil's Advocate | Contrarian views, challenge assumptions | 0.95 |
| `chairman` | Board Chairman | Synthesis, balanced summary | 0.5 |

## Session Management

```bash
# List recent sessions
mamf session list

# Continue a session
mamf session continue <session_id>

# Export to markdown
mamf session export <session_id> --format=markdown
```

## Creating Custom Councils

MAMF is flexible—create councils for any domain:

| Use Case | Example Advisors |
|----------|-----------------|
| **Startup** | CFO, CTO, Investor, Legal |
| **Game Dev** | Designer, Programmer, Artist, QA |
| **Writing** | Editor, Critic, Fan, Publisher |
| **Health** | Doctor, Nutritionist, Trainer, Patient |
| **Cat Care** | Vet, Breeder, Shelter Worker, Cat Lover |

See [`demos/cat-council/`](demos/cat-council/) for a complete example.

## Architecture

```
src/
├── config/       # YAML configuration loading
├── providers/    # LLM provider abstraction
│   ├── ollama.rs
│   ├── google.rs
│   ├── openai.rs
│   ├── openrouter.rs
│   ├── groq.rs
│   └── claude_cli.rs
├── advisors/     # Advisor personas and registry
├── session/      # Conversation orchestration
├── rag/          # Knowledge base (Qdrant + embeddings)
├── storage/      # SQLite persistence
├── cli/          # Command-line interface
└── tui/          # Ratatui terminal UI
    └── screens/  # Dashboard, Discussion, Advisor, etc.
```

## Development

```bash
# Build (uses build.sh for correct linker config)
./build.sh build
./build.sh release

# Run tests
./build.sh test

# Debug logging
RUST_LOG=debug ./build.sh run discuss "test"

# Format and lint
cargo fmt && cargo clippy
```

## License

MIT

## Credits

Built with [Ratatui](https://ratatui.rs/), [Tokio](https://tokio.rs/), and [Clap](https://clap.rs/).