Skip to content

feat(vfox): add lua archive and file operations - #11652

Merged
jdx merged 3 commits into
mainfrom
agent/lua-file-archive-operations
Aug 3, 2026
Merged

feat(vfox): add lua archive and file operations#11652
jdx merged 3 commits into
mainfrom
agent/lua-file-archive-operations

Conversation

@jdx

@jdx jdx commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • add optional strip_components = 1 support to archiver.decompress
  • expose sorted file.list, file.glob, and file.move operations to Lua plugins
  • return a Lua error instead of panicking for unsupported archive formats
  • document the new APIs and update the bundled LuaCATS definitions

Motivation

Lua backend plugins currently need platform-specific external commands to flatten versioned archive roots or rename glob-matched executables. These APIs let plugins handle those layouts portably within mise.

Closes the implementation gap described in discussion #11649.

Validation

  • mise --cd crates/vfox run test
  • mise --cd crates/vfox run lint
  • mise --cd crates/vfox run lint-fix

AI-assisted — Tool: Codex; model: openai/gpt-5; version: unavailable.


Note

Medium Risk
Changes plugin install paths (extract layout and file moves) used during tool installation; mistakes could break installs but scope is limited to the vfox Lua bridge with solid test coverage.

Overview
Extends the vfox Lua plugin API so install scripts can flatten archives and manipulate the filesystem without shelling out.

archiver.decompress accepts an optional { strip_components = 1 } table. With 1, extraction uses a temp directory then hoists one level of top-level directories into the destination while keeping root-level files, aligned with mise’s built-in extractors. Invalid args, bad options, and destination collisions fail with Lua runtime errors; unsupported formats no longer panic via unimplemented!.

file gains sorted list, glob (new glob crate dependency), and move backed by xx::file. Docs and bundled LuaCATS in mise-plugin.lua are updated accordingly, with unit tests for strip behavior, collisions, and pcall on archive errors.

Reviewed by Cursor Bugbot for commit 0422b72. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • Added file operations for listing directories, matching paths with glob patterns, and moving files or directories.
    • Added an option to remove one leading directory component when extracting archives.
    • File moves now create missing destination directories automatically.
  • Bug Fixes

    • Improved archive validation and error handling for invalid paths and unsupported formats.
    • Prevented archive extraction from overwriting existing destination entries.
  • Documentation

    • Added usage examples for the new file operations and archive extraction option.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds file.list, file.glob, and file.move Lua operations. It extends archiver.decompress with optional component stripping and Lua errors for invalid inputs and unsupported formats. Types, tests, dependencies, and documentation are updated.

Changes

Lua module capabilities

Layer / File(s) Summary
File operation APIs
crates/vfox/Cargo.toml, crates/vfox/src/lua_mod/file.rs, crates/vfox/types/mise-plugin.lua, docs/plugin-lua-modules.md
The Lua file module adds sorted directory listings, glob matching, and path moving. Tests cover filtering, ordering, and directory moves.
Archive decompression options
crates/vfox/src/lua_mod/archiver.rs, crates/vfox/types/mise-plugin.lua, docs/plugin-lua-modules.md
archiver.decompress validates arguments and paths, supports strip_components values of 0 or 1, promotes extracted entries, and returns Lua errors for collisions and unsupported formats. Tests cover extraction, collision handling, pcall, and error reporting.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LuaCaller
  participant archiverDecompress
  participant decompressArchive
  participant DestinationFilesystem
  LuaCaller->>archiverDecompress: Provide archive, destination, and options
  archiverDecompress->>decompressArchive: Validate paths and detect format
  decompressArchive->>DestinationFilesystem: Extract archive to temporary directory
  archiverDecompress->>DestinationFilesystem: Promote entries into destination
  archiverDecompress-->>LuaCaller: Return success or Lua error
Loading

Poem

I’m a rabbit with paths in a row,
Listing and globbing where they go.
Archives lose one root during the spin,
Collisions and errors report before moves begin.
Safe Lua calls let calm hops begin.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding Lua archive and file operations to vfox.

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.

@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR expands the vfox Lua API with portable archive flattening and filesystem operations while replacing unsupported-archive panics with Lua errors.

  • Adds optional strip_components = 1 archive extraction with collision preflight and explicit root-file retention.
  • Adds sorted file.list and file.glob operations plus file.move.
  • Updates LuaCATS definitions, documentation, dependencies, and unit coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the sole previous finding was invalidated by the documented parity contract and explicit regression coverage.

Important Files Changed

Filename Overview
crates/vfox/src/lua_mod/archiver.rs Adds validated archive options, error-based unsupported-format handling, temporary extraction, flattening, collision checks, and focused tests.
crates/vfox/src/lua_mod/file.rs Exposes sorted directory listing and glob matching alongside file and directory moves, with integration coverage.
crates/vfox/types/mise-plugin.lua Extends LuaCATS declarations for the new filesystem APIs and archive options.
docs/plugin-lua-modules.md Documents raised archive errors, root-file retention during flattening, and the new file operations.
crates/vfox/Cargo.toml Adds the existing workspace-resolved glob crate as a direct vfox dependency.
Cargo.lock Records glob as a direct dependency of the vfox package without changing its resolved version.

Reviews (3): Last reviewed commit: "fix(vfox): reject archive strip collisio..." | Re-trigger Greptile

