Skip to content

Conversation

@QaidVoid
Copy link
Member

@QaidVoid QaidVoid commented Dec 17, 2025

Summary by CodeRabbit

Release Notes

  • Refactor
    • Consolidated package handling into a dedicated module with improved error handling and format detection capabilities.
    • Enhanced error reporting for package operations with comprehensive error messaging and better diagnostics.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Warning

Rate limit exceeded

@QaidVoid has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3a7838c and 194d8ea.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • crates/soar-package/Cargo.toml (1 hunks)
  • crates/soar-package/src/formats/mod.rs (1 hunks)
  • crates/soar-package/src/formats/wrappe.rs (1 hunks)

Walkthrough

A new soar-package crate is extracted from soar-core to consolidate package format detection, handling, and error management. Package format modules, magic byte constants, error types, and the PackageExt trait are migrated to the new crate. Imports in soar-cli and soar-core are updated accordingly. External dependencies (image, squishy) move to the new crate.

Changes

Cohort / File(s) Summary
New soar-package crate foundation
Cargo.toml, crates/soar-package/Cargo.toml, crates/soar-package/src/lib.rs
Workspace member and dependency added; new crate manifest with dependencies on image, squishy, miette, regex, serde, soar-config, soar-utils, thiserror, tracing. Public API surface established with re-exports of error types, format utilities, magic byte constants, and traits.
soar-package error handling
crates/soar-package/src/error.rs
New PackageError enum with variants for IO, magic bytes, seeking, image, AppImage, config, and custom errors. Public Result<T> type alias and ErrorContext<T> trait for enriching IO errors with context. From-trait implementations for soar_config::ConfigError and soar_utils::FileSystemError.
soar-package format modules
crates/soar-package/src/formats/mod.rs, crates/soar-package/src/formats/appimage.rs, crates/soar-package/src/formats/common.rs, crates/soar-package/src/formats/wrappe.rs
Format detection constants (ELF, AppImage, FlatImage, RunImage, Wrappe, PNG, SVG magic bytes) and PackageFormat enum extracted. Functions get_file_type, integrate_package, symlink_icon, symlink_desktop, create_portable_link, setup_portable_dir, setup_wrappe_portable_dir, integrate_appimage migrated with return types updated from SoarResult<T> to Result<T>.
soar-package traits
crates/soar-package/src/traits.rs
New PackageExt trait with methods pkg_name(), pkg_id(), version(), repo_name() for package metadata access.
soar-core dependency updates
soar-core/Cargo.toml
Dependencies on image and squishy removed; soar-package added as workspace dependency.
soar-core error consolidation
soar-core/src/error.rs
Error variants SquishyError and ImageError removed; replaced with single PackageError variant wrapping soar_package::PackageError.
soar-core constant removal
soar-core/src/constants.rs
Magic byte constants (ELF, APPIMAGE, FLATIMAGE, RUNIMAGE, WRAPPE, PNG, SVG) removed; migrated to soar-package.
soar-core trait migration
soar-core/src/database/models.rs
Local PackageExt trait definition removed; re-exported from soar_package::PackageExt.
soar-core module removal
soar-core/src/package/mod.rs, soar-core/src/package/formats/mod.rs
pub mod formats; removed; entire formats module tree deleted.
soar-cli import updates
soar-cli/Cargo.toml, soar-cli/src/install.rs, soar-cli/src/use.rs
Workspace dependency soar-package added; import paths for integrate_package updated from soar_core::package::formats::common to soar_package::integrate_package.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Scope and spread: ~18 files affected across multiple crates (new crate creation, dependencies, imports, deletions)
  • Consistency of changes: Most edits follow a predictable extraction pattern—moving code, updating error types, consolidating traits—but span diverse modules
  • Logic density: Minimal new logic; primarily reorganization and type signature updates (SoarResult → Result, error variant consolidation)
  • Areas requiring attention:
    • Verify all public API re-exports in soar-package/src/lib.rs align with intended surface
    • Confirm error mapping from soar_package::PackageError to soar_core::SoarError::PackageError preserves context and diagnostics
    • Check that all internal call sites in soar-cli and remaining soar-core code correctly reference the new import paths
    • Validate PackageExt implementations in soar-core/src/database/models.rs still satisfy the newly re-exported trait signature

Poem

🐰 We've hopped and we've reorganized,
Extracted the package, crystallized!
From core to a crate of its own it now flies,
With traits, errors, formats—a modular prize! ✨
Cleaner boundaries, a rabbit's delight! 🥬

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(crate): init soar-package crate' accurately describes the main change: initializing a new crate named soar-package with a well-organized module structure, public API, and error handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Dec 17, 2025

