aboutsummaryrefslogtreecommitdiff
path: root/IMPROVEMENT_PLAN.md
diff options
context:
space:
mode:
Diffstat (limited to 'IMPROVEMENT_PLAN.md')
-rw-r--r--IMPROVEMENT_PLAN.md166
1 files changed, 0 insertions, 166 deletions
diff --git a/IMPROVEMENT_PLAN.md b/IMPROVEMENT_PLAN.md
deleted file mode 100644
index a553884..0000000
--- a/IMPROVEMENT_PLAN.md
+++ /dev/null
@@ -1,166 +0,0 @@
1# Demon CLI Improvement Plan
2
3## Overview
4This document outlines the planned improvements to the demon CLI tool based on feedback and best practices.
5
6## Improvement Tasks
7
8### 1. Switch to `anyhow` for Error Handling
9**Priority**: High
10**Status**: Pending
11
12**Goal**: Replace `Box<dyn std::error::Error>` with `anyhow::Result` throughout the codebase for better error handling.
13
14**Tasks**:
15- Replace all `Result<(), Box<dyn std::error::Error>>` with `anyhow::Result<()>`
16- Use `anyhow::Context` for better error context
17- Simplify error handling code
18- Update imports and error propagation
19
20**Benefits**:
21- Better error messages with context
22- Simpler error handling
23- More idiomatic Rust error handling
24
25### 2. Implement CLI Testing with `assert_cmd`
26**Priority**: High
27**Status**: Pending
28
29**Goal**: Create comprehensive integration tests for all CLI commands using the `assert_cmd` crate.
30
31**Prerequisites**:
32- Research and document `assert_cmd` usage in CLAUDE.md
33- Add `assert_cmd` dependency
34- Create test infrastructure
35
36**Test Coverage Required**:
37- `demon run`: Process spawning, file creation, duplicate detection
38- `demon stop`: Process termination, timeout handling, cleanup
39- `demon tail`: File watching behavior (basic scenarios)
40- `demon cat`: File content display, flag handling
41- `demon list`: Process listing, status detection
42- `demon status`: Individual process status checks
43- `demon clean`: Orphaned file cleanup
44- Error scenarios: missing files, invalid PIDs, etc.
45
46**Test Structure**:
47```
48tests/
49├── cli.rs # Main CLI integration tests
50├── fixtures/ # Test data and helper files
51└── common/ # Shared test utilities
52```
53
54### 3. Add Quiet Flag to List Command
55**Priority**: Medium
56**Status**: Pending
57
58**Goal**: Add `-q/--quiet` flag to the `demon list` command for machine-readable output.
59
60**Requirements**:
61- Add `quiet` field to `ListArgs` struct (if needed, since `List` currently has no args)
62- Convert `List` command to use `ListArgs` struct
63- When quiet flag is used:
64 - No headers
65 - One line per process: `id:pid:status`
66 - No "No daemon processes found" message when empty
67
68**Example Output**:
69```bash
70# Normal mode
71$ demon list
72ID PID STATUS COMMAND
73--------------------------------------------------
74my-app 12345 RUNNING N/A
75
76# Quiet mode
77$ demon list -q
78my-app:12345:RUNNING
79```
80
81### 4. Add LLM Command
82**Priority**: Medium
83**Status**: Pending
84
85**Goal**: Add a `demon llm` command that outputs a comprehensive usage guide for other LLMs.
86
87**Requirements**:
88- Add `Llm` variant to `Commands` enum
89- No arguments needed
90- Output to stdout (not stderr like other messages)
91- Include all commands with examples
92- Assume the reader is an LLM that needs to understand how to use the tool
93
94**Content Structure**:
95- Tool overview and purpose
96- All available commands with syntax
97- Practical examples for each command
98- Common workflows
99- File structure explanation
100- Error handling tips
101
102### 5. Remove `glob` Dependency
103**Priority**: Low
104**Status**: Pending
105
106**Goal**: Replace the `glob` crate with standard library `std::fs` functionality.
107
108**Implementation**:
109- Remove `glob` from Cargo.toml
110- Replace `glob("*.pid")` with `std::fs::read_dir()` + filtering
111- Update imports
112- Ensure same functionality is maintained
113
114**Functions to Update**:
115- `list_daemons()`: Find all .pid files
116- `clean_orphaned_files()`: Find all .pid files
117
118**Implementation Pattern**:
119```rust
120// Replace glob("*.pid") with:
121std::fs::read_dir(".")?
122 .filter_map(|entry| entry.ok())
123 .filter(|entry| {
124 entry.path().extension()
125 .and_then(|ext| ext.to_str())
126 .map(|ext| ext == "pid")
127 .unwrap_or(false)
128 })
129```
130
131## Implementation Order
132
1331. **Document assert_cmd** - Add understanding to CLAUDE.md
1342. **Switch to anyhow** - Foundation for better error handling
1353. **Implement tests** - Ensure current functionality works correctly
1364. **Add quiet flag** - Small feature addition
1375. **Add LLM command** - Documentation feature
1386. **Remove glob** - Cleanup and reduce dependencies
139
140## Success Criteria
141
142- [ ] All existing functionality remains intact
143- [ ] Comprehensive test coverage (>80% of CLI scenarios)
144- [ ] Better error messages with context
145- [ ] Machine-readable list output option
146- [ ] LLM-friendly documentation command
147- [ ] Reduced dependency footprint
148- [ ] All changes committed with proper messages
149
150## Risk Assessment
151
152**Low Risk**:
153- anyhow migration (straightforward replacement)
154- quiet flag addition (additive change)
155- LLM command (new, isolated feature)
156
157**Medium Risk**:
158- glob removal (need to ensure exact same behavior)
159- CLI testing (need to handle file system interactions carefully)
160
161## Notes
162
163- Each improvement should be implemented, tested, and committed separately
164- Maintain backward compatibility for all existing commands
165- Update IMPLEMENTATION_PLAN.md as work progresses
166- Consider adding integration tests that verify the actual daemon functionality \ No newline at end of file