Skip to content

skills: prompt before fetching so declined skills aren't downloaded - #253

Open
xsh310 wants to merge 2 commits into
databricks:mainfrom
xsh310:skills-dedup-before-fetch-main
Open

skills: prompt before fetching so declined skills aren't downloaded#253
xsh310 wants to merge 2 commits into
databricks:mainfrom
xsh310:skills-dedup-before-fetch-main

Conversation

@xsh310

@xsh310 xsh310 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Problem

In ucode configure skills download mode, the overwrite dedup prompt runs after the bytes are already downloaded. download_skills fetches every skill's full bundle up front via _fetch_bundles, then prompts per-skill at write time inside write_skill. Declining a skill (or hitting an invalid leaf name) throws away a download that already completed — wasted work that scales with how much the user already has on disk (the common re-download case).

Change

Move the disk-only checks (overwrite prompt + invalid-name skip) ahead of the fetch:

  • Extract existing_skill_on_disk(roots, leaf) — a small reusable existence check.
  • Split write_skill into should_download_skill(roots, leaf, *, location) (the decision — invalid-name skip + overwrite prompt, needs no bytes) and a pure write_skill(roots, leaf, files) writer.
  • In download_skills, filter each schema's leaves through should_download_skill first, then fetch only the survivors.

The per-schema parallel fetch (_fetch_bundles ThreadPoolExecutor) and the sequential for location in locations loop are unchanged. Because locations are still processed one at a time, a same-named skill from a later location still sees the earlier one on disk and prompts — cross-location overwrite behavior is preserved.

Tests

  • New test_declined_skill_is_not_fetched asserts fetch_skill_bundle is never called for a declined skill and the existing copy is untouched (the point of the change).
  • Prompt/keep/overwrite/invalid-leaf tests moved to TestShouldDownloadSkill; TestWriteSkill now covers the pure writer; added a direct existing_skill_on_disk test.
  • uv run pytest tests/test_skills_download.py → 33 passed. uv run ruff check → clean.

This pull request and its description were written by Isaac.

Comment thread src/ucode/skills_download.py Outdated
@xsh310
xsh310 marked this pull request as ready for review July 31, 2026 01:49
xsh310 added 2 commits July 31, 2026 22:20
Download mode fetched every skill's bytes up front, then prompted to
overwrite existing dirs at write time — so declining a skill threw away
an already-completed download.

Move the overwrite prompt and invalid-name check ahead of the fetch:
split write_skill into should_download_skill (the disk-only decision,
extracting existing_skill_on_disk) and a pure write_skill, and filter
each schema's leaves through the decision before _fetch_bundles runs.
The per-schema parallel fetch and the sequential location loop are
unchanged, so cross-location same-leaf overwrite prompting still works.
Address review nit — restructure the download_skills docstring into
explicit list/decide/fetch stages. Run ruff format to wrap an
over-length line in tests (fixes the test_ruff_format CI check).
@xsh310
xsh310 force-pushed the skills-dedup-before-fetch-main branch from 03c30d7 to 829d83a Compare July 31, 2026 22:23
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