Repository navigation
Install skill references from the package root and record installed files - #3397
Conversation
|
Review Type: Initial Review Requirements Check (issue #3368)
I ran Code Review Findings Critical None. The deletion logic holds up.
I mutation-checked in a scratch copy:
Improvements
Nits
Answers to the specific questions
Recommendation: APPROVE. There are no blockers and this is a clear net improvement. The deletion guard is sound and well tested. Improvements 1 and 2 are cheap robustness fixes worth making in this PR or a fast follow-up. Improvements 3 and 4 are one-liners plus a test. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.
Address-review summary (round 1)Review verdict was APPROVE with no blockers. Commit Addressed
The two reproductions in the review were re-run against the real CLI with a scratch HOME after the fix: a read-only Skipped, with reasons
Verification
Re-Review DecisionDecision: RE-REVIEW NEEDED Rationale: Imp 1, 3 and 4 change install/uninstall behaviour (record write order, symlink policy, the |
|
Review Type: Re-Review Previous Review Summary: 4 improvements and 7 nits in the previous review. All 4 improvements are addressed correctly. Of the nits, 4 are addressed in code and 3 are skipped with reasons I accept (case-only rename on a case-insensitive filesystem, the Verified: Status of each previous finding
Findings Critical None. Improvements None. The changes I checked hold up. Answers to the specific questions
Nits
Two smaller observations, no action needed:
Test quality I mutated a scratch copy of
Recommendation: APPROVE No blockers. The deletion logic is sound and every behaviour change is pinned by a test that fails when it is reverted. Nits 1 to 3 are optional and can ride along or be dropped. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment, GitHub blocks self-approval). Full findings in the review comment above.
Address-review summary (round 2)The re-review of Addressed
Skipped
Verification
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: The reviewer approved with no critical findings or improvements. Both changes in |
…iles (closes #3368) Install every references/*.md in the skill being installed instead of naming references in each agent's shims. Each install writes .nodespace-install.json in the agent's install directory, listing exactly the files it wrote. Uninstall removes the files the record names; a reinstall removes any recorded file the new skill no longer ships. Entries are deleted only when they are regular files that resolve inside the install directory. An install with no record is read as the files installers wrote before records existed (PRE_RECORD_REFERENCES plus SKILL.md and the harness shim), for both uninstall and reinstall. uninstall takes the package root, and the CLI passes its --resource-root. The public skill repository's file list comes from the same directory, so the work-tracking playbooks SKILL.md links to are now installed and published. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…s, key installs on SKILL.md - A stale file that cannot be deleted during a reinstall stays in the record and is reported on stderr; the install carries on instead of aborting. The record is written once, after the stale pass. - A package without SKILL.md installs nothing and leaves an existing install and its record alone (previously only a package with no files at all did). - A recorded symlink is unlinked, never followed; a symlinked parent that leads outside the install directory is still refused. - Uninstall no longer crashes when the install directory is an emptied symlink, and prunes the directories of recorded files already deleted by hand. - A record-less uninstall no longer aborts when the package's references/ directory cannot be read. Not changed: a case-only rename of a shipped reference on a case-insensitive filesystem, and the stale comment in the release workflow (touching it would run every test tier for a comment). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…record-less uninstall - pruneEmptyParents leaves a symlinked directory alone. On Windows rmdir would remove the link itself even though the directory behind it is not empty. - A record-less uninstall that cannot read the package's references/ still removes the pre-record files, and now says on stderr that the cleanup is partial. Not changed: duplicate entries in a hand-edited record are rewritten as they were (cosmetic; real records never contain them). Co-Authored-By: Claude Sonnet 5 <[email protected]>
2573da2 to
e7677c0
Compare
Closes #3368
What changed
The skill installer no longer takes its reference files from a hand-kept list. It installs every
references/*.mdin the skill it runs from (the stagedresources/skill/, orpackages/skill/in a source checkout), and records what it wrote so uninstall and reinstall can remove exactly that.agents.ts: no agent'sshimsnames areferences/path any more. Antigravity'sshimsis now justSKILL.md.installer.tslistReferenceFiles(packageRoot): the sorted*.mdfiles directly under<packageRoot>/references/(not recursive), asreferences/<name>paths;[]when the directory is absent. Any other read error is rethrown, so an unreadable directory never reads as "no references" (which would make a reinstall delete every installed reference).install()copies the shims and every reference, deletes each file the previous record named that the new set does not contain (pruningreferences/if it ends up empty), then writes<installDir>/.nodespace-install.json({ "files": [...sorted relative paths] }). A stale file that cannot be deleted stays in the record and is reported on stderr instead of aborting the install.SKILL.mdinstalls nothing and leaves an existing install and its record alone (a skill is discovered bySKILL.md; a folder without one is not a skill).uninstall(targetAgents, packageRoot = PACKAGE_ROOT)removes exactly the recorded files and the record, then prunes only the directories those files leave empty, and the install directory once it is empty (fail-soft if that directory is a symlink).checkInstalledis unchanged...entries, directories, and files reached through a symlinked directory that leads outside are ignored.install.ts:uninstallnow gets the--resource-rootthe CLI already parses. The Claude Code plugin reconciliation (uninstall(['claude-code'])insideinstall) passes its ownpackageRoot.scripts/publish-skill-repo.ts:sharedShimPaths()is the shared shims (now onlySKILL.md) pluslistReferenceFiles(packages/skill), so the public repository is derived the same way.readSkillSource()returns the references as a map. The script does not read any extension input.packages/skill/README.mddescribes the install record.types.tsdocuments thatshimsno longer lists references.Behaviour change to note
SKILL.md's "Work tracking" line linksreferences/jira-playbook.md,linear-playbook.mdandspec-driven-playbook.md, but no agent'sshimslisted them, so both the installed skill and the public repository linked to files that were not there. Taking the list from the directory means those three playbooks are now installed and published (six references instead of three). The PTY-session embed inpackages/agentalready wrote all six.Reviewer decision: installs without a record (option A chosen)
Most installs predate the record (
skill_installedmakes the first-launch install run once), so I took the recommended option A: a missing record is read as the files the pre-record installer wrote (SKILL.md, the agent's harness shim, and the exportedPRE_RECORD_REFERENCES:cli.md,shared-workspaces.md,graph-authored-guidance.md). The constant's doc says it covers installs made before the record existed and can be deleted once those are gone. If you prefer option B, deletePRE_RECORD_REFERENCES,preRecordFiles, and the four tests that name them.One extension beyond the issue text, worth a look: I applied the same reading on reinstall, not only on uninstall. Without it, a reinstall over a record-less install writes a record that omits a legacy reference the new skill no longer ships (say
shared-workspaces.md), leaving that file behind for good; a later uninstall would then keepreferences/and strand the install directory, the case the record exists to prevent. With it, the first reinstall cleans the legacy file. This is under option A only.Deviations from the issue and the code as found
listReferenceFilesreturnsreferences/<name>paths rather than bare names, so install, the record,PRE_RECORD_REFERENCESand the publish list all share one spelling.installedName()is deleted. With noreferences/shims,basename(shim)is the whole rule, and the record replaces the install/uninstall-must-agree problem it documented. Directory pruning now walks up from each deleted file (leaf-upward), which also retires the "deeper shim strandsreferences/" caveat in the old comment.SKILL.mdinstalls nothing and leaves the existing install and its record alone instead of diffing against a partial set: a broken package root must not wipe or half-replace a working install../SKILL.md) can never delete a file the same install just wrote.README.mdinpackages/skillhad a sentence saying the public repository gets onlyreferences/cli.md; updated, plus a short note on the record.Ratchet
bun run scripts/check-pro-boundary.tsexits 0, and the count table on this branch is identical to the table on its merge-base (checked against a checkout of the merge-base itself): 271 / 368 / 95 / 81 / 54 / 104 / 203 / 0 / 72 / 463 / 275 / 18 in marker order (proCommandsthroughproNamedFiles). This PR adds and removes no marker, andBASELINESis untouched. (Several counts are below their baselines because other PRs have lowered them; the final tightening issue owns that.)Tests
bun run test:changed(skill, scripts and Rust tiers) passed on the final head, including the Rust workspace under nextest. Skill package: 131 tests. Scripts: 970 tests.tscforpackages/skill(src and shims) andscripts/is clean.New tests in
packages/skill/src/tests/installer.test.ts, each mutation-checked by reverting the matchinginstaller.tschange and confirming it fails:references/*.md, including one no agent config namesinstallreferences/when none remain; leaves a user's own file alone)shimsnor the package names) and the record, leaving no directoryreferences/, soreferences/and the install directory stay../outside.md(also an absolute path, a directory, and a path through a symlinked directory) is never deleted, on uninstall and on reinstallAdded after review: a failed stale delete stays recorded and warns (mocked
rmSync); an emptied symlinked install directory does not crash uninstall or skip the next agent; a recorded symlink is unlinked and its target survives; a package withoutSKILL.mdleaves the install alone; recorded files deleted by hand still get their directories pruned; a record-less uninstall survives an unreadable packagereferences/and says the cleanup was partial; pruning never removes a symlinked directory (Windowsrmdirsemantics emulated).Also added:
listReferenceFilescases (sorted under a reversedreaddir, non-recursive,.mdonly, missing/non-directory, read errors rethrown with installed references left in place); reinstall over a record-less install (the option A extension); an install that writes nothing leaves the install alone; a differently spelled record entry is not treated as stale; malformed or non-string records fall back to no record; record-less uninstall also removes references the package root ships; the plugin-managed cleanup passespackageRoot; a record-only directory is not "installed"; installing from the realpackages/skillputs every reference in place and everyreferences/...link in the installedSKILL.mdresolves; andinstall.test.tsspawns the real CLI with a scratchHOMEto proveuninstallreceives--resource-root.In
scripts/publish-skill-repo.test.ts: the expected lists are nowSKILL.mdplus the six references, every reference is copied verbatim, and everyreferences/...link in the publishedSKILL.mdresolves to a published file.Mutation results: 42 mutations run (
installer.ts,agents.ts,package.json,install.tsandpublish-skill-repo.ts, several variants per guard). 41 are caught by the tests named above. The one that is not is an equivalent mutant: dropping the explicitArray.isArraycheck on the record'sfilesstill yields "no record", because the surroundingtry/catchalready turns.filteron a non-array into "no usable record".Verified against the real installer
Built with
bun run scripts/build-skill.tsand ran the compilednodespace-skill-installeragainst the stagedresources/skillwith a scratchHOME(env -i, nothing under the real~/.claude,~/.codexor~/.geminiwas touched):resources/skill/references/is identical topackages/skill/references/(six files, unchanged by this PR).installput all six references plus the shim in each of claude-code, codex and antigravity, and wrote the record.jira-playbook.mddeleted it and updated the record.uninstallremoved the recorded files and the record, kept a user'sreferences/my-notes.mdand its directories.uninstall --resource-root <root that ships no references>.bun run skill:check(the cargogen_skill_md --check) was not run separately:SKILL.mdis not modified.Risks and rollback
SKILL.mdalready links them.SKILL.md, so it is inert there..nodespace-install.jsonbehind and keeps the install directory; delete that file by hand if needed.🤖 Generated with Claude Code