Skip to content

feat(cli): interactive --select and manifest cache for bundle pull - #2109

Merged
alpergundogdu merged 2 commits into
mainfrom
claude/bundle-pull-vim-file-list-65916a
Sep 22, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
claude/bundle-pull-vim-file-list-65916a

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

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 selection

Opens the file list in your editor ($VISUAL → $EDITOR → vi), one path per line. Comment out (#) or delete a line to skip that file; save and exit to pull the rest.

  • Composes with --include/--exclude: the editor shows the already glob-filtered list, so use it alone (see everything) or to trim what a glob left.
  • Guards up front, before any paid work: requires an interactive TTY; refuses --json and --dry-run.
  • Safety: an edited line matching no bundle entry aborts (a typo must not silently drop a file). Paths that can't round-trip through the buffer (#-leading or tab-containing) are refused with a pointer to the glob flags.

Bundle-manifest cache — "don't pay again"

The --hash manifest blob is a paid cdn/client/v1 fetch, 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.

  • Hash-keyed — two different bundles pulled into one directory don't clobber each other.
  • Self-verifying on read — re-hashes the bytes and ignores a corrupt/tampered file (re-fetches fresh); trustless since content is BLAKE3-addressed.
  • Advisory — a write failure is logged, never fatal.
  • --overwrite forces a fresh fetch, consistent with how it bypasses the file skip-cache.

A repeat --hash pull now does zero paid manifest fetches, and --select on 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

--select answers "I don't know what this bundle holds — show me and let me # out what I don't want," rather than forcing blind --include/--exclude globs. The cache applies the project's "all byte transfers are paid" principle to the manifest itself.

Notes for reviewers

  • No new dependencies (reuses blake3/tempfile), so no crate-edge or cargo-deny impact.
  • Decision logic is pure and unit-tested: render_selection / parse_selection / check_selectable / editor_command in bundle_pull.rs, and the whole bundle_cache module. Only the ~15-line editor spawn is I/O glue.
  • Cache scope is deliberately --hash-only: an -i local manifest is already on disk for free.

Verification

  • cargo fmt --check, cargo clippy --all-targets --all-features (the -D warnings gate), and RUSTDOCFLAGS="-D warnings" cargo doc all clean.
  • cargo nextest run -p decdn-cli -p decdn-common — 1233 tests pass.

🤖 Generated with Claude Code

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]>
Copilot AI lite review requested due to automatic review settings September 22, 2026 11:23

Copilot AI 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.

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 Medium severity · 1 Low severity

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 --select flag to open the filtered manifest entry list in $VISUAL/$EDITOR and apply the edited selection.
  • Cache --hash manifest 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.

Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
Comment thread crates/cli/src/commands/bundle_pull.rs Resolved
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]>
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 83.70% (was 83.74%, ▼ 0.04%) — 86775/103675 lines

File Coverage Lines Δ
crates/cli/src/commands/bundle_cache.rs 94.83% 55/58 new
crates/cli/src/commands/bundle_pull.rs 71.62% 2794/3901 ▼ 0.41%
History
Commit Total Δ vs base
6e33467 (HEAD) 83.70% ▼ 0.04%

@alpergundogdu
alpergundogdu merged commit 67edb49 into main Sep 22, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/bundle-pull-vim-file-list-65916a branch September 22, 2026 12:51
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