Skip to content

fix: keep local edits when updating or installing skills - #89

Open
thekidnamedkd wants to merge 2 commits into
knoxgraeme:mainfrom
thekidnamedkd:fix/protect-local-edits
Open

thekidnamedkd wants to merge 2 commits into
knoxgraeme:mainfrom
thekidnamedkd:fix/protect-local-edits

Conversation

@thekidnamedkd

@thekidnamedkd thekidnamedkd commented Nov 1, 2026 •

Copy link
Copy Markdown

Summary

update and install reinstall a skill by replacing its directory, so local edits to an installed skill are lost without warning. This compares the installed files with what skillfish installed and holds back skills that changed. --force on either command keeps the current behavior.

The comparison hashes the directory the way git hashes a tree. New installs record that hash as contentSha, and a mismatch means the skill was edited.

Skills installed before this change have no contentSha, so their sha is the baseline. For a subdirectory skill that's the GitHub tree SHA of the directory, which equals the local hash of untouched files, so those still verify exactly. Two cases don't match:

  • GET /git/trees/{branch} returns the commit SHA in .sha, not the root tree SHA. Root-level skills store it after update, and so does any skill whose directory lookup missed. update looks up the skill's tree at that commit (one request per affected skill) and goes ahead if it matches.
  • Windows can't see executable bits, so skills with scripts won't match their stored tree SHA.

When an older baseline can't be matched, the skill is held with "May have local edits, installed by an older skillfish (use --force to update)" rather than reported as edited. After one --force update it has a contentSha and is checked exactly from then on.

What changes for users:

  • update holds edited skills and lists them in a new skipped field in --json output
  • install holds edited skills when their ref or source changes, and keeps edited skills that were removed from skillfish.json, with a warning
  • unedited skills behave as before, and add --force and remove are unchanged

update --json still exits 0 when it holds skills, the same as add does for skills that already exist. I can make that non-zero if you'd rather CI notice.

The commit SHA in .sha also makes root-level skills show as outdated right after add, since add stores the SKILL.md blob SHA and update compares it with the commit. I left that out because the fix depends on which SHA root-level skills should track. I can open a separate issue for it.

Related Issue

Fixes #88

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • New agent support (adds support for a new AI agent)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the project's style guidelines
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass (npm test)
  • The build succeeds (npm run build)
  • I have updated documentation if needed

Testing

  • integrity.test.ts checks computeTreeSha() against git write-tree (nested directories, git's sort order for directories, executable files), and covers getLocalEditStatus() for contentSha, older tree SHAs, root-level SKILL.md blob SHAs and commit SHAs
  • github.test.ts covers fetchCommitTreeSha(); manifest.test.ts and installer.test.ts cover validating and recording contentSha
  • npm test on Node 18, 20 and 22, plus lint, format check, typecheck and build
  • ran it against anthropics/skills and against root-level skill repos (for example DenisSergeevitch/repo-task-proof-loop) installed and updated with 1.0.39. Edited skills were held, and untouched ones updated, including stale installs whose manifest holds a commit SHA.

`update` and `install` reinstall a skill by replacing its directory, so
edits to an installed skill were lost without warning.

Compare a git tree hash of the installed directory with what skillfish
installed, and skip skills that changed unless --force is passed. Older
manifests need no migration: the GitHub tree SHA they store equals the
local tree hash of an untouched skill. New installs also record
contentSha.

Fixes knoxgraeme#88
Older manifests can store a commit SHA instead of a tree SHA: root-level
skills after `update` (GET /git/trees/{branch} returns the commit SHA in
`.sha`), and any skill whose directory lookup missed. No local content
hash can equal a commit SHA, so untouched skills read as edited and were
held forever.

For manifests without contentSha, a mismatch is now `unknown` rather than
`modified`, and the user is told the skill may have local edits. `update`
resolves a commit SHA to the skill's tree at that commit and proceeds when
it matches, so untouched skills update normally and record contentSha.

Refs knoxgraeme#88
@thekidnamedkd

Copy link
Copy Markdown
Author

Hi @knoxgraeme, #90 came in for #88 a couple of minutes after this one, from what looks like your issue automation. Could you let me know how you'd like to handle the overlap?

The main difference: #90 treats skills without a contentHash as unmodified, so anything installed before that release still gets overwritten on its next update. This PR protects those too. It hashes skill directories the way git hashes a tree, so the result can be compared with the sha already stored in every .skillfish.json, and skills it can't verify are held with a message instead of being overwritten.

I'm happy to go whichever way suits you. You could take this one, I could port the older-install handling onto #90, or I could trim this one down if it's more than you'd like to review.

More generally, I'd like to keep contributing, so it would help to know how outside PRs fit with the automation. Should I skip opening an issue first, or is there a better way to avoid duplicate work?

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.

update and install discard local edits to installed skills

1 participant