mindkit 0.1.0

A generic sequential thinking toolkit for AI reasoning systems
Documentation
# MindKit 🧠

[![Crates.io](https://img.shields.io/crates/v/mindkit.svg)](https://crates.io/crates/mindkit)
[![Documentation](https://docs.rs/mindkit/badge.svg)](https://docs.rs/mindkit)
[![License](https://img.shields.io/crates/l/mindkit.svg)](https://github.com/DevOpsDali/mindkit/blob/main/LICENSE)
[![CI](https://github.com/DevOpsDali/mindkit/workflows/CI/badge.svg)](https://github.com/DevOpsDali/mindkit/actions/workflows/ci.yml)
[![Rust Version](https://img.shields.io/badge/rust-1.85%2B-blue.svg)](https://www.rust-lang.org)

A Rust library for structured sequential thinking and reasoning patterns for LLMs. MindKit provides a framework-agnostic implementation for organizing thoughts, tracking reasoning processes, and applying different analytical lenses to problems.

## Overview

MindKit allows you to integrate structured, reflective reasoning into any MCP (Model Context Protocol) server or other AI application. It's designed to make thinking processes transparent, traceable, and systematic.

## Features

- **Multiple Thinking Modes**: Analytical, Critical, Synthesis, and Validation
- **Revision Tracking**: Track when thoughts are revised and what they revise
- **Branching Thoughts**: Create alternate reasoning paths
- **Custom Lenses**: Apply domain-specific analysis (e.g., "Rust best practices", "security")
- **Confidence Levels**: Track reasoning confidence (0.0-1.0)
- **Visual Feedback**: Intuitive emoji indicators for different thought types
- **Dynamic Adjustment**: Automatically adjusts total thoughts as reasoning expands
- **Framework Agnostic**: Use with any MCP server implementation

## Installation

Add MindKit to your `Cargo.toml`:

```toml
[dependencies]
mindkit = "0.1.0"
```

## Quick Start

```rust
use mindkit::{ThinkInput, process_thinking};

// Create a basic analytical thought
let input = ThinkInput {
    thought: "Breaking down this problem into smaller components...".to_string(),
    next_thought_needed: true,
    thought_number: 1,
    total_thoughts: 5,
    thought_type: Some("analytical".to_string()),
    is_revision: None,
    revises_thought: None,
    branch_from_thought: None,
    branch_id: None,
    needs_more_thoughts: None,
    custom_lens: None,
    confidence: None,
};

let result = process_thinking(input);
println!("{}", result.formatted_output);
// Output: πŸ’­ 1/5 [analytical] | Breaking down this problem into smaller components...
```

## Thought Types

### Analytical (default)
Standard reasoning mode for breaking down problems and exploring ideas.
```rust
thought_type: Some("analytical".to_string())  // Icon: πŸ’­
```

### Critical
Actively looks for flaws, assumptions, and potential issues. Automatically adds warnings for detected assumptions, absolute statements, and implicit biases.
```rust
thought_type: Some("critical".to_string())  // Icon: πŸ”
// Example output: "This will always work [⚠️ ABSOLUTE STATEMENT: Consider edge cases]"
```

### Synthesis
Combines multiple perspectives and ideas into cohesive insights.
```rust
thought_type: Some("synthesis".to_string())  // Icon: πŸ”—
```

### Validation
Verifies conclusions and checks reasoning validity.
```rust
thought_type: Some("validation".to_string())  // Icon: βœ“
```

## Advanced Features

### Revising Previous Thoughts
```rust
let revision = ThinkInput {
    thought: "Actually, I need to reconsider my approach...".to_string(),
    next_thought_needed: true,
    thought_number: 3,
    total_thoughts: 5,
    is_revision: Some(true),
    revises_thought: Some(2),  // Revising thought #2
    // ... other fields as None
};
// Output: πŸ”„ 3/5 | Actually, I need to reconsider my approach... β†Ί#2
```

### Branching Thoughts
```rust
let branch = ThinkInput {
    thought: "Alternative approach: what if we tried...".to_string(),
    next_thought_needed: true,
    thought_number: 4,
    total_thoughts: 6,
    branch_from_thought: Some(3),
    branch_id: Some("alt-1".to_string()),
    // ... other fields as None
};
// Output: 🌿 4/6 | Alternative approach: what if we tried... β””#3[alt-1]
```

### Custom Analytical Lenses
Apply domain-specific analysis to your thoughts:

```rust
let security_lens = ThinkInput {
    thought: "Examining the input validation logic...".to_string(),
    next_thought_needed: true,
    thought_number: 2,
    total_thoughts: 4,
    custom_lens: Some("security".to_string()),
    // ... other fields as None
};
// Output: 🎯 2/4 πŸ”Žsecurity | Examining the input validation logic... [πŸ”Ž SECURITY: Validate and sanitize all inputs]
```

Supported lenses include:
- **Rust**: Adds reminders about ownership, borrowing, and error handling
- **Security**: Highlights input validation and authentication concerns
- **Performance**: Points out algorithmic complexity and memory usage
- **Custom**: Any other lens applies a generic perspective marker

### Confidence Tracking
```rust
let confident_thought = ThinkInput {
    thought: "Based on the evidence, the solution is clear.".to_string(),
    next_thought_needed: false,
    thought_number: 5,
    total_thoughts: 5,
    confidence: Some(0.95),
    // ... other fields as None
};
// Output: πŸ’­ 5/5 95% | Based on the evidence, the solution is clear.
```

## Integration Examples

### With FTL SDK

```rust
use ftl_sdk::{tool, ToolResponse};
use mindkit::{ThinkInput, process_thinking};

#[tool]
fn sequential_thinking(input: ThinkInput) -> ToolResponse {
    let result = process_thinking(input);
    if result.is_error {
        ToolResponse::error(result.formatted_output)
    } else {
        ToolResponse::text(result.formatted_output)
    }
}
```

## Visual Indicators

The formatted output includes visual indicators for quick understanding:

- πŸ’­ Analytical thinking
- πŸ” Critical analysis
- πŸ”— Synthesis of ideas
- βœ“ Validation check
- πŸ”„ Revision of previous thought
- 🌿 Branching to alternate path
- 🎯 Custom lens applied
- (+) Expanding beyond initial estimate
- β†Ί#N Revising thought number N
- β””#N Branching from thought number N

## API Reference

### Core Types

#### `ThinkInput`
The main input structure for the thinking process. All fields except the first four are optional.

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `thought` | `String` | Yes | The current thinking step |
| `next_thought_needed` | `bool` | Yes | Whether more thinking is required |
| `thought_number` | `u32` | Yes | Current thought number (must be > 0) |
| `total_thoughts` | `u32` | Yes | Estimated total thoughts (must be > 0) |
| `thought_type` | `Option<String>` | No | Type: analytical, critical, synthesis, or validation |
| `is_revision` | `Option<bool>` | No | Whether this revises a previous thought |
| `revises_thought` | `Option<u32>` | No | Which thought number is being revised |
| `branch_from_thought` | `Option<u32>` | No | Branching point for alternate paths |
| `branch_id` | `Option<String>` | No | Identifier for the branch |
| `needs_more_thoughts` | `Option<bool>` | No | Indicates expansion beyond initial estimate |
| `custom_lens` | `Option<String>` | No | Domain-specific analytical lens |
| `confidence` | `Option<f32>` | No | Confidence level (0.0-1.0) |

#### `ThinkResult`
The result of processing a thinking input.

| Field | Type | Description |
|-------|------|-------------|
| `formatted_output` | `String` | The formatted thought with metadata |
| `is_error` | `bool` | Whether an error occurred |

### Functions

#### `process_thinking(input: ThinkInput) -> ThinkResult`
Main function that processes a thinking input and returns formatted output.

## Use Cases

- **AI Assistants**: Structure reasoning for transparent decision-making
- **Problem Solving**: Break down complex problems systematically
- **Code Review**: Apply different analytical lenses to code analysis
- **Decision Systems**: Track confidence and reasoning paths
- **Learning Tools**: Make thinking processes visible and traceable
- **Debugging**: Systematic approach to finding and fixing issues

## Inspiration

This project was inspired by [@modelcontextprotocol/server-sequential-thinking](https://www.npmjs.com/package/@modelcontextprotocol/server-sequential-thinking), extending these concepts into a framework-agnostic Rust library.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

Licensed under the Apache License, Version 2.0.