Comment thread crates/vfox/src/lua_mod/archiver.rs Outdated
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Instruction counts

benchmark trend instructions Δ wall (min) Δ
env ▂▄▂▁▁▂▄▃▄█ 80,074,952 → 80,177,870 +0.13% 17.64 → 17.95ms +1.76%
hook-env █▇▁▄▃▂▅▄▆▄ 82,190,914 → 82,146,142 -0.05% 18.34 → 18.87ms +2.90%
ls ▆▄▁▁▂███▇█ 73,127,800 → 73,144,952 +0.02% 15.71 → 16.66ms +6.01%
registry ▁▂▃▂▃▆▆█▂▁ 49,102,713 → 49,080,229 -0.05% 11.64 → 12.15ms +4.37%
startup ██▁▆▅▂▃▅▆▅ 15,784,751 → 15,782,665 -0.01% 9.04 → 9.20ms +1.75%

No instruction-count regression above 1%.

Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run.

Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes.

0422b7221f55 vs e5230aa14775 · measured on the runner, not pushed to the history.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/vfox/src/lua_mod/file.rs`:
- Around line 82-84: Prevent stripped archive entries from overwriting existing
destinations by adding a collision check in the strip-and-move flow in
crates/vfox/src/lua_mod/archiver.rs lines 46-83 before invoking move_path;
reject the operation with an appropriate error when the destination already
exists. crates/vfox/src/lua_mod/file.rs lines 82-84 requires no direct change,
and docs/plugin-lua-modules.md lines 538-549 requires no direct change because
the behavior is addressed in the archiver.

In `@docs/plugin-lua-modules.md`:
- Around line 448-456: Update the async archiver.decompress calls in the
neighboring basic-extraction examples, the strip_components example, and the
Real-World Example to use pcall with await, checking the success result and
raising the captured error when decompression fails instead of treating errors
as return values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 104eab96-08db-4d34-9643-1a6ef908fc9c

📥 Commits

Reviewing files that changed from the base of the PR and between 96b1462 and d17bc85.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • crates/vfox/Cargo.toml
  • crates/vfox/src/lua_mod/archiver.rs
  • crates/vfox/src/lua_mod/file.rs
  • crates/vfox/types/mise-plugin.lua
  • docs/plugin-lua-modules.md

Comment thread crates/vfox/src/lua_mod/file.rs
Comment thread docs/plugin-lua-modules.md Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e1c3cfe. Configure here.

Comment thread crates/vfox/src/lua_mod/archiver.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
crates/vfox/src/lua_mod/archiver.rs (2)

158-179: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover root-level files through the public Lua API.

This test invokes strip_archive_path_components directly. Add an integration fixture containing both a root-level file and a nested file, then call archiver.decompress with strip_components = 1. Keep this unit test for focused promotion coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/vfox/src/lua_mod/archiver.rs` around lines 158 - 179, Add an
integration fixture containing both a root-level file and a nested file, then
exercise the public Lua API through archiver.decompress with strip_components
set to 1 and assert both files are promoted correctly. Keep
test_strip_components_preserves_root_files unchanged as focused unit coverage.

21-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for the new Lua argument errors.

The branches at Line 21 through Line 44 handle missing arguments, invalid options, and unsupported strip_components values. Add Lua-level tests for each branch and assert the error text.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/vfox/src/lua_mod/archiver.rs` around lines 21 - 44, Add Lua-level
regression tests covering archiver.decompress with missing archive/destination
arguments, a non-table options value, and strip_components values greater than
1. Assert each failure returns the exact error text emitted by the corresponding
branches in the decompress argument parsing flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/vfox/src/lua_mod/archiver.rs`:
- Around line 59-62: Update the archive extraction flow around
strip_archive_path_components so promotion into destination cannot leave
partially committed entries when a move fails. Plan and validate all moves
before modifying destination, or stage the complete result and atomically
replace destination while preserving its existing contents.

---

Nitpick comments:
In `@crates/vfox/src/lua_mod/archiver.rs`:
- Around line 158-179: Add an integration fixture containing both a root-level
file and a nested file, then exercise the public Lua API through
archiver.decompress with strip_components set to 1 and assert both files are
promoted correctly. Keep test_strip_components_preserves_root_files unchanged as
focused unit coverage.
- Around line 21-44: Add Lua-level regression tests covering archiver.decompress
with missing archive/destination arguments, a non-table options value, and
strip_components values greater than 1. Assert each failure returns the exact
error text emitted by the corresponding branches in the decompress argument
parsing flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 618c3d42-73e5-4d88-9c17-631d4f04bd83

📥 Commits

Reviewing files that changed from the base of the PR and between d17bc85 and e1c3cfe.

📒 Files selected for processing (3)
  • crates/vfox/src/lua_mod/archiver.rs
  • crates/vfox/types/mise-plugin.lua
  • docs/plugin-lua-modules.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/vfox/types/mise-plugin.lua
  • docs/plugin-lua-modules.md

Comment thread crates/vfox/src/lua_mod/archiver.rs
@jdx
jdx enabled auto-merge (squash) August 3, 2026 01:35
@jdx
jdx merged commit db20af7 into main Aug 3, 2026
32 checks passed
@jdx
jdx deleted the agent/lua-file-archive-operations branch August 3, 2026 01:40
donbeave pushed a commit to donbeave/mise that referenced this pull request Aug 3, 2026
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.

1 participant