fix(skill): preserve custom installed instructions - #96
Open
NianJiuZst wants to merge 2 commits into
Open
Conversation
NianJiuZst
marked this pull request as ready for review
August 17, 2026 07:20
Collaborator
|
A very good PR, but we need to fix the bug where users who haven't upgraded to the latest version will never be able to upgrade automatically again, the cleanest solution is to prepare a historical fingerprint for the "no marker" case |
Before .bsk-source markers existed, any user who installed via the bundled bsk CLI had a plain SKILL.md on disk. The new marker-aware sync then refused to overwrite that file as long as its content differed from the current bundle, so users were silently frozen on their first-ever install until they manually reran bsk install-skill. Recognise legacy bundled installs by hashing their on-disk content and comparing against the SHA-256 digests of every SKILL.md that bsk ever shipped. When the on-disk content matches the current bundle, stamp a bundled marker and report UpToDate. When it matches a historical fingerprint, atomically rewrite to the current bundle, stamp a fresh bundled marker, and report Updated. Anything else stays Preserved as before.
NianJiuZst
force-pushed
the
codex/preserve-custom-skill-source
branch
from
August 20, 2026 05:53
a3eaabc to
25af5c5
Compare
NianJiuZst
commented
Aug 20, 2026
NianJiuZst
left a comment
Contributor
Author
There was a problem hiding this comment.
Thanks for the catch. You're right — anyone who installed before .bsk-source markers existed would be frozen on their first-ever bundled SKILL.md because the new marker-aware sync refused to overwrite a differing file. Now fixed.
What changed in this update:
- Added
HISTORICAL_BUNDLED_FINGERPRINTS: &[&str]incrates/bsk-cli/src/skill_install/sync.rscontaining the SHA-256 hex digests of everySKILL.mdever shipped in this repo (initial public release throughfeat(session): support unfocused agent windows --no-focus #87, i.e. the same content as the current bundledSKILL.md). - Extended the marker-less branch of
sync_one: when there's no marker, hash the on-disk content and adopt as managed if it matches either the current bundle or any historical fingerprint. Matching the current bundle stamps a bundled marker and reportsUpToDate; matching a historical fingerprint atomically rewrites to the current bundle, stamps a fresh bundled marker, and reportsUpdated. Anything else still goes toPreserved(unrecognised manual edits remain untouched). - Refactored
sync_oneto share the atomic-replace + marker-refresh path between stale-managed upgrades and legacy-bundled adoptions (extracted into a smallatomic_replaceclosure). - Updated
SyncReport::preserved's docstring accordingly. - New unit test
sync_adopts_markerless_legacy_bundle_and_upgrades_itwrites the real initial-releaseSKILL.mdcontent (sha25628d39215...d4a3e1bc5a, exactly matching the list entry) without a marker, syncs against a new bundle, and asserts the file was upgraded and a fresh bundled marker was stamped. The existingsync_preserves_custom_edited_and_unknown_skills,sync_adopts_markerless_current_bundle_then_updates_it,sync_updates_outdated_skill, etc. all still pass.
New head: 25af5c5 (rebased onto current main@6b78211).
Verified locally after the rebase:
cargo test -p bsk --locked --lib skill_install::sync— all 7 tests pass, including the new one.cargo clippy -p bsk --all-targets --locked -- -D warnings— clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SKILL.mdcame from the bundled source or--sourcebsk doctorWhy
bsk install-skill --source ...installs user-owned instructions, but daemon startup currently rewrites every differingSKILL.mdwith the bundled copy. Starting a session can therefore silently destroy custom instructions.The sidecar marker is written fail-safe: custom ownership is recorded before content replacement, and bundled markers include the exact installed-content hash. A marker-less file is only adopted automatically when it exactly matches the current bundle.
Tests
cargo test -p bsk --lockedcargo clippy -p bsk --all-targets --locked -- -D warnings