orgflow 0.2.0

A Rust library for managing documents with support for tasks and notes
Documentation
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
# Orgflow

A modern Rust ecosystem for managing notes and tasks with a smooth, efficient workflow.

Orgflow consists of two main components:
- **`orgflow`** - Core library for document management with support for tasks and notes
- **`orgflow-tui`** - Terminal user interface for intuitive note and task management

## 🚀 Quick Start

### Install the TUI Application

```bash
# Install from crates.io
cargo install orgflow-tui

# Run the application
orgflow-tui
```

### Use the Library

Add to your `Cargo.toml`:

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

## 📋 Features

### Orgflow Library (`orgflow`)

- **Document Management**: Read, write, and manipulate structured documents
- **Task Handling**: Create, manage, and track tasks with metadata
- **Note Support**: Rich note creation with titles, content, and tags
- **Flexible Storage**: Configurable file locations and formats
- **Rust API**: Type-safe, memory-efficient document operations

### Orgflow TUI (`orgflow-tui`)

- **Three-Tab Interface**: Editor, Viewer, and Tasks views
- **Session Management**: Automatic state persistence and recovery
- **Real-time Editing**: Create and edit notes with immediate saving
- **Task Management**: Visual task list with status tracking
- **Note Browser**: Navigate through saved notes with metadata display
- **Keyboard-driven**: Efficient navigation without mouse dependency
- **Cross-platform**: Works on Linux, macOS, and Windows

## 🎯 Use Cases

- **Personal Knowledge Management**: Organize notes, ideas, and research
- **Task Tracking**: Manage todos, projects, and deadlines
- **Documentation**: Create and maintain structured documentation
- **Note-taking**: Capture thoughts with rich formatting and metadata
- **Productivity**: Streamline workflow with keyboard-driven interface

## 📦 Components

### Core Library: `orgflow`

The foundational library that provides:

```rust
use orgflow::{OrgDocument, Task, Note, Configuration};

// Load a document
let doc = OrgDocument::from("path/to/file.org")?;

// Create a task
let task = Task::with_today("Complete project documentation");

// Create a note
let note = Note::with("Meeting Notes".to_string(), vec![
    "Discussed project timeline".to_string(),
    "Next steps identified".to_string(),
]);

// Add to document and save
doc.push_task(task);
doc.push_note(note);
doc.to("path/to/file.org")?;
```

### Terminal Interface: `orgflow`

A beautiful, responsive terminal interface featuring:

#### Editor Tab
- Create notes with titles and rich content
- Quick task entry with `Ctrl+T`
- Auto-save functionality with `Ctrl+S`
- Smart field navigation
- Draft content automatically preserved between sessions

#### Viewer Tab
- Browse all saved notes
- Split-panel layout (content + metadata)
- Arrow key navigation
- Rich metadata display

#### Tasks Tab
- Visual task list with status indicators
- Detailed task information panel
- Highlighted selection with underlines
- Priority and date tracking

### Navigation
- **Streamlined Tab Switching**: Single Ctrl+R key cycles through all tabs (Editor → Viewer → Tasks)
- **Session Recovery**: All navigation state preserved between sessions
- **Keyboard-driven**: Efficient workflow without mouse dependency

## 📖 Documentation

### Installation

#### From Crates.io

```bash
# Install the TUI application
cargo install orgflow-tui

# Use the library in your project
cargo add orgflow
```

#### From Source

```bash
git clone https://github.com/ucyo/orgflow
cd orgflow

# Build everything
cargo build --release

# Build just the library
cargo build -p orgflow --release

# Build just the TUI
cargo build -p orgflow-tui --release
```

### Configuration

Set your preferred storage location:

```bash
export ORGFLOW_BASEFOLDER=/path/to/your/notes
```

Default location: `/home/sweet/home`

### Session Management

Orgflow TUI automatically manages your session state:

- **Automatic Saving**: Session state is saved every 500ms after changes or every 50 keystrokes
- **Draft Recovery**: Unsaved notes, tasks, and scratchpad content are preserved between sessions
- **UI State Persistence**: Current tab, focus, and selection positions are restored on startup
- **Session File**: State is stored in `session.json` in your base folder
- **No Data Loss**: Even if the application crashes, your work is automatically recovered

**Session includes:**
- Current tab and focus position
- Unsaved draft content (title, note content, scratchpad)
- Navigation state (selected note/task indices)
- UI preferences (scratchpad visibility)

The session file is automatically created and managed - no manual intervention required.

### File Format

Orgflow uses a structured text format:

```org
## Tasks
[ ] Implement new feature
[x] 2024-01-15 Write documentation
(A) 2024-01-10 High priority task @work +project

## Notes

### Meeting Notes
> cre:2024-01-15 mod:2024-01-15 guid:abc123... @meeting +work
Discussed quarterly objectives and timeline.

Next steps:
- Review current progress
- Set new milestones
- Schedule follow-up meeting

### Project Ideas
> cre:2024-01-10 mod:2024-01-12 guid:def456... @ideas +innovation
Ideas for improving the user experience:
1. Better navigation
2. Faster search
3. Mobile support
```

## 🎮 Usage Examples

### TUI Application

```bash
# Start the application
orgflow

# Keyboard shortcuts:
# Ctrl+R - Cycle through tabs (Editor → Viewer → Tasks → Editor)
# Ctrl+T - Quick task entry    Ctrl+S - Save note
# Esc - Exit (session auto-saved)    Tab - Navigate fields
# Session state automatically preserved on every keystroke
```

