Repository navigation
feat(cli): interactive --select and manifest cache for bundle pull - #2109
Conversation
Add two features to `decdn bundle pull`, aimed at the case where you don't know a bundle's contents up front and don't want to re-pay for work already done. --select opens the (post-`--include`/`--exclude`) file list in the user's editor ($VISUAL/$EDITOR/vi). Commenting out (`#`) or deleting a line skips that file; save-and-exit pulls the rest. It composes with the glob filters, requires an interactive terminal, and refuses `--json` / `--dry-run`. An edited line that matches no entry aborts (a typo must not silently drop a file), and paths that cannot round-trip through the buffer (`#`-leading or tab-containing) are refused with a pointer to the glob flags. The bundle-manifest cache stores each fetched `--hash` manifest verbatim at `<out>/.decdn-bundles/<hash>.json`, next to `.decdn-manifest.json`. The manifest blob is a paid `cdn/client/v1` fetch, so a repeat pull of the same bundle into the same directory now re-reads it from disk instead of paying again. The cache is hash-keyed (no clobber across bundles), self-verifying on read (a corrupt or tampered file is ignored and the manifest re-fetched), and advisory (a write failure is logged, never fatal). `--overwrite` forces a fresh fetch. The "nothing to fetch" message now names its cause (empty bundle, filtered out, or deselected) instead of always blaming the filters. No new dependencies. Decision logic (render/parse/selectable/editor resolution and the cache) is pure and unit-tested; only the editor spawn is I/O glue. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
There is a correctness issue in --select path representability checks (leading-whitespace-then-# can be silently dropped) plus newly introduced documentation mismatches that should be fixed before approval.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (3)
What changed in this PR
This PR enhances decdn bundle pull for exploratory and repeat pulls by adding an interactive --select step (editor-driven file list trimming) and a local, hash-keyed manifest cache to avoid re-paying for manifest fetches on repeated --hash runs.
Changes:
- Add
--selectflag to open the filtered manifest entry list in$VISUAL/$EDITORand apply the edited selection. - Cache
--hashmanifest blobs under<out>/.decdn-bundles/<hash>.json, with self-verification on read and best-effort writes. - Improve “nothing to fetch” messaging by distinguishing empty bundle vs filtered-out vs deselected.
| File | Description |
|---|---|
| crates/common/src/cli/bundle.rs | Adds the --select CLI flag and clippy expectation for the expanded bool flag set. |
| crates/cli/src/commands/mod.rs | Exposes the new bundle_cache module. |
| crates/cli/src/commands/bundle_pull.rs | Implements interactive selection, early flag/TTY guards, manifest caching integration, and refined empty-result messaging. |
| crates/cli/src/commands/bundle_cache.rs | Implements the on-disk manifest cache (hash-keyed, self-verifying, advisory writes) with unit tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Address Copilot review on #2109. - check_selectable now rejects every path that cannot round-trip through the editor buffer exactly: leading/trailing whitespace (which parse_selection trims) and whitespace before a leading '#' (which would read as a comment and silently drop the file), in addition to a literal leading '#' and tab/newline. Previously " #foo" was silently dropped. - editor_command/edit_in_editor docs no longer claim git-style parsing; they state the actual behavior (ASCII whitespace split, no shell quoting). - Remove the stranded by_filter doc block above NothingReason; its docstring now describes the current enum. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Coverage reportTotal: 83.70% (was 83.74%, ▼ 0.04%) — 86775/103675 lines
History
|


What
Two additions to
decdn bundle pull, for the case where you don't know a bundle's contents up front and don't want to re-pay for work already done.--select— interactive file selectionOpens the file list in your editor (
$VISUAL→$EDITOR→vi), onepathper line. Comment out (#) or delete a line to skip that file; save and exit to pull the rest.--include/--exclude: the editor shows the already glob-filtered list, so use it alone (see everything) or to trim what a glob left.--jsonand--dry-run.#-leading or tab-containing) are refused with a pointer to the glob flags.Bundle-manifest cache — "don't pay again"
The
--hashmanifest blob is a paidcdn/client/v1fetch, so re-pulling the same bundle re-paid for it every run. Now each fetched manifest is cached verbatim at<out>/.decdn-bundles/<hash>.json, beside.decdn-manifest.json.--overwriteforces a fresh fetch, consistent with how it bypasses the file skip-cache.A repeat
--hashpull now does zero paid manifest fetches, and--selecton that repeat run opens instantly from the cached list — including re-adding files excluded on a prior run.Also
The "nothing to fetch" message now names its cause (empty bundle / filtered out / deselected) instead of always blaming the filters.
Why
--selectanswers "I don't know what this bundle holds — show me and let me#out what I don't want," rather than forcing blind--include/--excludeglobs. The cache applies the project's "all byte transfers are paid" principle to the manifest itself.Notes for reviewers
blake3/tempfile), so no crate-edge or cargo-deny impact.render_selection/parse_selection/check_selectable/editor_commandinbundle_pull.rs, and the wholebundle_cachemodule. Only the ~15-line editor spawn is I/O glue.--hash-only: an-ilocal manifest is already on disk for free.Verification
cargo fmt --check,cargo clippy --all-targets --all-features(the-D warningsgate), andRUSTDOCFLAGS="-D warnings" cargo docall clean.cargo nextest run -p decdn-cli -p decdn-common— 1233 tests pass.🤖 Generated with Claude Code