### Install Ghost Binary Source: https://github.com/skanehira/ghost/blob/main/README.md Steps to copy the compiled Ghost binary to a local user's bin directory or a system-wide bin directory for easy execution from the command line. ```bash cp target/release/ghost ~/.local/bin/ ``` ```bash sudo cp target/release/ghost /usr/local/bin/ ``` -------------------------------- ### Start Ghost Terminal User Interface (TUI) Source: https://github.com/skanehira/ghost/blob/main/README.md Initiates the interactive TUI mode for real-time task management. It also shows that standard CLI subcommands can still be used. ```bash $ ghost ``` ```bash $ ghost list ``` -------------------------------- ### Get detailed status of a Ghost task Source: https://github.com/skanehira/ghost/blob/main/README.md This command retrieves comprehensive information about a completed or running Ghost task, including its PID, status, command, working directory, start/finish times, exit code, and log file path. ```bash $ ghost status 9fe034eb-2ce7-4809-af10-2c99af15583d ``` -------------------------------- ### Check Ghost Task Status Source: https://github.com/skanehira/ghost/blob/main/README.md Details how to get comprehensive information about a specific running or completed background task, including its PID, status, command, working directory, and log file path. ```bash ghost status e56ed5f8-44c8-4905-97aa-651164afd37e ``` -------------------------------- ### SQLite Database Schema for Ghost Tasks Source: https://github.com/skanehira/ghost/blob/main/docs/architecture.md Defines the structure of the 'tasks' table in the SQLite database used by Ghost to store information about managed processes, including their ID, PID, command, status, and logging path. It also includes indexes for efficient querying based on status, PID, and start time. ```sql CREATE TABLE IF NOT EXISTS tasks ( id TEXT PRIMARY KEY, pid INTEGER NOT NULL, pgid INTEGER, command TEXT NOT NULL, env TEXT, cwd TEXT, status TEXT NOT NULL DEFAULT 'running', exit_code INTEGER, started_at INTEGER NOT NULL, finished_at INTEGER, log_path TEXT NOT NULL ); CREATE INDEX IF NOT EXISTS idx_tasks_status ON tasks(status); CREATE INDEX IF NOT EXISTS idx_tasks_pid ON tasks(pid); CREATE INDEX IF NOT EXISTS idx_tasks_started_at ON tasks(started_at); ``` -------------------------------- ### Run Background Processes with Ghost Source: https://github.com/skanehira/ghost/blob/main/README.md Demonstrates how to execute various commands in the background using `ghost run`, including simple commands, long-running processes, scripts, and commands with specified working directories or environment variables. ```bash ghost run echo "Hello, World" ``` ```bash ghost run sleep 30 ``` ```bash ghost run ./my_script.sh ``` ```bash ghost run --cwd /path/to/directory make build ``` ```bash ghost run --env NODE_ENV=production --env PORT=3000 npm start ``` -------------------------------- ### Build Ghost from Source Source: https://github.com/skanehira/ghost/blob/main/README.md Instructions to clone the Ghost repository and compile the binary using Cargo. This process requires Rust 1.80+ and a Unix-based system. ```bash git clone https://github.com/skanehira/ghost.git cd ghost cargo build --release ``` -------------------------------- ### Ghost Cleanup Command Options Source: https://github.com/skanehira/ghost/blob/main/README.md Detailed documentation for the various command-line options available with the `ghost cleanup` command, including their purpose and default values. ```APIDOC --days N: Delete tasks older than N days (default: 30) --all: Delete all finished tasks regardless of age (overrides --days) --status STATUS: Filter by status (exited, killed, unknown, all) --dry-run or -n: Preview what would be deleted without actually deleting ``` -------------------------------- ### Ghost Architecture Overview Source: https://github.com/skanehira/ghost/blob/main/README.md High-level description of Ghost's daemon-free architecture, outlining its core components and how they interact to manage tasks. ```APIDOC 1. SQLite Database: Stores task metadata and status (ghost.db) 2. File-based Logs: Each task gets its own log file 3. Process Groups: Uses setsid() for proper signal handling and cleanup 4. Status Monitoring: Real-time process checking via signal 0 5. Non-blocking TUI: Uses async event streams for responsive UI ``` -------------------------------- ### Execute Ghost Application Test Suites with Cargo and Nextest Source: https://github.com/skanehira/ghost/blob/main/docs/architecture.md These commands execute the various test suites for the Ghost application, including unit, integration, and end-to-end tests. "cargo test" runs standard tests, "cargo nextest run" provides enhanced output, and "./e2e/run_all_tests.sh" initiates comprehensive E2E scenarios to ensure full functionality. ```Bash cargo test cargo nextest run # Better test output ./e2e/run_all_tests.sh # E2E tests ``` -------------------------------- ### List Ghost Background Tasks Source: https://github.com/skanehira/ghost/blob/main/README.md Shows how to view all managed background tasks and how to filter them by their current status (e.g., running, exited, killed) using the `ghost list` command. ```bash ghost list ``` ```bash ghost list --status running ``` -------------------------------- ### Rust Code for Ghost Process Spawning Source: https://github.com/skanehira/ghost/blob/main/docs/architecture.md Illustrates a simplified Rust code snippet for spawning a new process within Ghost. It shows how to generate a UUID for task identification, redirect standard I/O to a log file, and create a new process group using 'libc::setpgid' for proper signal handling and isolation. ```rust // Simplified process spawning flow let task_id = Uuid::new_v4().to_string(); let mut child = Command::new(&command[0]) .args(&command[1..]) .stdin(Stdio::null()) .stdout(log_file.try_clone()?) .stderr(log_file) .spawn()?; // Create new process group unsafe { libc::setpgid(child.id() as i32, 0); } ``` -------------------------------- ### Build Rust Project Source: https://github.com/skanehira/ghost/blob/main/CLAUDE.md These commands compile the Rust project. Use `cargo build` for a debug build and `cargo build --release` for an optimized release build, suitable for deployment. ```bash cargo build cargo build --release ``` -------------------------------- ### Ghost Environment Variables Source: https://github.com/skanehira/ghost/blob/main/README.md Documentation for environment variables that can be used to configure Ghost's behavior, such as overriding the default data directory. ```APIDOC GHOST_DATA_DIR: Override the default data directory location. This is useful for testing or running multiple instances. ``` -------------------------------- ### Build Ghost Application in Release Mode using Cargo Source: https://github.com/skanehira/ghost/blob/main/docs/architecture.md This command compiles the Ghost application using Cargo, Rust's package manager, in release mode. Release builds are optimized for performance and size, making them suitable for deployment and production environments. ```Bash cargo build --release ``` -------------------------------- ### View Ghost Task Logs Source: https://github.com/skanehira/ghost/blob/main/README.md Explains how to retrieve logs for specific background tasks by their ID and how to follow logs in real-time, similar to `tail -f`, for ongoing processes. ```bash ghost log 9fe034eb-2ce7-4809-af10-2c99af15583d ``` ```bash ghost log c3d4e5f6-g7h8-9012-cdef-345678901234 ``` ```bash ghost log -f e56ed5f8-44c8-4905-97aa-651164afd37e ``` -------------------------------- ### Perform Rust Code Formatting and Linting for Ghost Source: https://github.com/skanehira/ghost/blob/main/docs/architecture.md These commands enforce code style and identify potential issues in the Ghost codebase. "cargo fmt" automatically formats Rust code according to established conventions, while "cargo clippy -- -D warnings" runs a linter to catch common programming mistakes and stylistic errors, treating all warnings as critical errors. ```Bash cargo fmt cargo clippy -- -D warnings ``` -------------------------------- ### Format and Lint Rust Code Source: https://github.com/skanehira/ghost/blob/main/CLAUDE.md Maintain code quality and style. `cargo fmt` automatically formats the code, and `cargo fmt --all -- --check` verifies formatting without applying changes. `cargo clippy` runs the linter, with `cargo clippy -- -D warnings` configured to fail the build on any linter warnings. ```bash cargo fmt cargo fmt --all -- --check cargo clippy cargo clippy -- -D warnings ``` -------------------------------- ### Ghost TUI Keybindings Reference Source: https://github.com/skanehira/ghost/blob/main/README.md Reference for keyboard shortcuts used within the Ghost Terminal User Interface for navigating task lists, viewing logs, and managing tasks. ```APIDOC Task List Keybindings: j/k: Move selection up/down g/G: Jump to top/bottom of list l: View logs for selected task s: Send SIGTERM to selected task Ctrl+K: Send SIGKILL to selected task q: Quit Tab: Switch between task filters (All/Running/Exited/Killed) Log Viewer Keybindings: j/k: Scroll up/down h/l: Scroll left/right (for long lines) g/G: Jump to top/bottom Esc: Return to task list ``` -------------------------------- ### Rust Formatting Rules for Macros Source: https://github.com/skanehira/ghost/blob/main/CLAUDE.md This section outlines best practices for using Rust's formatting macros (`format!`, `println!`, `writeln!`, etc.). It emphasizes the use of inline format strings with embedded expressions (`{variable}`) for improved readability and conciseness, rather than positional arguments (`{}`). ```Rust // ALWAYS use inline format strings with embedded expressions when possible // Use `format!("text {variable}")` instead of `format!("text {}", variable)` // Use `println!("value: {x}")` instead of `println!("value: {}", x)` // Use `writeln!(file, "Log line {i}")` instead of `writeln!(file, "Log line {}", i)` // This applies to all formatting macros: `format!`, `print!`, `println!`, `write!`, `writeln!`, `eprintln!`, etc. ``` -------------------------------- ### Run Rust Benchmarks Source: https://github.com/skanehira/ghost/blob/main/CLAUDE.md Execute performance benchmarks for the Rust project. The `cargo bench` command runs defined benchmarks to measure and track the performance characteristics of the codebase. ```bash cargo bench ``` -------------------------------- ### Run Rust Tests Source: https://github.com/skanehira/ghost/blob/main/CLAUDE.md Execute tests for the Rust project. `cargo test` runs all unit tests, while `cargo test ` targets a specific test. `cargo nextest run` provides faster execution and improved output, especially in CI environments. ```bash cargo test cargo test cargo nextest run ``` -------------------------------- ### Ghost Default Data and Log Locations Source: https://github.com/skanehira/ghost/blob/main/README.md Specifies the default file system locations where Ghost stores its data and logs on different operating systems (Linux and macOS). ```APIDOC Linux: Data: $XDG_DATA_HOME/ghost or $HOME/.local/share/ghost Logs: $XDG_DATA_HOME/ghost/logs or $HOME/.local/share/ghost/logs macOS: Data: ~/Library/Application Support/ghost/ Logs: ~/Library/Application Support/ghost/logs/ ``` -------------------------------- ### Generate Rust Code Coverage Report Source: https://github.com/skanehira/ghost/blob/main/CLAUDE.md Generate a detailed code coverage report for the Rust project. The `cargo llvm-cov nextest --lcov --output-path lcov.info` command produces an LCOV-formatted report, useful for analyzing test coverage. ```bash cargo llvm-cov nextest --lcov --output-path lcov.info ``` -------------------------------- ### Clean up old Ghost tasks Source: https://github.com/skanehira/ghost/blob/main/README.md Commands to remove old or finished Ghost tasks. By default, it cleans tasks older than 30 days. Options allow specifying age, status, or performing a dry run. The --all flag cleans up all finished tasks regardless of age. ```bash $ ghost cleanup ``` ```bash $ ghost cleanup --days 7 ``` ```bash $ ghost cleanup --days 0 ``` ```bash $ ghost cleanup --dry-run ``` ```bash $ ghost cleanup --all ``` ```bash $ ghost cleanup --status killed ``` ```bash $ ghost cleanup --status killed --days 0 ``` ```bash $ ghost cleanup --status killed --all ``` -------------------------------- ### Ghost Log File Storage Structure Source: https://github.com/skanehira/ghost/blob/main/docs/architecture.md Describes the directory structure for Ghost's data and log files. It shows that the 'tasks.db' SQLite database resides directly under '$GHOST_DATA_DIR', and individual task logs are stored in a 'logs/' subdirectory, named by their unique task UUID. ```shell $GHOST_DATA_DIR/ ├── tasks.db └── logs/ ├── {task-uuid-1}.log ├── {task-uuid-2}.log └── {task-uuid-3}.log ``` -------------------------------- ### Stop a running Ghost task Source: https://github.com/skanehira/ghost/blob/main/README.md Commands to gracefully stop a task using SIGTERM or force-kill it using SIGKILL. It also shows the error message when attempting to stop an already exited task. ```bash $ ghost stop e56ed5f8-44c8-4905-97aa-651164afd37e ``` ```bash $ ghost stop c3d4e5f6-g7h8-9012-cdef-345678901234 --force ``` ```bash $ ghost stop 9fe034eb-2ce7-4809-af10-2c99af15583d ``` -------------------------------- ### Define Ghost Application Error Types in Rust Source: https://github.com/skanehira/ghost/blob/main/docs/architecture.md This Rust enum defines the various error types used within the Ghost application, providing explicit failure modes for I/O, database operations, invalid arguments, and task-specific issues. It helps in robust error handling and clearer debugging by categorizing potential problems. ```Rust pub enum GhostError { Io { source: std::io::Error }, Database { source: rusqlite::Error }, InvalidArgument { message: String }, TaskNotFound { task_id: String }, TaskNotRunning { task_id: String, status: String }, // ... } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.