### Library Usage

```rust
use orgflow::{Configuration, OrgDocument, Task, Note};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Get base folder from environment or use default
    let base_folder = Configuration::basefolder();
    let file_path = format!("{}/refile.org", base_folder);

    // Load existing document or create new
    let mut doc = OrgDocument::from(&file_path)
        .unwrap_or_else(|_| OrgDocument::default());

    // Add a new task
    let task = Task::with_today("Review pull requests");
    doc.push_task(task);

    // Add a new note
    let note = Note::with(
        "Daily Standup".to_string(),
        vec![
            "Team discussed current sprint progress".to_string(),
            "Identified blockers and solutions".to_string(),
            "Planned next steps for the week".to_string(),
        ]
    );
    doc.push_note(note);

    // Save the document
    doc.to(&file_path)?;

    println!("Document saved with {} tasks and {} notes",
             doc.len().0, doc.len().1);

    Ok(())
}
```

## 🛠️ Development

### Prerequisites

- Rust 1.70+ (edition 2024)
- Git

### Setup

```bash
# Clone the repository
git clone https://github.com/ucyo/orgflow
cd orgflow

# Build the workspace
cargo build

# Run tests
cargo test

# Run the TUI in development
cargo run -p orgflow-tui

# Run the CLI tool
cargo run -p orgflow
```

### Project Structure

```
orgflow/
├── orgflow/           # Core library
│   ├── src/
│   │   ├── lib/       # Library modules
│   │   └── main.rs    # CLI binary
│   └── tests/         # Integration tests
├── orgflow-tui/       # Terminal interface
│   └── src/
│       ├── main.rs    # TUI application
│       └── session.rs # Session management
├── Cargo.toml         # Workspace configuration
└── README.md          # This file
```

### Testing

```bash
# Run all tests
cargo test

# Test specific package
cargo test -p orgflow
cargo test -p orgflow-tui

# Run with output
cargo test -- --nocapture
```

### Linting and Formatting

```bash
# Format code
cargo fmt

# Run clippy lints
cargo clippy

# Check for issues
cargo check
```

## 🎨 Interface Preview

### Editor Tab
```
┌─────────────────────────────────────────────────────────────┐
│        Orgflow - Editor | Viewer | Tasks (Ctrl+R to switch) │
├─────────────────────────────────────────────────────────────┤
│ Title                                                       │
│ Weekly Planning Session                                     │
├─────────────────────────────────────────────────────────────┤
│ Content                                                     │
│ ## Agenda                                                   │
│ 1. Review last week's accomplishments                      │
│ 2. Set priorities for upcoming week                        │
│ 3. Identify potential blockers                             │
│                                                             │
│ ## Action Items                                             │
│ - Schedule team review meeting                              │
│ - Update project documentation                              │
│                                                             │
│ Quit <ESC> Switch <SHIFT>+<TAB> Save <CTRL>+<S> Cycle <CTRL>+<R> │
└─────────────────────────────────────────────────────────────┘
```

### Tasks Tab
```
┌─────────────────────────────────────────────────────────────┐
│        Orgflow - Editor | Viewer | Tasks (Ctrl+R to switch) │
├──────────────────────────────────────┬──────────────────────┤
│ Tasks (5 total)                      │ Task Details         │
│ ► [ ] Review pull request #123       │ Status: Pending      │
│   [x] Update documentation           │ Priority: High       │
│   [ ] Fix login bug                  │ Created: 2024-01-15  │
│   [ ] Plan next sprint               │ Completed: N/A       │
│   [x] Team standup meeting           │ Tags: @dev +urgent   │
│                                      │                      │
│                                      │ Description:         │
│                                      │ Review pull request  │
│                                      │ #123 for the new     │
│                                      │ authentication...    │
│ Navigate <↑↓> Quit <ESC> Switch <CTRL>+<R>                  │
└──────────────────────────────────────┴──────────────────────┘
```

**Session Management**: All UI state and draft content is automatically preserved in `session.json`. Exit anytime with `ESC` and resume exactly where you left off!

## 🤝 Contributing

We welcome contributions! Here's how to get started:

1. **Fork the repository**
2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
3. **Make your changes**: Follow the existing code style
4. **Add tests**: Ensure your changes are well-tested
5. **Run tests**: `cargo test`
6. **Submit a PR**: Create a pull request with a clear description

### Contribution Guidelines

- Follow Rust conventions and idioms
- Add tests for new functionality
- Update documentation as needed
- Keep commits focused and atomic
- Write clear commit messages

### Areas for Contribution

- **Features**: New functionality for the library or TUI
- **Performance**: Optimization opportunities
- **Documentation**: Improve examples and guides
- **Testing**: Increase test coverage
- **UI/UX**: Enhance the terminal interface
- **Bug fixes**: Address reported issues

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- [ratatui]https://github.com/ratatui-org/ratatui - Excellent TUI framework
- [org-mode]https://orgmode.org/ - Inspiration for the document format
- The Rust community for amazing tools and libraries

## 📞 Support

- **Issues**: [GitHub Issues]https://github.com/ucyo/orgflow/issues
- **Discussions**: [GitHub Discussions]https://github.com/ucyo/orgflow/discussions
- **Documentation**: [docs.rs/orgflow]https://docs.rs/orgflow

---

**Start organizing your workflow with Orgflow today!** 🚀

---

*Made with ❤️ in Rust*