@QaidVoid
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (2)
crates/soar-package/src/error.rs (1)

16-22: Consider adding context to MagicBytesError and SeekError.

These variants lack context that would help with debugging. Consider including the file path or expected vs actual bytes.

-    #[error("Failed to read magic bytes")]
+    #[error("Failed to read magic bytes from {path}")]
     #[diagnostic(code(soar_package::magic_bytes))]
-    MagicBytesError,
+    MagicBytesError { path: String },

-    #[error("Failed to seek in file")]
+    #[error("Failed to seek in file {path}: {reason}")]
     #[diagnostic(code(soar_package::seek))]
-    SeekError,
+    SeekError { path: String, reason: String },
crates/soar-package/src/formats/common.rs (1)

213-214: Consider preserving the original error context.

The error mapping discards the original std::io::Error from env::current_dir(), which could make debugging more difficult.

Apply this diff to preserve error context:

     let base_dir = env::current_dir()
-        .map_err(|_| PackageError::Custom("Error retrieving current directory".into()))?;
+        .with_context(|| "retrieving current directory".to_string())?;

This uses the ErrorContext trait (already in scope) to convert to PackageError::IoError, preserving the original error source.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21070db and 3a7838c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • Cargo.toml (2 hunks)
  • crates/soar-package/Cargo.toml (1 hunks)
  • crates/soar-package/src/error.rs (1 hunks)
  • crates/soar-package/src/formats/appimage.rs (1 hunks)
  • crates/soar-package/src/formats/common.rs (10 hunks)
  • crates/soar-package/src/formats/mod.rs (1 hunks)
  • crates/soar-package/src/formats/wrappe.rs (1 hunks)
  • crates/soar-package/src/lib.rs (1 hunks)
  • crates/soar-package/src/traits.rs (1 hunks)
  • soar-cli/Cargo.toml (1 hunks)
  • soar-cli/src/install.rs (1 hunks)
  • soar-cli/src/use.rs (1 hunks)
  • soar-core/Cargo.toml (1 hunks)
  • soar-core/src/constants.rs (0 hunks)
  • soar-core/src/database/models.rs (1 hunks)
  • soar-core/src/error.rs (1 hunks)
  • soar-core/src/package/formats/mod.rs (0 hunks)
  • soar-core/src/package/mod.rs (0 hunks)
💤 Files with no reviewable changes (3)
  • soar-core/src/package/mod.rs
  • soar-core/src/constants.rs
  • soar-core/src/package/formats/mod.rs
🧰 Additional context used
🧬 Code graph analysis (7)
crates/soar-package/src/traits.rs (1)
soar-core/src/database/models.rs (8)
  • pkg_name (252-254)
  • pkg_name (270-272)
  • pkg_id (256-258)
  • pkg_id (274-276)
  • version (260-262)
  • version (278-280)
  • repo_name (264-266)
  • repo_name (282-284)
crates/soar-package/src/lib.rs (2)
crates/soar-package/src/formats/common.rs (1)
  • integrate_package (326-400)
crates/soar-package/src/formats/mod.rs (1)
  • get_file_type (66-105)
crates/soar-package/src/formats/wrappe.rs (3)
crates/soar-package/src/formats/common.rs (1)
  • create_portable_link (207-227)
crates/soar-package/src/traits.rs (1)
  • pkg_name (9-9)
soar-core/src/database/models.rs (2)
  • pkg_name (252-254)
  • pkg_name (270-272)
soar-cli/src/use.rs (1)
crates/soar-package/src/formats/common.rs (1)
  • integrate_package (326-400)
crates/soar-package/src/formats/appimage.rs (2)
crates/soar-utils/src/fs.rs (1)
  • read_file_signature (223-233)
crates/soar-package/src/formats/common.rs (2)
  • symlink_desktop (142-193)
  • symlink_icon (85-122)
soar-cli/src/install.rs (1)
crates/soar-package/src/formats/common.rs (1)
  • integrate_package (326-400)
crates/soar-package/src/formats/common.rs (2)
crates/soar-package/src/traits.rs (1)
  • pkg_name (9-9)
soar-core/src/database/models.rs (2)
  • pkg_name (252-254)
  • pkg_name (270-272)
🪛 GitHub Actions: CI
Cargo.toml

[warning] 1-1: cargo-machete detected unused dependencies: serde, tracing in soar-package/Cargo.toml.

crates/soar-package/Cargo.toml

[warning] 1-1: cargo-machete detected unused dependencies: serde, tracing in soar-package/Cargo.toml.

