---
@agent {
  role: technical documentation architect,
  llm: claude-3-5-sonnet-20241022,
  max_tokens: 8192,
  temperature: 0.3
}

@shell "ls -la /Users/Akasha/Development/typedialog/docs/" as current_docs
@shell "find /Users/Akasha/Development/typedialog/crates -name 'README.md' -o -name '*.md' | head -20" as crate_docs
@import "/Users/Akasha/Development/typedialog/README.md" as main_readme
@import "/Users/Akasha/Development/typedialog/CHANGES.md" as changes_file
@import "/Users/Akasha/Development/typedialog/docs/README.md" as docs_readme

@validate output {
  must_contain: ["## Documentation Structure", "## Changes to CHANGES.md", "## README Updates"],
  format: markdown,
  min_length: 1500
}
---

# TypeDialog Documentation Reorganization Plan

## Current State

### Existing docs/ Structure
{{current_docs}}

### Crate Documentation
{{crate_docs}}

### Main README
{{main_readme}}

### Current CHANGES.md
{{changes_file}}

### Docs README
{{docs_readme}}

---

## Task: Documentation Reorganization

You need to create a comprehensive plan to:

### 1. Create Documentation Folders

Create the following folders in `docs/` (similar to existing `docs/agent/`):

- **docs/cli/** - CLI backend documentation (typedialog CLI)
- **docs/tui/** - TUI backend documentation (typedialog-tui)
- **docs/web/** - Web backend documentation (typedialog-web)
- **docs/ai/** - AI backend documentation (RAG, embeddings)
- **docs/encryption/** - Move encryption docs here:
  - ENCRYPTION-QUICK-START.md
  - ENCRYPTION-SERVICES-SETUP.md
  - ENCRYPTION-UNIFIED-ARCHITECTURE.md

Each folder should follow the pattern established by `docs/agent/`:
- README.md (overview + navigation)
- GETTING_STARTED.md
- REFERENCE.md (API/CLI reference)
- Additional specialized docs as needed

### 2. Update CHANGES.md

The CHANGES.md file is outdated. It needs to include these major changes that happened after the RepeatingGroup work:

**TypeDialog Agent (NEW):**
- Complete multi-provider LLM support (Claude, OpenAI, Gemini, Ollama)
- Agent execution system (.agent.mdx files)
- Template system with LiquidJS (variables, conditionals, imports)
- File imports with glob patterns
- Shell command integration
- Output validation rules
- Streaming support (SSE for Claude/OpenAI, JSON for Gemini/Ollama)
- Token usage tracking

**Naming Refactor:**
- Renamed typeagent-* to typedialog-ag-* for consistency
- typeagent-core → typedialog-ag-core
- typeagent-cli → typedialog-ag
- typeagent-server → typedialog-ag-server
- Updated all imports, docs, and scripts

**Organization:**
- Created demos/agent/ with 4 provider comparison demos
- Created tests/agent/ with validation tests
- Created examples/12-agent-execution/ with 8 practical examples
- Created docs/agent/ with complete user documentation

**Documentation:**
- docs/agent/README.md - Overview
- docs/agent/GETTING_STARTED.md - Installation and first agent
- docs/agent/LLM_PROVIDERS.md - Complete provider comparison

Format this as a proper CHANGES.md entry with:
- Version/date heading
- Categorized sections (Added, Changed, Fixed)
- Specific, actionable descriptions
- Links to relevant docs/examples

### 3. Update Main README.md

Add a section about TypeDialog Agent after the "Backends at a Glance" section:

**TypeDialog Agent (typedialog-ag)**
- What it is (AI agent execution from markdown files)
- Quick example
- Link to docs/agent/
- Link to examples/12-agent-execution/

### 4. Update docs/README.md

Add references to the new documentation folders:
- Link to cli/
- Link to tui/
- Link to web/
- Link to ai/
- Link to agent/
- Link to encryption/

Organize them logically (e.g., "Backend Documentation", "Feature Documentation")

---

## Instructions

Provide a **detailed, actionable plan** that includes:

1. **Folder Structure** - Exact directory tree showing what to create
2. **File Moves** - Which existing files to move where
3. **New Files to Create** - List each new README.md with a brief outline
4. **CHANGES.md Content** - Complete markdown entry to add
5. **README.md Updates** - Exact markdown sections to add/modify
6. **docs/README.md Updates** - Complete reorganized structure
7. **Migration Order** - Step-by-step execution order to avoid conflicts

For each new documentation folder (cli/, tui/, web/, ai/), specify:
- What topics should be covered
- What existing content can be referenced
- What new content needs to be written
- Cross-references to examples and code

**IMPORTANT:**
- DO NOT include time estimates
- Focus on WHAT needs to be done and WHY
- Identify dependencies (what must be done first)
- Flag any risks (e.g., breaking existing links)
- Provide clear success criteria

Generate the complete plan now.
