aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Refactor cat and tail flag logic for better readabilityfix-tail-flag-logicdiogo4642025-06-261-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | Replace the cryptic boolean expressions with clearer if-else logic that explicitly handles the flag combinations: Old logic (functionally correct but hard to understand): let show_stdout = !args.stderr || args.stdout; let show_stderr = !args.stdout || args.stderr; New logic (clear and self-documenting): let show_stdout = if args.stdout || args.stderr { args.stdout } else { true // Show both when no flags are specified }; This change improves code readability while maintaining identical behavior: - No flags: show both stdout and stderr - --stdout only: show only stdout - --stderr only: show only stderr - Both flags: show both stdout and stderr 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Fix critical process daemonization issue by replacing std::mem::forget with ↵diogo4642025-06-261-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | proper background thread management PROBLEM: The previous implementation used std::mem::forget(child) to detach processes, which caused several critical issues: - Prevented Child destructor from running, leading to resource leaks - Could result in zombie processes under certain conditions - Violated Rust best practices for resource management - No proper cleanup of OS handles and process resources SOLUTION: Replaced std::mem::forget(child) with a background thread approach: - Spawn child process in background thread that owns the Child struct - When thread completes, Child's Drop implementation runs automatically - Ensures proper resource cleanup while maintaining process detachment - Process becomes child of init (PID 1) which handles reaping - Follows Rust idioms for resource management VERIFICATION: - Added test that verifies proper resource management - All existing functionality preserved - No breaking changes to CLI interface - Improved system resource handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add comprehensive root directory validation testsdiogo4642025-06-263-2/+386
| | | | | | | | | | | | | | | | | | These tests cover edge cases including: - Root directory specified as file instead of directory - Non-existent root directories - .demon directory exists as file in git root - Permission denied scenarios - Symlink handling (valid and broken) - Invalid UTF-8 paths - Deeply nested paths Most validation is already working correctly, but these tests document and verify the expected behavior for edge cases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Fix all tests and add cargo test to pre-commit hookHEADmaindiogo4642025-06-231-90/+70
| | | | | | | | | | | - Fixed all 19 failing tests by replacing --root-dir flag with DEMON_ROOT_DIR environment variable - All 28 tests now pass consistently - Added cargo test to pre-commit hook for comprehensive quality checks - Pre-commit hook now runs: cargo fmt, cargo clippy, and cargo test 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add clippy check to pre-commit hook and fix all clippy warningsdiogo4642025-06-231-48/+40
| | | | | | | | | | | | | | | - Enhanced pre-commit hook to run cargo clippy with -D warnings - Fixed uninlined_format_args warnings by using variables directly in format strings - Removed needless borrows in .args() calls - Fixed print_literal warnings by moving literals out of format placeholders - Replaced seek_from_current with stream_position for better semantics - Fixed len_zero warning by using is_empty() instead of len() > 0 All code now passes both cargo fmt and cargo clippy checks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Remove implementation plans and goal filesdiogo4642025-06-234-778/+0
| | | | | | | | Clean up project by removing internal planning documents 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add pre-commit hook for cargo fmt and apply formattingdiogo4642025-06-232-46/+105
| | | | | | | | | | - Created pre-commit hook that runs cargo fmt --check - If formatting issues found, runs cargo fmt and asks for re-commit - Applied cargo fmt to fix existing formatting issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Simplify README titlediogo4642025-06-231-1/+1
| | | | | | | | Remove "Background Process Manager" subtitle for cleaner title 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add GitHub Actions workflow for Rust testingdiogo4642025-06-231-0/+43
| | | | | | | | | | - Runs tests on push and pull requests to main branch - Includes formatting check, clippy linting, build, and test steps - Uses cargo caching for improved performance 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Improve README introduction and add root directory informationdiogo4642025-06-231-180/+21
| | | | | | | | | | | - Rewrite opening section to be clearer and more direct - Better explain the tool's purpose for AI agents - Add root directory discovery details to "How It Works" section - Simplify content structure while maintaining essential information 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Change default root directory to use .demon subdirectorydiogo4642025-06-222-4/+74
| | | | | | | | | | | | | | | | | - Modified find_git_root() to create and return <git_root>/.demon instead of <git_root> - Auto-creates .demon directory if it doesn't exist - Added proper error handling for edge cases (file vs directory conflicts, permissions) - Maintains backward compatibility with explicit --root-dir flag - Added comprehensive test to verify new default behavior - Fixed test argument ordering for test_list_empty Files are now organized as: - Before: /project/daemon.pid, /project/daemon.stdout, /project/daemon.stderr - After: /project/.demon/daemon.pid, /project/.demon/daemon.stdout, /project/.demon/daemon.stderr 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add comprehensive integration tests for clean command behaviordiogo4642025-06-221-4/+56
| | | | | | | | | | | - Enhanced test_clean_with_orphans with explicit verification steps - Added test_clean_removes_stdout_stderr_files to explicitly verify that clean removes all three file types (.pid, .stdout, .stderr) - Fixed argument ordering in tests (--root-dir should come after subcommand) - Tests confirm that clean command correctly removes stdout and stderr files, not just pid files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Update README.md: remove emojis, simplify installation, and remove license ↵diogo4642025-06-221-71/+10
| | | | | | | | | | | | | section - Remove all emoji icons from section headers - Replace installation section with single git install command - Remove license and similar tools sections - Update GitHub issues URL to correct repository 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add environment variable support for root directory configurationdiogo4642025-06-192-2/+2
| | | | | | | | Enable setting the root directory via DEMON_ROOT_DIR environment variable by adding 'env' feature to clap and configuring the root_dir argument to read from environment. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add configurable root directory for daemon files with git root discoverydiogo4642025-06-192-151/+251
| | | | | | | | | | | | | | | | | Implement --root-dir global option to specify where daemon files (PID, stdout, stderr) are created. When not specified, automatically searches upward for git repository root. This addresses the issue of daemon files being scattered across various working directories. Key features: - Global --root-dir option available on all commands - Automatic git root discovery when --root-dir not specified - Proper error handling for invalid directories - Updated all file operations to use configurable root directory - Optimized HashMap usage with PathBuf for better performance - Fixed ID extraction to show daemon names instead of full paths - Updated tests to work with new directory structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Enhance tail command with follow mode control and line count optionsdiogo4642025-06-191-3/+61
| | | | | | | | Add -f/--follow flag to control real-time following behavior and -n/--lines option to specify number of lines to display. By default, tail now shows the last 50 lines and exits, only following when -f is explicitly provided. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add wait subcommand for blocking until process terminationdiogo4642025-06-194-5/+382
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements a new 'wait' subcommand that blocks until a specified daemon process terminates, with configurable timeout and polling interval. Features: - Default 30-second timeout, configurable with --timeout flag - Infinite wait with --timeout 0 - Configurable polling interval with --interval flag (default 1 second) - Quiet operation - only shows errors on failure - Preserves PID files (doesn't clean up) - Exit codes: 0 for success, 1 for failure Usage examples: - demon wait my-process # Wait 30s - demon wait my-process --timeout 0 # Wait indefinitely - demon wait my-process --timeout 60 --interval 2 # Custom timeout/interval Added comprehensive test suite covering: - Non-existent processes - Already terminated processes - Normal process termination - Timeout scenarios - Infinite timeout behavior - Custom polling intervals Updated documentation: - README.md with wait command reference and usage examples - LLM guide with detailed wait command documentation - Integration examples for development workflows 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Update improvement plan with completion statusdiogo4642025-06-191-5/+21
| | | | | | | | | | | | All four planned tasks successfully completed: ✅ Rename PidFileData to PidFile ✅ Implement PidFileReadError enum ✅ Make --id positional argument ✅ Write comprehensive README.md 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add comprehensive README.md with complete documentationdiogo4642025-06-192-9/+362
| | | | | | | | | | | | | | | | | | | | | | | | | - Add detailed overview highlighting key features and benefits - Include installation instructions for multiple methods - Provide comprehensive command reference with examples - Document use cases for development, LLM integration, DevOps - Add practical examples for each major workflow - Include machine-readable output documentation for automation - Document file management, security, and system requirements - Add contributing guidelines and development setup - Position as LLM-friendly tool for background process management - Focus on developer experience and automation integration - Highlight key differentiators vs similar tools README emphasizes: - Simplicity and zero-configuration approach - LLM agent integration capabilities - Development workflow optimization - Practical examples for common scenarios - Clear documentation for automation use cases 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Make --id a positional argument for improved CLI usabilitydiogo4642025-06-192-60/+52
| | | | | | | | | | | | | | | | | | | | | | | - Remove --id flags from all command argument structures - Update RunArgs, StopArgs, TailArgs, CatArgs, StatusArgs to use positional ID - Update all integration tests to use new positional argument syntax - Update comprehensive LLM guide documentation with new command syntax - Maintain -- separator support for complex commands - More natural CLI interface: 'demon run web-server python -m http.server 8080' - Consistent with common tools like docker, systemctl, git - Breaking change but improves usability significantly - All tests pass with new CLI format Examples of new syntax: - demon run web-server python -m http.server 8080 - demon stop web-server - demon status web-server - demon tail web-server --stdout - demon cat web-server 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Implement PidFileReadError enum for better error handlingdiogo4642025-06-192-32/+101
| | | | | | | | | | | | | | | | | | | - Add PidFileReadError enum with FileNotFound, FileInvalid, and IoError variants - Implement Display and Error traits for proper error handling - Update PidFile::read_from_file() to return Result<PidFile, PidFileReadError> - Update all call sites to handle specific error types: - is_process_running(): Handle FileNotFound/FileInvalid as "not running" - stop_daemon(): Handle FileNotFound as "not running", FileInvalid as cleanup needed - list_daemons(): Handle FileInvalid with specific error messages - status_daemon(): Handle FileNotFound as "NOT FOUND", FileInvalid as detailed error - clean_orphaned_files(): Handle FileInvalid as cleanup candidate - Remove redundant Path::exists() checks (error type provides this info) - Fix test timing issue by adding sleep in test_run_creates_files - More idiomatic Rust error handling with specific error types 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Rename PidFileData to PidFilediogo4642025-06-192-27/+275
| | | | | | | | | | | - Rename struct and update all references throughout codebase - Cleaner, more intuitive name that follows Rust conventions - Update documentation comments - No functional changes, purely cosmetic refactor 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Store command in PID file and display in list/status outputdiogo4642025-06-191-145/+151
| | | | | | | | | | | | | | | | | | | | - Add PidFileData struct to represent PID file contents - Store both PID and command in PID file (first line: PID, remaining lines: command args) - Implement write_to_file() and read_from_file() methods for structured data handling - Update run_daemon() to write command alongside PID - Update all functions to use PidFileData instead of raw PID parsing: - is_process_running() - stop_daemon() - list_daemons() - now shows actual command instead of "N/A" - status_daemon() - shows command in detailed output - clean_orphaned_files() - Add command_string() method for formatted display - Maintain backward compatibility with error handling for invalid PID files - All tests pass, command display works correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Format code with rustfmtdiogo4642025-06-192-176/+231
| | | | | | | | | | | | - Apply standard Rust formatting conventions - Improve code readability and consistency - Reorganize imports alphabetically - Fix line lengths and indentation - All tests continue to pass 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Replace glob dependency with std::fs directory traversaldiogo4642025-06-193-106/+100
| | | | | | | | | | | | | - Remove glob crate usage in favor of std::fs::read_dir() - Create find_pid_files() helper function using std::fs - Update list_daemons() and clean_orphaned_files() functions - Maintain same functionality while reducing dependencies - Fix indentation issues after conversion - All tests pass, functionality preserved 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add llm command for comprehensive usage documentationdiogo4642025-06-192-0/+258
| | | | | | | | | | | | | | | | - Add 'demon llm' command that outputs detailed usage guide - Comprehensive documentation targeted at LLM consumption - Covers all commands with syntax, behavior, and examples - Includes common workflows, best practices, and integration tips - Explains file management, error handling, and scripting patterns - Add test to verify LLM command output contains key sections This provides a complete reference that other LLMs can use to understand how to effectively use the demon CLI tool. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add quiet flag to list command for machine-readable outputdiogo4642025-06-192-14/+67
| | | | | | | | | | | | | | | | | - Add ListArgs struct with quiet boolean flag - Convert List command from unit variant to struct variant - In quiet mode: no headers, colon-separated format (id:pid:status) - In normal mode: preserve existing table format - Handle quiet mode in all output scenarios (normal, error cases) - Add comprehensive test for quiet mode functionality Example usage: demon list # Normal table output demon list -q # Quiet: process1:123:RUNNING 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add comprehensive CLI tests using assert_cmddiogo4642025-06-193-1/+617
| | | | | | | | | | | | | | - Add assert_cmd, predicates, and tempfile dev dependencies - Create 18 comprehensive integration tests covering all CLI commands - Test success scenarios, error conditions, and edge cases - Use temporary directories for isolated test environments - Cover file creation, process management, and cleanup functionality All tests pass and provide good coverage of the CLI interface. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Switch to anyhow for improved error handlingdiogo4642025-06-193-17/+345
| | | | | | | | | | | | | | - Replace Box<dyn std::error::Error> with anyhow::Result throughout - Add comprehensive assert_cmd documentation to CLAUDE.md - Create detailed improvement plan in IMPROVEMENT_PLAN.md - Use anyhow::anyhow\! for custom error messages - Add Context trait for better error context where applicable This provides better error messages and more idiomatic Rust error handling. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Add .gitignore for demon process filesdiogo4642025-06-191-0/+6
| | | | | | | | | Ignore *.pid, *.stdout, and *.stderr files created by demon processes to prevent them from being accidentally committed to the repository. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
* Initial implementation of demon CLI tooldiogo4642025-06-196-0/+1554
Implement complete daemon process management CLI with the following features: - demon run: spawn background processes with stdout/stderr redirection - demon stop: graceful process termination with SIGTERM/SIGKILL timeout - demon tail: real-time file watching and log tailing - demon cat: display log file contents - demon list: show all managed processes with status - demon status: detailed process information - demon clean: remove orphaned files from dead processes Technical implementation: - Uses clap for CLI with enum-based subcommands - Structured logging with tracing crate - File watching with notify crate for efficient tailing - Process management with proper signal handling - Creates .pid, .stdout, .stderr files in working directory - Comprehensive error handling and edge case coverage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>