diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 015c08e..0000000 --- a/.dockerignore +++ /dev/null @@ -1,38 +0,0 @@ -# Git -.git -.gitignore -.github - -# Target -target -**/*.rs.bk -*.pdb - -# Documentation -*.md -!README.md - -# CI/CD -Justfile -Makefile -.justfile -.claude - -# Tests -tests -*.spec -PKGBUILD - -# IDE -.vscode -.idea -*.swp -*.swo -*~ - -# OS -.DS_Store -Thumbs.db - -# Logs -*.log diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 9ed818b..0000000 --- a/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -# Multi-stage Dockerfile for SedX - -# Build stage -FROM docker.io/library/rust:1.75-alpine AS builder - -WORKDIR /build - -# Install build dependencies -RUN apk add --no-cache musl-dev - -# Copy source -COPY . . - -# Build release binary -RUN cargo build --release - -# Runtime stage -FROM docker.io/library/alpine:3.19 - -# Install runtime dependencies -RUN apk add --no-cache \ - ca-certificates \ - bash - -# Copy binary from builder -COPY --from=builder /build/target/release/sedx /usr/local/bin/sedx - -# Install man page -RUN mkdir -p /usr/local/share/man/man1 -COPY --from=builder /build/man/sedx.1 /usr/local/share/man/man1/ - -# Create non-root user -RUN addgroup -S sedx && \ - adduser -S sedx -G sedx - -# Set working directory -WORKDIR /workdir - -# Switch to non-root user -USER sedx - -# Verify installation -RUN sedx --version - -ENTRYPOINT ["/usr/local/bin/sedx"] -CMD ["--help"] diff --git a/docs/PRODUCTION_ROADMAP.md b/docs/PRODUCTION_ROADMAP.md deleted file mode 100644 index ed1b18c..0000000 --- a/docs/PRODUCTION_ROADMAP.md +++ /dev/null @@ -1,448 +0,0 @@ -# SedX Production Roadmap: v0.2.6-alpha to v1.0.0 - -**Last Updated:** 2026-02-25 -**Current Branch:** neo -**Current Version:** v0.2.6-alpha -**Current State:** ~9,600 LOC, 13 modules, 121 unit tests passing - ---- - -## Executive Summary - -SedX has completed Phases 1-5 with substantial feature completeness. This roadmap focuses on **production readiness** rather than feature expansion. The path to v1.0.0 prioritizes stability, polish, and documentation over implementing remaining GNU sed commands. - -**Current Status:** -- 95% GNU sed compatibility achieved for common operations -- Core architecture (streaming, backups, regex) is solid -- Flow control (b, t, T), file I/O (r, R, w, W), and additional commands (=, F, z) implemented -- Known issues include Unicode handling, some edge cases -- Code has technical debt (TODOs, large files, compiler warnings) - ---- - -## v1.0.0 Release Criteria - -### Must-Have (Blocking) - -- [ ] Zero critical bugs (data loss or crashes) -- [ ] All known security vulnerabilities addressed -- [ ] 80%+ test coverage -- [ ] Complete user documentation -- [ ] Man page complete and installed -- [ ] Shell completions provided -- [ ] Migration guide from GNU sed -- [ ] Clear documentation of limitations -- [ ] All Phase 1-4 cleanup tasks complete - -### Should-Have (Strongly Recommended) - -- [ ] Unicode pattern matching fixed -- [ ] Property tests for core operations -- [ ] Performance benchmarks documented -- [ ] Real-world examples in docs -- [ ] Contribution guide complete - -### Nice-to-Have (Can Defer to v1.1) - -- [ ] Additional sed commands (y, l, e) -- [ ] Performance optimizations -- [ ] Windows support improvements -- [ ] Fuzz testing infrastructure - ---- - -## Phase 1: Code Cleanup & Stabilization - -**Duration:** 2 weeks -**Priority:** CRITICAL -**Target Release:** v0.3.0-beta - -### Goals -- Remove technical debt -- Eliminate compiler warnings -- Fix known issues affecting stability - -### Tasks - -#### 1.1 Fix Compiler Warnings (1 day) - -**Files with warnings:** -- `src/file_processor.rs`: - - Line 5: Unused import `PathBuf` - - Line 9: Unused import `HashSet` - - Line 1499: Unused variable `address_matches` - - Line 2768: Unused variable `start_idx` - - Line 2914-2956: Unused `range` parameters - -- `src/main.rs`: - - Line 21: Unused import `Path` - - Line 636: Unused variable `idx` - - Line 737: Unused import `save_config` - -- `src/backup_manager.rs`: - - Line 71: Unused constant `WARN_PERCENT` - -- `src/config.rs`: - - Line 10: Unused constant `DEFAULT_CONFIG` - - Lines 1-5: Fix module doc comment (`///` → `//!`) - -- `src/disk_space.rs`: - - Lines 1-5: Fix module doc comment (`///` → `//!`) - -**Action:** Run `cargo clippy -- -D warnings` and fix all issues. - -#### 1.2 Document Unsafe Blocks (1 day) - -**File:** `src/disk_space.rs:74-84` - -Add safety documentation: -```rust -/// # Safety -/// -/// The `c_path` pointer is valid because it comes from a `CString` whose lifetime -/// exceeds this function call. The `statvfs` call is a standard POSIX system call -/// that writes to a valid mutable reference. Return value is checked for errors. -``` - -#### 1.3 Replace Unsafe unwrap() Calls (2 days) - -**Files to fix:** -- `src/sed_parser.rs:308`: `trimmed.chars().nth(pos).unwrap()` -- `src/parser.rs:268`: `flag.to_digit(10).unwrap()` - -**Action:** Replace with `ok_or_else()` and proper error handling. - -#### 1.4 Resolve TODO Comments (3 days) - -**File:** `src/file_processor.rs` -- Line 1753: Pattern range state tracking -- Line 1762: Mixed range state tracking -- Line 2063: Port all commands to cycle model -- Line 2938: R command EOF handling -- Line 2961: D command restart cycle -- Line 3691: Proper parser for file reads - -**Action:** Complete implementation or document as known limitation. - -#### 1.5 Fix Unicode Pattern Matching (3 days) - -**Issue:** Byte index panic on Unicode boundaries. - -**File:** `src/sed_parser.rs:297` - -**Action:** Use char indices instead of byte indices. Add Unicode test cases. - -#### 1.6 Remove Dead Code (1 day) - -**Files to clean:** -- `src/bre_converter.rs:104`: `is_bre_pattern()` - never used -- `src/capability.rs:32`: Functions never called -- `src/diff_formatter.rs`: Unused format methods - -**Action:** Remove or mark with `#[allow(dead_code)]`. - -**Success Criteria:** `cargo clippy` produces zero warnings, all TODOs resolved. - ---- - -## Phase 2: Testing & Coverage - -**Duration:** 2 weeks -**Priority:** HIGH -**Target Release:** v0.4.0-beta - -### Goals -- Achieve 80% test coverage -- Add property-based testing -- Implement stress testing - -### Tasks - -#### 2.1 Coverage Analysis & Gap Filling (1 week) - -**Run coverage:** -```bash -cargo install cargo-tarpaulin -cargo tarpaulin --out Html -``` - -**Target:** 80% line coverage (current estimated: ~60%) - -**Add missing tests for:** -- `src/backup_manager.rs` - Error paths, edge cases -- `src/config.rs` - Corruption handling, validation -- `src/disk_space.rs` - Edge cases, cross-platform -- `src/bre_converter.rs` - Conversion edge cases -- `src/ere_converter.rs` - Backreference handling - -**Test scenarios to add:** -- Regex compilation failures -- Invalid command syntax -- Malformed configuration files -- Disk space exhaustion -- Permission denied errors -- Lock conflicts - -#### 2.2 Property-Based Testing (3 days) - -**Add to Cargo.toml:** -```toml -[dev-dependencies] -proptest = "1.0" -``` - -**Property tests:** -1. Round-trip: parse → process → output matches expected -2. Streaming == in-memory for supported commands -3. Backup can always restore exactly -4. Dry-run == execute (output matches, no file mod) - -#### 2.3 Stress Testing (4 days) - -**Test scenarios:** -1. Large file processing (create 10GB test file) -2. Many small files (10,000 files in batch) -3. Deeply nested flow control (1,000 branches) -4. Complex regex patterns (100 groups) -5. Unicode edge cases (emoji, combining marks, RTL) - -**Success Criteria:** 80%+ coverage, property tests pass, stress tests stable. - ---- - -## Phase 3: Error Handling & User Experience - -**Duration:** 1 week -**Priority:** HIGH -**Target Release:** v0.5.0-beta - -### Goals -- Clear, actionable error messages -- Graceful degradation -- Consistent UX - -### Tasks - -#### 3.1 Parser Error Improvements (2 days) - -**File:** `src/sed_parser.rs` - -**Improvements:** -- Show context around error position -- Suggest corrections for common mistakes -- Example: "Unknown command '2i INSERTED LINE' - text must use '2i\\INSERTED LINE'" - -#### 3.2 Regex Error Handling (2 days) - -**File:** `src/file_processor.rs` - -**Improvements:** -- Capture and explain regex compilation errors -- Distinguish invalid regex from PCRE vs BRE/ERE issues -- Suggest pattern fixes - -#### 3.3 File Operation Error Messages (1 day) - -**Scenarios:** -- Permission denied: Show path and suggest fix -- Disk space: Show available vs required -- Lock conflicts: Suggest --no-backup or retry - -#### 3.4 Warning Consistency (2 days) - -**Review all warnings for:** -- Consistent phrasing -- Actionable suggestions -- Clear severity levels - -**Success Criteria:** All error messages actionable, zero silent failures. - ---- - -## Phase 4: Documentation - -**Duration:** 2 weeks -**Priority:** HIGH -**Target Release:** v0.6.0-beta - -### Goals -- Complete user-facing documentation -- Comprehensive migration guide -- Man pages and shell completions - -### Tasks - -#### 4.1 User Documentation (1 week) - -**Create:** -1. **`docs/USER_GUIDE.md`** - - Installation (cargo, binary, package managers) - - Quick start tutorial - - Common use cases with examples - - Backup system explanation - - Configuration guide - -2. **`docs/MIGRATION_GUIDE.md`** - - Regex syntax differences (PCRE vs BRE/ERE) - - Command compatibility matrix - - Flag differences - - Common migration patterns - - Breaking changes and workarounds - -3. **`docs/EXAMPLES.md`** - - System administration tasks - - Development workflows - - Data processing patterns - - 50+ real-world examples - -4. **Update `README.md`** - - Simplify for new users - - Link to detailed guides - - Performance characteristics - - Current limitations - -#### 4.2 Reference Documentation (3 days) - -**Create/Update:** -1. **`docs/CONTRIBUTING.md`** - Expand - - Development setup - - Code organization - - Testing strategy - - PR guidelines - -2. **`docs/ARCHITECTURE.md`** - New - - Module interactions - - Data flow diagrams - - Streaming architecture - - Backup system design - -3. **`man/sedx.1`** - Man page - - All commands documented - - Examples for each - - All flags documented - - Exit codes - -#### 4.3 Shell Completions (4 days) - -**Create:** -- `completions/bash.sedx` -- `completions/zsh.sedx` -- `completions/fish.sedx` -- `completions/powershell.sedx` - -**Installation:** -- Add to README -- Package in releases -- Auto-install via makefile - -**Success Criteria:** New users can onboard without external help. - ---- - -## Phase 5: Final Polish & Release Preparation - -**Duration:** 1 week -**Priority:** CRITICAL -**Target Release:** v1.0.0 - -### Goals -- Release preparation -- Final testing -- Announcement - -### Tasks - -#### 5.1 Release Preparation (2 days) - -**Tasks:** -- Update `CHANGELOG.md` with all changes -- Tag v1.0.0-rc1 -- Create release notes -- Prepare GitHub release - -#### 5.2 Final Testing (2 days) - -**Tasks:** -- Run full test suite on Linux, macOS, Windows -- Test installation from source -- Test binary distribution -- Verify all documentation examples - -#### 5.3 Announcement (1 day) - -**Tasks:** -- Write announcement blog post -- Update website (if applicable) -- Prepare social media -- Notify relevant communities - -#### 5.4 Release (2 days) - -**Tasks:** -- Build release binaries (Linux x64, macOS ARM64/x64, Windows x64) -- Upload to GitHub Releases -- Publish to crates.io -- Update documentation links - -**Success Criteria:** v1.0.0 released with all criteria met. - ---- - -## Release Timeline - -| Milestone | Target | Duration | Dependencies | -|-----------|--------|----------|--------------| -| v0.3.0-beta | Week 2 | 2 weeks | Code cleanup | -| v0.4.0-beta | Week 4 | 2 weeks | Testing coverage | -| v0.5.0-beta | Week 5 | 1 week | Error handling | -| v0.6.0-beta | Week 7 | 2 weeks | Documentation | -| **v1.0.0-rc1** | Week 8 | 1 week | Release prep | -| **v1.0.0** | Week 9 | 1 week | Final polish | - -**Total Time to v1.0.0:** 9 weeks - ---- - -## Post-v1.0.0 Roadmap - -### v1.1 - Feature Completion (4-6 weeks) -- Performance optimizations -- Additional commands (y, l, e) -- Windows improvements -- Enhanced error messages - -### v1.2 - Enhanced Features (4-6 weeks) -- Interactive mode improvements -- Backup compression options -- Additional PCRE features -- Fuzz testing infrastructure - -### v2.0 - Major Enhancements (Future) -- Script language extensions -- Visual diff mode -- Parallel file processing -- Plugin system - ---- - -## Success Metrics - -### Functional -- 95% compatibility with GNU sed for common operations -- All documented features work as described -- Zero silent data loss scenarios - -### Quality -- 80%+ test coverage -- Zero critical bugs -- Zero known security vulnerabilities - -### Usability -- Clear error messages -- Complete documentation -- Migration path from sed - -### Stability -- Passes stress tests -- No memory leaks -- Handles 100GB files with <100MB RAM diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 9e041cb..a470e78 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -404,7 +404,7 @@ cp ~/.sedx/config.toml.bak ~/.sedx/config.toml - **Windows support**: Enhanced Windows compatibility - **Fuzz testing**: Comprehensive fuzzing infrastructure -See [ROADMAP.md](docs/ROADMAP.md) for full details. +Track ongoing work in [CHANGELOG.md](../CHANGELOG.md) and the GitHub issues/milestones. --- diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md deleted file mode 100644 index cc6394b..0000000 --- a/docs/ROADMAP.md +++ /dev/null @@ -1,891 +0,0 @@ -# SedX Development Roadmap - -**Version:** 0.2.6-alpha → 1.0.0 -**Last Updated:** 2026-02-25 -**Development Approach:** Incremental Releases with Comprehensive Testing - -> **📋 For the production roadmap to v1.0.0, see [PRODUCTION_ROADMAP.md](PRODUCTION_ROADMAP.md)** - ---- - -## 🎯 Project Vision - -SedX is a **modern, safe text processing tool** that: -- Maintains high GNU sed compatibility (~95%) -- Uses **PCRE (modern regex) by default** with optional BRE/ERE modes -- Provides robust backup management with disk space awareness -- Uses stream processing for memory efficiency -- Always uses **sed syntax** (no sd-like simplified syntax) - -**Target Users:** -- System administrators needing safer sed -- Developers wanting modern regex processing -- DevOps engineers requiring reliable automation -- Data scientists processing large files - ---- - -## 📊 Current Status (v0.2.6-alpha - neo branch) - -**Implemented:** 9,600+ lines, 13 modules -- ✅ 25/30 sed commands (83%) - including flow control and file I/O -- ✅ **Full backup system with disk space checking** -- ✅ **Configuration file system** (~/.sedx/config.toml) -- ✅ **Backup management CLI** (list, show, restore, remove, prune) -- ✅ Dry-run & interactive modes -- ✅ Hold space operations (in-memory + streaming) -- ✅ **Unified Command System (UCS) parser** -- ✅ **Regex flavor support (PCRE/ERE/BRE)** -- ✅ **BRE to ERE auto-conversion** -- ✅ **Stdin/stdout pipeline support** -- ✅ **Streaming processing (chunks 1-11 completed)** - - ✅ Basic infrastructure + atomic writes - - ✅ Commands: s, d, p, a, i, c, q, Q - - ✅ Sliding window diff with context - - ✅ Pattern ranges with state machine - - ✅ Hold space operations (h, H, g, G, x) - - ✅ Command grouping with ranges ({...}) - - ✅ Single-pattern address fix (/foo/d) -- ✅ **Essential sed flags (-n, -e, -f)** ✅ COMPLETE -- ✅ **Backup optimization (skip for read-only commands)** ✅ COMPLETE -- ✅ **Comprehensive Phase 4 testing** ✅ COMPLETE -- ✅ **Cycle-based execution architecture** ✅ COMPLETE -- ✅ **Phase 5 COMPLETE**: Flow Control, File I/O, Additional Commands 🔀 - -**Recent Work (Completed 2026-02-25):** -- **Phase 5 COMPLETE**: Flow Control & Advanced Features ✅ - - ✅ **Flow control commands (b, t, T)** - FULLY IMPLEMENTED - - Label registry and program counter - - Unconditional branching (b command) - - Conditional branching (t command - if substitution made) - - Inverse branching (T command - if NO substitution) - - Per-line substitution flag tracking - - 12/12 flow control tests passing - - ✅ **File I/O commands (r, w, R, W)** - FULLY IMPLEMENTED - - File handle management (write_handles HashMap) - - Read position tracking for R command (read_positions HashMap) - - Pattern address detection in parser - - 6/6 file I/O tests passing - - ✅ **Additional commands (=, F, z)** - FULLY IMPLEMENTED - - Stdout output infrastructure (stdout_outputs Vec in CycleState) - - Filename tracking (current_filename field) - - 6/6 additional command tests passing - - ✅ **All 29 Phase 5 tests passing, 121/121 unit tests passing** - - ✅ **~95% GNU sed compatibility achieved** - -- **Phase 4 COMPLETE**: Essential Sed Compatibility 📝 - - ✅ **Week 1**: `-n`/`--quiet`/`--silent` flag, `-e`/`--expression` flag - - ✅ **Week 2**: Multi-line pattern space (n, N, P, D commands - basic implementation) - - ✅ **Week 3**: Q command (quit without printing), `-f`/`--file` flag, backup optimization - - ✅ **Week 4**: Comprehensive testing & bug fixes - - Phase 4 tests: 27/29 passing (93%) - - Regression tests: 10/10 passing (100%) - - Comprehensive tests: 32/40 passing (80%) - - ✅ **Week 5**: Cycle-based architecture & address resolution - - Implemented full cycle-based execution model - - Address resolution for all command types (line, pattern, range, negated, relative, step) - - Single-line address range bug fix - - N command EOF handling fix - - P command newline handling fix - - Full address/range support for multi-line commands - -- **Phase 3 COMPLETE**: Enhanced Regex & Substitution ✅ - - ✅ Escape sequences in replacements (\n, \t, \r, \\, \xHH, \uHHHH) - - ✅ Numbered substitution flag (s/old/new/2g) - - ✅ Substitution print flag (s/old/new/p) - - ✅ All PCRE features tested (named groups, non-capturing, inline flags) - -- **Phase 2 COMPLETE**: Backup Disk Management ✅ - - Disk space checking with configurable thresholds - - All backup management subcommands (list, show, restore, remove, prune) - - Configuration file system with auto-creation and auto-repair - - 110 unit tests passing - - 10/10 regression tests passing - - Cross-platform disk space API (Linux/macOS implemented) - -- **Phase 1 COMPLETE**: Stream Processing Foundation ✅ - - All 11 chunks completed (basic streaming through testing) - - Memory usage: <5MB for 12MB file (was 343MB before optimization) - - 10/10 streaming tests passing - -**Performance:** -- Memory: Constant regardless of file size ✅ -- Speed: 30-126x slower than GNU sed (due to backups + diffs) -- Trade-off: Safety and features vs raw speed -- **Sed Compatibility: ~95%** for common use cases ⭐ - -**Streaming Progress:** -- Chunks 1-11: ✅ **COMPLETED** - Phase 1 (Stream Processing Foundation) is complete! -- Phase 1 SUCCESS: All criteria met except 2x speed target (see Performance section) - -**Test Status:** -- 121 unit tests passing ✅ -- 10/10 regression tests passing ✅ -- 29/29 Phase 5 tests passing ✅ -- Phase 4 features tested (-n, -e flags) ✅ -- Flow control tested (b, t, T commands) ✅ - ---- - -## 🗺️ Development Roadmap - -### Phase 1: Stream Processing Foundation ⭐ CRITICAL ✅ COMPLETED - -**Duration:** Completed (2026-01-10) -**Release:** v0.2.0-alpha (on neo branch) -**Priority:** HIGHEST (User requirement #1) - -#### Goals - ALL ACHIEVED ✅ -- ✅ Enable processing of 100GB+ files with <100MB RAM -- ✅ True sed-like stream behavior -- ✅ Foundation for all future features - -#### Tasks - ALL COMPLETED ✅ - -**Week 1: Core Stream Architecture** ✅ -- ✅ Refactor `file_processor.rs` to use `BufRead` -- ✅ Implement line-by-line processing -- ✅ Add sliding window for context tracking -- ✅ Create atomic file writes (tempfile + rename) -- ✅ Preserve backup system integration - -**Week 2: Command Streaming** ✅ -- ✅ Stream-enable: `s` (substitution) -- ✅ Stream-enable: `d` (delete) -- ✅ Stream-enable: `a`, `i`, `c` (insert/append/change) -- ✅ Stream-enable: `p` (print) -- ✅ Stream-enable: `q` (quit) - -**Week 3: Complex Operations** ✅ -- ✅ Stream-enable pattern ranges with state machine -- ✅ Stream-enable hold space operations -- ✅ Stream-enable: `{}` (grouping) - Completed with full range support -- ⚠️ Stream-enable negation - NOT DONE (low priority, can use in-memory fallback) - -**Week 4: Testing & Polish** ✅ -- ✅ Large file tests (101MB+ tested, constant memory verified) -- ✅ Memory profiling (<5MB for 12MB file with 1 change) -- ✅ Performance benchmarks vs GNU sed -- ✅ Edge case testing (empty files, single lines, binary) -- ✅ Documentation updates - -#### Success Criteria -- ✅ Process 100GB file with <100MB RAM - **ACHIEVED** (<5MB for 12MB file) -- ✅ No performance regression vs current implementation - **ACHIEVED** -- ✅ All existing tests pass - **ACHIEVED** (10/10 regression tests) -- ✅ Backup system works with streaming - **ACHIEVED** -- ❌ Within 2x speed of GNU sed - **NOT ACHIEVED** (30-126x slower, acceptable trade-off) - -#### Performance Notes -SedX is slower than GNU sed due to additional safety features: -- Backup creation (file copies to ~/.sedx/backups/) -- Detailed diff generation -- Atomic writes (tempfile + rename) -- Rust regex engine vs C implementation - -**Trade-off:** Safety and features vs raw speed - This is acceptable for SedX's target users who prioritize data safety over processing speed. - ---- - -### Phase 2: Backup Disk Management 🛡️ CRITICAL ✅ COMPLETED - -**Duration:** Completed (2026-01-10) -**Release:** v0.2.0-alpha (on neo branch) -**Priority:** HIGH (User requirement #2) - -#### Goals - ALL ACHIEVED ✅ -- ✅ Prevent disk space exhaustion -- ✅ User-friendly backup management -- ✅ Smart backup behavior - -#### Tasks - ALL COMPLETED ✅ - -**Week 1: Disk Space Checking** ✅ -- ✅ Implement cross-platform disk space checking (`src/disk_space.rs`) - - Linux: `statvfs` via libc - - macOS: `statvfs` (same code path) - - Windows: Placeholder (not yet tested) -- ✅ Add backup size estimation (checks file metadata) -- ✅ Implement warning thresholds: - - ⚠️ Warn if backup > 2GB (configurable via config) - - ⚠️ Warn if backup > 40% free space (configurable via config) - - ❌ Error if backup > 60% free space (configurable via config) - - ❌ Error if insufficient disk space -- ✅ Add `--no-backup` flag (requires `--force`) -- ✅ Add `--backup-dir` flag - -**Week 2: Backup Management** ✅ -- ✅ Add `sedx config` command (opens $EDITOR, validates syntax) -- ✅ Implement backup subcommands: - - ✅ `sedx backup list` [-v, --verbose] - - ✅ `sedx backup show ` - - ✅ `sedx backup restore ` - - ✅ `sedx backup remove ` [--force] - - ✅ `sedx backup prune` [--keep=N] [--keep-days=N] -- ✅ Create `~/.sedx/config.toml` structure with full template -- ✅ Add configuration validation (auto-fixes malformed configs) -- ✅ Implement config settings: - - ✅ `[backup] max_size_gb`, `max_disk_usage_percent`, `backup_dir` - - ✅ `[compatibility] mode`, `show_warnings` - - ✅ `[processing] context_lines`, `max_memory_mb`, `streaming` -- ✅ Auto-create config on first run with all fields documented -- ✅ Auto-repair malformed config files - -#### Success Criteria - ALL MET ✅ -- ✅ Never silently fill disk -- ✅ All backup operations manageable via CLI -- ✅ Config file editable via `sedx config` command -- ✅ Clear user communication - -**Recent Work (Completed 2026-01-10):** -- ✅ **Configuration file system implemented**: - - Auto-creation on first run with all fields documented - - Well-commented template at `~/.sedx/config.toml` - - Auto-repair of malformed configs - - All config values integrated with CLI flags - - `sedx config --show` displays current configuration - - `sedx config` opens editor and validates syntax - -- ✅ **Disk space checking**: - - Cross-platform `DiskSpaceInfo` module - - Human-readable size formatting - - Pre-backup validation with warnings/errors - - Configurable thresholds via config file - -- ✅ **Backup management commands**: - - All 5 backup subcommands implemented - - List, show, restore, remove, prune operations - - Force flags for dangerous operations - - Clear user feedback and confirmations - -#### Example Usage -```bash -# Large backup warning -$ sedx --execute 's/foo/bar/' hugefile.bin -warning: This operation will create a large backup (3.7 GB) -prompt: Continue? [y/N] y - -# Low disk space error -$ sedx --execute 's/foo/bar/' file.txt -error: Insufficient disk space for backup -backup partition: /home (15.2 GB free) -backup required: 10.1 GB (would use 66% of free space) -options: - 1. Remove old backups: sedx backup prune --keep=5 - 2. Use different location: --backup-dir /mnt/backups - 3. Skip backup: --no-backup --force (not recommended) - -# Edit configuration -$ sedx config -# Opens $EDITOR on ~/.sedx/config.toml -# Validates syntax on save -``` - ---- - -### Phase 3: Enhanced Regex & Substitution Features 🔄 IN PROGRESS - -**Duration:** Started 2026-01-10 -**Target Release:** v0.3.0 -**Priority:** MEDIUM (User requirement #4) - -#### Goals -- Leverage modern PCRE regex capabilities -- Add convenience features while maintaining sed compatibility -- Enhance substitution flags and options -- Improve regex error messages and validation - -#### Tasks - -**Week 1: PCRE Enhancements** ✅ PARTIALLY COMPLETED -- ✅ PCRE-specific features already supported by Rust regex: - - ✅ Named capture groups: `(?P...)` - - ✅ Non-capturing groups: `(?:...)` - - ✅ Inline flags: `(?i)`, `(?m)`, `(?s)` - - ❌ Lookaheads/lookbehinds (not supported by Rust regex crate) - - ❌ Atomic groups (not supported) - - ❌ Possessive quantifiers (not supported) -- [ ] Add regex flag overrides in patterns: `(?i)`, `(?m)`, `(?s)` (ALREADY WORKS) -- [ ] Implement `-X`/`--pcre-only` flag (NOT NEEDED - PCRE is default) -- [ ] Add regex validation and helpful error messages (PENDING) - -**Week 2: Enhanced Features** ✅ COMPLETED -- [ ] Implement `--max-count`/`--max-replacements` flag (NOT NEEDED - use nth flag instead) -- ✅ Numbered substitution flag (`s/old/new/2`) - ALREADY IMPLEMENTED -- ✅ Print-on-substitution flag (`s/old/new/p`) - ALREADY IMPLEMENTED -- [ ] Add capture group validation (PENDING): - - Detect `$1foo` → suggest `${1}foo` - - Validate capture group references - - Helpful error messages -- [ ] Support modern capture syntax (`$1`, `$2`, `${name}`) (ALREADY WORKS) -- [ ] Keep `\1`, `\2` for sed compatibility (convert internally when using `-B`) (ALREADY IMPLEMENTED) - -**Week 3: Escape Sequences & Testing** ✅ COMPLETED -- ✅ Add escape sequences in replacements: - - ✅ `\n`, `\t`, `\r`, `\\` - - ✅ `\xHH`, `\uHHHH` - - ❌ `\U{HHHHHH}` (not implemented) -- [ ] Add escape sequences in patterns (PCRE mode) (NOT NEEDED - Rust regex handles this) -- [ ] Comprehensive testing: - - ✅ All 110 unit tests passing - - ✅ 10/10 regression tests passing - -#### Success Criteria -- ✅ All PCRE features work correctly (that Rust regex supports) -- ✅ Backward compatible with GNU sed in BRE/ERE modes -- [ ] Clear error messages for invalid regex patterns (PENDING) -- [ ] Capture group validation prevents common errors (PENDING) - -**Recent Work (2026-01-10):** -- ✅ **Escape sequences in replacements**: - - Implemented `\n` (newline), `\t` (tab), `\r` (carriage return), `\\` (backslash) - - Implemented `\xHH` (hex character), `\uHHHH` (unicode character) - - Works for both in-memory and streaming processing - - All tests passing (110 unit tests, 10 regression tests) - -- ✅ **Verified existing features**: - - Numbered substitution already works: `s/foo/bar/2` - - Print-on-substitution already works: `s/foo/bar/p` - - Modern capture syntax works: `$1`, `${name}` - - BRE backreferences work: `\1`, `\2` (converted to `$1`, `$2`) - -**Phase 3 Status:** -- COMPLETED: Escape sequences, numbered substitution, print flag -- COMPLETED: PCRE features (non-capturing groups, named groups, inline flags) -- PENDING: Better error messages, capture group validation - -Note: Full PCRE support (lookaheads, atomic groups, possessive quantifiers) would require switching to `fancy-regex` or `pcre2` crate. Current implementation uses Rust's standard `regex` crate which provides excellent performance and supports the most commonly used features. - -#### Example Usage -```bash -# Modern PCRE features (default) -$ sedx 's/(?P\w+)/<\1>/g' file.txt # Named groups -$ sedx 's/foo(?=bar)/FOO/g' file.txt # Lookahead - -# BRE mode (GNU sed compatible) -$ sedx -B 's/\(foo\|bar\)/BAZ/g' file.txt # Auto-converts to (foo|bar) - -# ERE mode (sed -E compatible) -$ sedx -E 's/(foo|bar)/BAZ/g' file.txt - -# Numbered substitution -$ sedx 's/foo/bar/2' file.txt # Replace only 2nd occurrence - -# Capture group validation -$ sedx 's/(\d+)/$1user/' file.txt -error: Ambiguous capture reference: $1user -hint: Use ${1}user to disambiguate: s/(\d+)/${1}user/ -``` - ---- - -### Phase 4: Essential Sed Compatibility 📝 ✅ COMPLETE - -**Duration:** Completed 2026-01-10 (4 weeks) -**Release:** v0.2.4-alpha (on neo branch) -**Priority:** HIGH (User requirement #3) - -#### Goals -- ✅ Implement Tier 1 missing commands -- ✅ Add critical CLI flags -- ✅ Reach ~80% sed compatibility (achieved) - -#### Tasks - -**Week 1: Core Flags** ✅ COMPLETED -- ✅ Implement `-n`/`--quiet`/`--silent` flag (suppress output) -- ✅ Implement `-e`/`--expression` flag (multiple expressions) -- ✅ Update command routing logic for multiple expressions -- ✅ Substitution print flag works with quiet mode - -**Week 2: Multi-line Pattern Space** ✅ COMPLETED -- ✅ Implement `n` command (print, read next, start new cycle) -- ✅ Implement `N` command (append newline + next line) -- ✅ Implement `P` command (print first line of pattern space) -- ✅ Implement `D` command (delete first line, restart cycle) -- ✅ Add multi-line pattern space support -- ⚠️ Note: Multi-line commands require explicit addresses (known limitation) - -**Week 3: Additional Commands** ✅ COMPLETED -- ✅ Implement `Q` command (quit without printing) -- ✅ Add `-f`/`--file` flag (script from file) -- ✅ Implement script file parser -- ✅ Support shebang: `#!/usr/bin/sedx -f` -- ✅ Backup optimization (skip for read-only commands) - -**Week 4: Testing** ✅ COMPLETED -- ✅ Phase 4 comprehensive tests (27/29 passing, 93%) -- ✅ Regression tests vs GNU sed (10/10 passing, 100%) -- ✅ Comprehensive test suite (32/40 passing, 80%) -- ✅ Edge cases tested (empty files, huge lines, EOF handling) -- ✅ Multi-line operation tests (partial - addresses required) - -**Week 5: Cycle-Based Architecture & Address Resolution** ✅ COMPLETED -- ✅ Full cycle-based execution model implemented -- ✅ Address resolution for all command types: - - LineNumber, Pattern, FirstLine, LastLine - - Negated addresses - - Relative ranges (addr,+N and addr,~N) - - Step addresses (first~step) -- ✅ Range state tracking across cycles (for 1,3 ranges) -- ✅ Single-line address range bug fix (2p now works correctly) -- ✅ N command EOF handling fix (no extra newlines) -- ✅ P command newline handling fix (only prints when newline present) -- ✅ Full address/range support for multi-line commands (n, N, P, D, Q) - -#### Success Criteria -- ✅ 80% of common sed scripts work unmodified (achieved) -- ✅ All Tier 1 commands implemented (16/30 complete) -- ✅ No regressions in existing functionality (100% regression test pass) -- ✅ Cycle-based architecture with full address resolution (achieved) - -#### Example Usage -```bash -# Suppress automatic output -$ sedx -n '1,10p' file.txt # Only print lines 1-10 - -# Multiple expressions -$ sedx -e 's/foo/bar/' -e 's/baz/qux/' file.txt - -# Next line operations -$ seq 1 5 | sedx 'n; d' # Print 1, 3, 5 -$ printf "a\nb\nc" | sedx 'N; s/\n/ /' # "a b\nc" - -# Script file -$ cat script.sed -#!/usr/bin/sedx -f -s/foo/bar/g -5,10d - -$ sedx -f script.sed file.txt - -# Quit without printing -$ sedx '/error/Q' file.txt # Quit on first error, don't print -``` - ---- - -### Phase 5: Flow Control & Advanced Features 🔀 ✅ COMPLETE - -**Duration:** Completed 2026-02-25 (4 weeks) -**Release:** v0.2.6-alpha (on neo branch) -**Priority:** MEDIUM (User requirement #5) - -#### Goals - ALL ACHIEVED ✅ -- ✅ Implement flow control commands (COMPLETE) -- ✅ Add file I/O operations (COMPLETE) -- ✅ Additional commands (=, F, z) (COMPLETE) - -#### Completed Work - -**Week 1-2: Labels & Branching** ✅ COMPLETE -- ✅ Implemented `:label` command -- ✅ Implemented `b` command (branch to label) -- ✅ Implemented `b` without label (branch to end) -- ✅ Added label registry during parsing -- ✅ Implemented program counter in execution - -**Week 2: Test Branching** ✅ COMPLETE -- ✅ Track substitution flag state -- ✅ Implemented `t` command (branch if substitution made) -- ✅ Implemented `T` command (branch if NO substitution) -- ✅ Per-line substitution flag tracking -- ✅ Full state management - -**Week 3: File I/O** ✅ COMPLETE -- ✅ Implemented `r file` command (read and append file contents) -- ✅ Implemented `w file` command (write pattern space to file) -- ✅ File handle management structure (write_handles HashMap) -- ✅ Implemented `R file` (read one line from file) -- ✅ Implemented `W file` (write first line to file) -- ✅ Read position tracking for R command (read_positions HashMap) -- ✅ Pattern address detection in parser (is_inside_pattern_address helper) - -**Week 4: Additional Commands** ✅ COMPLETE -- ✅ Implemented `=` command (print line number to stdout) -- ✅ Implemented `F` command (print filename to stdout) -- ✅ Implemented `z` command (clear pattern space) -- ✅ Stdout output infrastructure (stdout_outputs Vec in CycleState) -- ✅ Filename tracking (current_filename field) -- ✅ Comprehensive flow control tests (12/12 passing) -- ✅ File I/O tests (6/6 passing) -- ✅ Additional command tests (6/6 passing) - -#### Implementation Status - -**Fully Implemented:** -- ✅ Labels (`:label`) -- ✅ Unconditional branching (`b`) -- ✅ Conditional branching (`t` - if substitution made) -- ✅ Inverse branching (`T` - if NO substitution) -- ✅ Branching with line addresses and ranges -- ✅ Branching with pattern addresses -- ✅ Groups with flow control -- ✅ Per-line substitution flag tracking -- ✅ File I/O commands (r, R, w, W) - full implementation -- ✅ Additional commands (=, F, z) - full implementation - -#### Success Criteria - ALL MET ✅ -- ✅ Flow control works correctly (100% - 12/12 tests passing) -- ✅ File operations safe and working (6/6 tests passing) -- ✅ Comprehensive test coverage (29/29 Phase 5 tests passing) - -#### Known Limitations -- Pattern range with branch command (`/start/,/end/b`) not yet supported by parser -- File I/O commands reopen files on each access (acceptable for current implementation) - -#### Test Results -``` -All 29 Phase 5 tests passing -All 121 unit tests passing -Validated against GNU sed behavior -``` - -#### Example Usage -```bash -# Loop until pattern matches (WORKS) -$ sedx ':top; /found/q; n; b top' file.txt - -# Repeat substitution until no more matches (WORKS) -$ sedx ':loop; s/foo/bar/; t loop' file.txt - -# Read/Write files (PARSES but doesn't execute yet) -$ sedx '5r header.txt' file.txt -$ sedx '/error/w errors.log' file.txt - -# Print line numbers (PARSES but doesn't execute yet) -$ sedx '=' file.txt -``` - -#### Next Steps for Phase 5 -To complete Phase 5, the following architecture work is needed: -1. Refactor cycle-based execution to support mutable state -2. Implement actual file reading/writing (r, R, w, W commands) -3. Implement stdout writing for = and F commands -4. Implement pattern space clearing for z command -5. Support pattern ranges with flow control commands in parser - ---- - -### Phase 6: Advanced Addressing & Polish ✨ - -**Duration:** 3 weeks -**Target Release:** v0.6.0 -**Priority:** LOW-MEDIUM - -#### Goals -- Add advanced addressing modes -- Implement remaining commands - -#### Tasks - -**Week 1: Advanced Addressing** -- [ ] Implement stepping addresses (`first~step`) -- [ ] Implement relative ranges (`addr,+N`) -- [ ] Implement special address `0` (first line) -- [ ] Add address validation - -**Week 2-3: Additional Commands** -- [ ] Implement `y` command (translate characters) -- [ ] Implement `l` command (list with escapes) -- [ ] Add `-l N` flag (line length for `l`) -- [ ] Implement `e` command (execute shell) with sandbox -- [ ] Documentation completion - -#### Success Criteria -- [ ] All addressing modes work -- [ ] Tier 3 commands implemented -- [ ] Documentation complete - ---- - -### Phase 6.5: Performance Optimization ⚡ (NEW) - -**Duration:** 2 weeks -**Target Release:** v0.6.5 -**Priority:** MEDIUM (deferrable to post-1.0 if needed) - -#### Goals -- Close the speed gap with GNU sed -- Optimize hot paths in streaming mode -- Reduce overhead of backups and diffs - -#### Context -Current performance: 30-126x slower than GNU sed -- This is acceptable for v1.0 due to safety features -- Optimization can be deferred if needed for timeline -- Focus on common use cases: simple substitutions and deletions - -#### Tasks - -**Week 1: Core Optimizations** -- [ ] Profile and identify bottlenecks (use flamegraph/perf) -- [ ] Optimize backup creation: - - [ ] Use hard links when possible (same filesystem) - - [ ] Lazy backup compression (compress in background) - - [ ] Optional: `--no-backup` flag for trusted operations -- [ ] Optimize regex compilation: - - [ ] Cache compiled regex objects - - [ ] Lazy regex compilation (only when used) -- [ ] Reduce diff overhead: - - [ ] Make diff generation optional (`--no-diff` flag) - - [ ] Stream diff to temp file instead of memory - - [ ] Lazy diff formatting (only on error or request) - -**Week 2: Advanced Optimizations** -- [ ] Parallel file processing (Rayon): - - [ ] Process multiple files in parallel - - [ ] Parallel chunk processing for large files -- [ ] I/O optimizations: - - [ ] Use `mmap` for large files when safe - - [ ] Optimize buffer sizes for streaming - - [ ] Batch writes to reduce syscalls -- [ ] Regex engine optimizations: - - [ ] Consider regex crate alternatives (fancy-regex, pcre2) - - [ ] JIT compilation for frequently used patterns -- [ ] Benchmark and iterate: - - [ ] Re-run benchmarks after each optimization - - [ ] Target: Within 5-10x of GNU sed (realistic goal) - - [ ] Document trade-offs - -#### Success Criteria -- [ ] Within 5-10x of GNU sed for common operations -- [ ] No regressions in functionality or safety -- [ ] Memory usage remains constant -- [ ] Benchmark suite documenting performance - -#### Optimization Targets (Priority Order) -1. **Backup overhead** - biggest win for large files - - Current: Copies entire file to ~/.sedx/backups/ - - Target: Hard links or compression - - Expected speedup: 2-5x - -2. **Regex compilation** - helps scripts with many patterns - - Current: Compiles regex on every use - - Target: Cache compiled regex - - Expected speedup: 1.5-3x for pattern-heavy scripts - -3. **Diff generation** - helps when output is large - - Current: Builds full diff in memory - - Target: Stream or disable diff - - Expected speedup: 1.2-2x for large outputs - -4. **I/O operations** - marginal gains - - Current: Standard BufRead/BufWriter - - Target: mmap or larger buffers - - Expected speedup: 1.1-1.5x - -#### Risk Mitigation -- **Risk:** Optimizations introduce bugs - - **Mitigation:** Comprehensive test suite before optimization -- **Risk:** Complex optimizations delay v1.0 - - **Mitigation:** Mark as deferrable; deliver v1.0 with current speed -- **Risk:** Optimizations reduce safety - - **Mitigation:** Keep safety features; add opt-out flags - ---- - -### Phase 7: Production Hardening 🚀 - -**Duration:** 2 weeks -**Target Release:** v1.0.0 -**Priority:** CRITICAL - -#### Goals -- Production-ready stability -- Complete documentation -- Full test coverage - -#### Tasks - -**Week 1: Testing** -- [ ] Property-based tests (proptest) -- [ ] Fuzz testing for parser -- [ ] Large file tests (100GB+) -- [ ] Memory leak detection -- [ ] Stress testing - -**Week 2: Documentation & Release** -- [ ] Complete SPECIFICATION.md -- [ ] Write tutorial -- [ ] Create migration guide (sed → sedx) -- [ ] Add shell completions (bash, zsh, fish, powershell) -- [ ] Prepare v1.0.0 release -- [ ] Update README, man pages -- [ ] Create announcement - -#### Success Criteria -- [ ] 95%+ test coverage -- [ ] Zero known critical bugs -- [ ] Complete documentation -- [ ] Successful beta testing - ---- - -## 📅 Release Timeline - -| Version | Date | Features | Stability | -|---------|------|----------|-----------| -| **v0.1.0** | Past | Basic sed commands, in-memory | Alpha | -| **v0.2.0-alpha** | 2026-01-10 | **Stream processing (Phase 1 complete)** | Alpha | -| **v0.2.0** | Current | Complete streaming + all tests | Beta | -| **v0.2.1** | Next | Backup disk management | Beta | -| **v0.3.0** | +3 weeks | Enhanced substitution | Beta | -| **v0.4.0** | +7 weeks | Essential sed compatibility | Beta | -| **v0.5.0** | +11 weeks | Flow control & file I/O | Beta | -| **v0.6.0** | +14 weeks | Advanced addressing & polish | RC | -| **v0.6.5** | +16 weeks | **Performance optimization** ⚡ | RC (optional) | -| **v1.0.0** | +18 weeks | Production-ready | Stable | - -**Total Duration:** ~4-5 months (18 weeks with opt. Phase 6.5) - ---- - -## 🎯 Success Metrics - -### Functionality -- [ ] 95% compatibility with GNU sed for common operations -- [ ] Full PCRE support with modern regex features -- [ ] Stream processing handles 100GB+ files with <100MB RAM -- [ ] Backup system prevents all silent data loss - -### Performance -- [ ] Within 2x speed of GNU sed for typical operations -- [ ] Memory usage constant regardless of file size -- [ ] No memory leaks in long-running processes - -### Reliability -- [ ] Zero silent disk space exhaustion -- [ ] Zero data loss incidents (with backups enabled) -- [ ] All operations recoverable via rollback -- [ ] Comprehensive test coverage (>90%) - -### Usability -- [ ] Clear incompatibility warnings -- [ ] Helpful error messages -- [ ] Intuitive backup management -- [ ] Complete documentation - ---- - -## 🔄 Iteration Process - -### Sprint Structure (2-3 weeks each) - -1. **Planning (1 day)** - - Review tasks for sprint - - Estimate effort - - Identify dependencies - -2. **Development (80% of sprint)** - - Implement features - - Write tests alongside code - - Update documentation - -3. **Testing & Review (15% of sprint)** - - Run comprehensive tests - - Performance benchmarks - - Code review - -4. **Release (5% of sprint)** - - Tag release - - Update CHANGELOG - - Create announcement - -### Continuous Integration - -- Run tests on every commit -- Benchmark performance weekly -- Regression testing before releases -- Beta testing for major versions - ---- - -## 🚧 Risks & Mitigations - -### Technical Risks - -**Risk: Stream processing breaks existing functionality** -- **Probability:** Medium -- **Impact:** High -- **Mitigation:** Comprehensive regression tests, gradual migration - -**Risk: Performance regression** -- **Probability:** Medium -- **Impact:** Medium -- **Mitigation:** Regular benchmarks, performance targets - -**Risk: Cross-platform issues** -- **Probability:** Low -- **Impact:** Medium -- **Mitigation:** Test on Linux, macOS, Windows regularly - -### Project Risks - -**Risk: Scope creep** -- **Probability:** Medium -- **Impact:** Medium -- **Mitigation:** Clear priorities, phased approach - -**Risk: User adoption** -- **Probability:** Low -- **Impact:** High -- **Mitigation:** Documentation, examples, migration guide - ---- - -## 📚 Documentation Plan - -### User Documentation -- [ ] Tutorial (interactive) -- [ ] Quick reference guide -- [ ] Migration guide (sed → sedx) -- [ ] Examples cookbook -- [ ] FAQ - -### Developer Documentation -- [ ] Architecture overview -- [ ] Contributing guide -- [ ] Code style guide -- [ ] Testing guide -- [ ] Release process - ---- - -## 🤝 Community & Feedback - -### Feedback Channels -- GitHub Issues (bug reports, feature requests) -- GitHub Discussions (usage questions, ideas) -- Regular releases with changelogs - -### Contribution Guidelines -- Bug fixes welcome anytime -- Features should be discussed first -- All contributions require tests -- Code review required - ---- - -## 🎉 Conclusion - -This roadmap delivers a **production-ready SedX** in ~5-6 months through incremental releases: - -1. **Stream processing** (foundation for large files) -2. **Backup management** (safety first) -3. **Enhanced regex features** (modern PCRE with sed compatibility) -4. **Sed compatibility** (Tier 1 + Tier 2 commands) -5. **Flow control** (complex scripts) -6. **Advanced features** (addressing, polish) -7. **Production hardening** (stability & docs) - -**Key Principles:** -- ✅ Stream processing first (architectural foundation) -- ✅ Incremental releases (regular feedback) -- ✅ Comprehensive testing (per sprint) -- ✅ Modern regex by default (PCRE) with sed compatibility modes -- ✅ Unified command system (clean internal architecture) -- ✅ Safety features (backups, disk checks) -- ✅ Clear communication (warnings, docs) - -The result: a **modern, safe, powerful** text processing tool that maintains GNU sed compatibility while providing modern regex capabilities. diff --git a/justfile b/justfile deleted file mode 100644 index 9c97138..0000000 --- a/justfile +++ /dev/null @@ -1,251 +0,0 @@ -# SedX Justfile -# Modern alternative to Makefile using the 'just' command runner -# Install: cargo install just -# Usage: just [target] - -# Variables -cargo := "cargo" -binary := "sedx" -src_dir := "src" -man_dir := "man" -man_page := man_dir + "/sedx.1" -completions_dir := "completions" -prefix := env_var_or_default("PREFIX", "/usr/local") -bindir := prefix + "/bin" -mandir := prefix + "/share/man/man1" -datadir := prefix + "/share" -compdir := datadir + "/" + binary - -# Default target -default: build - -# Build the release binary -build: - @echo "Building {{binary}} in release mode..." - {{cargo}} build --release - @echo "Build complete: target/release/{{binary}}" - -# Build debug binary (faster compilation) -dev: - @echo "Building {{binary}} in debug mode..." - {{cargo}} build - @echo "Build complete: target/debug/{{binary}}" - -# Run all tests -test: - @echo "Running all tests (unit + integration)..." - {{cargo}} test --all-features - @echo "All tests passed!" - -# Run quick tests only -test-quick: - @echo "Running quick tests..." - {{cargo}} test - @echo "Quick tests passed!" - -# Run tests with race detection -test-race: - @echo "Running tests with race detection..." - {{cargo}} test --all-features - @echo "Race-free tests passed!" - -# Install binary to ~/.local/bin or /usr/local -install: build - @echo "Installing {{binary}}..." - # Prefer ~/.local/bin if it exists or can be created - @if [ -w "{{env_var('HOME')}}/.local/bin" ] || mkdir -p "{{env_var('HOME')}}/.local/bin" 2>/dev/null; then \ - INSTALL_DIR="{{env_var('HOME')}}/.local/bin"; \ - else \ - INSTALL_DIR="{{bindir}}"; \ - fi - @echo "Installing to $INSTALL_DIR" - install -Dm755 "target/release/{{binary}}" "$INSTALL_DIR/{{binary}}" - @echo "Installed {{binary}} to $INSTALL_DIR" - -# Install to system directory (requires sudo) -install-system: build - @echo "Installing {{binary}} to {{prefix}}..." - @echo "This may require sudo privileges" - install -Dm755 target/release/{{binary}} {{bindir}}/{{binary}} - @echo "Installed {{binary}} to {{bindir}}" - -# Remove installed binary -uninstall: - @echo "Uninstalling {{binary}}..." - @rm -f "{{env_var('HOME')}}/.local/bin/{{binary}}" 2>/dev/null && echo "Removed from ~/.local/bin" || true - @rm -f "{{bindir}}/{{binary}}" 2>/dev/null && echo "Removed from {{bindir}}" || true - @echo "Note: Completions and man pages must be removed manually" - -# Install man page -man: - @echo "Installing man page..." - install -Dm644 {{man_page}} {{mandir}}/{{binary}}.1 - @echo "Installed man page to {{mandir}}" - -# Validate and list shell completions -completions: - @echo "Available shell completions..." - ls -la {{completions_dir}} || echo "No completions directory found" - @echo "Completions are maintained in {{completions_dir}}/" - -# Install shell completions -completions-install: - @echo "Installing shell completions..." - # bash - mkdir -p {{datadir}}/bash-completion/completions - install -Dm644 {{completions_dir}}/{{binary}}.bash {{datadir}}/bash-completion/completions/{{binary}} - # zsh - mkdir -p {{datadir}}/zsh/site-functions - install -Dm644 {{completions_dir}}/{{binary}}.zsh {{datadir}}/zsh/site-functions/_{{binary}} - # fish - mkdir -p {{datadir}}/fish/vendor_completions.d - install -Dm644 {{completions_dir}}/{{binary}}.fish {{datadir}}/fish/vendor_completions.d/{{binary}}.fish - @echo "Installed completions" - -# Clean build artifacts -clean: - @echo "Cleaning build artifacts..." - {{cargo}} clean - @rm -rf {{completions_dir}} - @echo "Clean complete" - -# Format code with rustfmt -fmt: - @echo "Formatting code..." - {{cargo}} fmt - @echo "Code formatted" - -# Run clippy lints -lint: - @echo "Running clippy..." - {{cargo}} clippy --all-targets --all-features -- -D warnings - @echo "No clippy warnings!" - -# Check if code is formatted -fmt-check: - @echo "Checking code formatting..." - {{cargo}} fmt --check - @echo "Code is formatted" - -# Run fmt check and clippy -check: fmt-check lint - -# Run the same checks CI runs (fmt + clippy stable+beta + test + docs) -check-ci: - @echo "Running CI-equivalent checks locally..." - {{cargo}} fmt --check - {{cargo}} clippy --all-targets --all-features -- -D warnings - @if command -v rustup >/dev/null 2>&1 && rustup toolchain list 2>/dev/null | grep -q '^beta'; then \ - echo "Running beta clippy..."; \ - {{cargo}} +beta clippy --all-targets --all-features -- -D warnings; \ - else \ - echo "Skipping beta clippy (beta toolchain not installed; 'rustup toolchain install beta' to enable)"; \ - fi - {{cargo}} test --all-features - {{cargo}} doc --no-deps --all-features - @echo "CI-equivalent checks passed" - -# Install the pre-push git hook (copies from contrib/hooks/) -install-hook: - @if [ ! -d .git ]; then \ - echo "Not a git checkout; nothing to install"; \ - exit 1; \ - fi - install -m 0755 contrib/hooks/pre-push .git/hooks/pre-push - @echo "Pre-push hook installed at .git/hooks/pre-push" - @echo "Bypass once with: git push --no-verify" - -# Build release binaries for all platforms -release: - @echo "Building release binaries for all platforms..." - mkdir -p release - # Linux x86_64 - @echo "Building for Linux x86_64..." - {{cargo}} build --release --target x86_64-unknown-linux-gnu - cp target/x86_64-unknown-linux-gnu/release/{{binary}} release/{{binary}}-linux-x86_64 - # Linux aarch64 - @echo "Building for Linux aarch64..." - {{cargo}} build --release --target aarch64-unknown-linux-gnu - cp target/aarch64-unknown-linux-gnu/release/{{binary}} release/{{binary}}-linux-aarch64 - # macOS x86_64 - @echo "Building for macOS x86_64 (may fail if toolchain not installed)..." - @{{cargo}} build --release --target x86_64-apple-darwin 2>/dev/null || true - @if [ -f target/x86_64-apple-darwin/release/{{binary}} ]; then \ - cp target/x86_64-apple-darwin/release/{{binary}} release/{{binary}}-darwin-x86_64; \ - fi - # macOS aarch64 (Apple Silicon) - @echo "Building for macOS aarch64 (may fail if toolchain not installed)..." - @{{cargo}} build --release --target aarch64-apple-darwin 2>/dev/null || true - @if [ -f target/aarch64-apple-darwin/release/{{binary}} ]; then \ - cp target/aarch64-apple-darwin/release/{{binary}} release/{{binary}}-darwin-aarch64; \ - fi - # Windows x86_64 - @echo "Building for Windows x86_64..." - {{cargo}} build --release --target x86_64-pc-windows-gnu - cp target/x86_64-pc-windows-gnu/release/{{binary}}.exe release/{{binary}}-windows-x86_64.exe - @echo "Release binaries built in release/" - -# Generate checksums for release binaries -release-checksums: release - @echo "Generating checksums..." - cd release && \ - sha256sum {{binary}}-* > SHA256SUMS.txt && \ - sha512sum {{binary}}-* > SHA512SUMS.txt - @echo "Checksums generated" - -# Verify release binaries against checksums -release-verify: - @echo "Verifying release binaries..." - cd release && sha256sum -c SHA256SUMS.txt - @echo "All binaries verified" - -# Build documentation -docs: - @echo "Building documentation..." - {{cargo}} doc --no-deps --all-features - @echo "Documentation built" - -# Build and open documentation -docs-open: docs - {{cargo}} doc --no-deps --all-features --open - -# Update dependencies -update: - @echo "Updating dependencies..." - {{cargo}} update - @echo "Dependencies updated" - -# Run benchmarks against GNU sed -benchmark: - @echo "Running benchmarks..." - @./tests/tools/benchmark.sh - -# Show version information -version: - @echo "SedX Version Information" - @{{cargo}} --version - @echo "" - @target/release/{{binary}} --version - -# Run all checks before committing -pre-commit: fmt-check lint test-quick - @echo "All checks passed!" - -# Create a git tag for release -tag VERSION: - @echo "Creating tag v{{VERSION}}..." - git tag -a "v{{VERSION}}" -m "Release v{{VERSION}}" - @echo "Tag created. Push with: git push origin v{{VERSION}}" - -# Publish to crates.io -publish: - @echo "Publishing to crates.io..." - {{cargo}} publish - @echo "Published!" - -# Show help -help: - @echo "SedX Justfile" - @echo "" - @echo "Available recipes:" - @just --list diff --git a/scripts/package.sh b/scripts/package.sh deleted file mode 100755 index 811bbb6..0000000 --- a/scripts/package.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# Package SedX for distribution - -set -e - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" -VERSION="${VERSION:-$(grep '^version = ' "$PROJECT_ROOT/Cargo.toml" | head -1 | cut -d '"' -f 2)}" -PACKAGE_NAME="sedx-${VERSION}" -PACKAGE_DIR="$PROJECT_ROOT/dist/$PACKAGE_NAME" - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -echo -e "${BLUE}Packaging SedX ${VERSION}...${NC}" - -# Clean previous builds -echo -e "${BLUE}Cleaning previous builds...${NC}" -cargo clean - -# Build release binary -echo -e "${BLUE}Building release binary...${NC}" -cargo build --release - -# Create package directory -rm -rf "$PACKAGE_DIR" -mkdir -p "$PACKAGE_DIR" - -# Copy binary -echo -e "${BLUE}Copying files...${NC}" -cp "$PROJECT_ROOT/target/release/sedx" "$PACKAGE_DIR/" - -# Copy documentation -mkdir -p "$PACKAGE_DIR/share/man/man1" -cp "$PROJECT_ROOT/man/sedx.1" "$PACKAGE_DIR/share/man/man1/" - -# Copy license and readme -cp "$PROJECT_ROOT/LICENSE" "$PACKAGE_DIR/" -cp "$PROJECT_ROOT/README.md" "$PACKAGE_DIR/" - -# Copy completions -echo -e "${BLUE}Copying completions...${NC}" -mkdir -p "$PACKAGE_DIR/share/completions" -cp -r "$PROJECT_ROOT/completions/"* "$PACKAGE_DIR/share/completions/" - -# Create tarball -echo -e "${BLUE}Creating tarball...${NC}" -cd "$PROJECT_ROOT/dist" -tar czvf "${PACKAGE_NAME}.tar.gz" "$PACKAGE_NAME" -cd "$PROJECT_ROOT" - -# Generate checksums -echo -e "${BLUE}Generating checksums...${NC}" -cd "$PROJECT_ROOT/dist" -sha256sum "${PACKAGE_NAME}.tar.gz" > "${PACKAGE_NAME}.tar.gz.sha256" -sha512sum "${PACKAGE_NAME}.tar.gz" > "${PACKAGE_NAME}.tar.gz.sha512" -cd "$PROJECT_ROOT" - -echo -e "${GREEN}Package created: dist/${PACKAGE_NAME}.tar.gz${NC}" -echo -e "${GREEN}Checksums: dist/${PACKAGE_NAME}.tar.gz.sha256${NC}" -echo -e "${GREEN} dist/${PACKAGE_NAME}.tar.gz.sha512${NC}"