Repository navigation
fix: keep local edits when updating or installing skills - #89
thekidnamedkd wants to merge 2 commits into
Conversation
`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
|
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 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? |
Summary
updateandinstallreinstall 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.--forceon 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 theirshais 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 afterupdate, and so does any skill whose directory lookup missed.updatelooks up the skill's tree at that commit (one request per affected skill) and goes ahead if it matches.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
--forceupdate it has acontentShaand is checked exactly from then on.What changes for users:
updateholds edited skills and lists them in a newskippedfield in--jsonoutputinstallholds edited skills when their ref or source changes, and keeps edited skills that were removed fromskillfish.json, with a warningadd --forceandremoveare unchangedupdate --jsonstill exits 0 when it holds skills, the same asadddoes for skills that already exist. I can make that non-zero if you'd rather CI notice.The commit SHA in
.shaalso makes root-level skills show as outdated right afteradd, sinceaddstores theSKILL.mdblob SHA andupdatecompares 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
Checklist
npm test)npm run build)Testing
integrity.test.tscheckscomputeTreeSha()againstgit write-tree(nested directories, git's sort order for directories, executable files), and coversgetLocalEditStatus()forcontentSha, older tree SHAs, root-levelSKILL.mdblob SHAs and commit SHAsgithub.test.tscoversfetchCommitTreeSha();manifest.test.tsandinstaller.test.tscover validating and recordingcontentShanpm teston Node 18, 20 and 22, plus lint, format check, typecheck and buildanthropics/skillsand against root-level skill repos (for exampleDenisSergeevitch/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.