🔇 Additional comments (21)
soar-core/Cargo.toml (1)

22-22: LGTM!

Clean dependency migration. The image and squishy dependencies are correctly moved to the new soar-package crate, and the workspace reference is properly configured.

crates/soar-package/src/formats/wrappe.rs (1)

1-39: LGTM on the overall structure and documentation.

Good use of the new Result type alias and comprehensive doc comments following Rust conventions.

crates/soar-package/src/error.rs (2)

7-39: Well-structured error types with diagnostic codes.

Good use of thiserror and miette for rich error handling. The From implementations provide clean error conversion.


44-64: Clean implementation of ErrorContext trait.

The trait provides a consistent pattern for enriching IO errors with contextual information. This is a good abstraction.

soar-cli/src/install.rs (1)

31-31: LGTM!

Import correctly updated to reference integrate_package from the new soar-package crate.

soar-cli/Cargo.toml (1)

37-37: LGTM!

The workspace dependency addition for soar-package is correctly configured and consistent with other workspace dependencies in the manifest.

soar-cli/src/use.rs (1)

14-14: LGTM!

The import path update correctly reflects the migration of integrate_package to the new soar-package crate. The function usage remains consistent throughout the file.

crates/soar-package/src/traits.rs (1)

1-19: LGTM!

The PackageExt trait is well-designed with clear documentation. The four accessor methods provide essential package metadata needed for integration operations. The trait interface is appropriately minimal and focused.

soar-core/src/database/models.rs (1)

20-20: LGTM!

The re-export of PackageExt from soar_package correctly delegates the trait definition to the new crate while maintaining backward compatibility. The existing implementations for Package and InstalledPackage remain unchanged and continue to satisfy the trait contract.

soar-core/src/error.rs (1)

51-52: LGTM!

The PackageError variant correctly wraps the external soar_package::PackageError type, consolidating package-related error handling. The automatic From conversion via the #[from] attribute ensures seamless error propagation throughout the codebase.

crates/soar-package/src/formats/appimage.rs (2)

33-42: LGTM!

The function signature correctly uses the crate-local Result type, and the early return guard efficiently skips unnecessary work when both desktop integration assets are already present.


8-15: LGTM!

The import consolidation correctly brings in the necessary types from the parent module (PNG_MAGIC_BYTES) and the crate's error handling (ErrorContext, Result) and traits (PackageExt).

crates/soar-package/src/lib.rs (1)

1-41: LGTM!

The public API surface is well-designed with clear module organization and comprehensive documentation. The re-exports provide convenient access to key functionality (error types, format detection, integration, magic bytes, and traits), making the crate ergonomic to use. The example code demonstrates proper usage patterns.

crates/soar-package/src/formats/mod.rs (3)

1-12: LGTM!

The module structure and imports are well-organized. The public module declarations and use statements are appropriate for the package format detection functionality.


14-33: LGTM!

The magic byte constants are well-defined with clear documentation. The offset information in comments (e.g., "at offset 8", "at offset file_size - 801") is helpful for understanding where these bytes are expected in the file.


35-50: LGTM!

The PackageFormat enum is well-structured with appropriate derives and clear documentation for each variant. The Unknown variant provides a good fallback for unrecognized formats.

crates/soar-package/src/formats/common.rs (5)

1-44: LGTM!

The imports have been correctly updated to reference the new error types from crate::error, and the SUPPORTED_DIMENSIONS constant provides clear documentation of the supported icon dimensions for desktop integration.


69-122: LGTM!

The function has been properly updated with comprehensive documentation and the new error type. The logic for normalizing icon dimensions and creating symlinks is correct, and error handling is consistent throughout.


124-193: LGTM!

The function has been properly updated with clear documentation explaining the desktop file modification behavior. The return type migration and error handling are consistent with the new error model.


229-303: LGTM!

The function has been properly updated with comprehensive documentation explaining the portable directory setup logic. The return type migration is consistent, and the logic correctly handles both unified and individual portable paths.


305-400: LGTM!

The function has been properly updated with comprehensive documentation explaining the integration workflow. The return type migration is consistent throughout, including the closure definitions, and the format-specific integration logic is correct.

@QaidVoid QaidVoid merged commit 7915faf into main Dec 17, 2025
5 of 6 checks passed
@QaidVoid QaidVoid mentioned this pull request Dec 17, 2025
github-actions bot pushed a commit to Azathothas/soar that referenced this pull request Dec 17, 2025
@QaidVoid QaidVoid mentioned this pull request Dec 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants