# `idea.rs` – Idea Model & Management

## Purpose
The **Idea** module defines a lightweight structure for capturing brainstorming concepts, proposals, or feature suggestions. Ideas are persisted under `~/.todozi/ideas/` as JSON files and can be later turned into tasks, projects, or research items.

## Main Types
| Type | Description |
|------|-------------|
| `Idea` | Struct with fields `id`, `text`, `share_level`, `importance`, `created_at`, `updated_at`. |
| `IdeaCollection` | In‑memory map of `Idea`s with helpers `add`, `remove`, `list`, `save`, `load`. |

## Public API
| Function / Method | Description |
|-------------------|-------------|
| `Idea::new(text: String, share_level: ShareLevel, importance: u8) -> Self` | Create a new `Idea` instance. |
| `IdeaCollection::add(idea: Idea)` | Insert an `Idea` into the collection. |
| `IdeaCollection::remove(id: &str) -> Option<Idea>` | Delete an idea by its UUID. |
| `IdeaCollection::list() -> Vec<Idea>` | Return all stored ideas. |
| `IdeaCollection::save()` / `load()` | Serialise the collection to JSON/HLX and read it back. |

## Usage Example
```rust
use todozi::idea::{Idea, IdeaCollection, ShareLevel};

fn main() -> todozi::error::Result<()> {
    // Create a new idea
    let idea = Idea::new(
        "Add dark mode to the UI".to_string(),
        ShareLevel::Public,
        7, // importance out of 10
    );

    // Load existing collection (or start a new one)
    let mut collection = IdeaCollection::load().unwrap_or_default();

    // Add and persist the idea
    collection.add(idea);
    collection.save()?;

    // List all ideas
    for i in collection.list() {
        println!("Idea {}: {}", i.id, i.text);
    }

    Ok(())
}
```

## Integration Points
* **`cli.rs`** – Provides `todozi idea create`, `list`, and `show` sub‑commands that call into this module.
* **`server.rs`** – Exposes REST endpoints (`/ideas`, `/ideas/{id}`) for remote management.
* **`emb.rs`** – When the embedding service is enabled, each idea’s text is embedded for semantic search.
* **`todozi.rs`** – The structured‑text parser can extract `<idea>` blocks from chat messages and feed them here.

## When to Use
- Capture raw brainstorming output without committing to a full task.
- Store feature proposals that can later be refined into actionable items.
- Share concepts across a team (`share_level = Public`) or keep them personal (`share_level = Private`).

---

*Generated by GPT‑OSS – documentation for the `idea.rs` module.*
