Repository navigation
fix: upgrade-hosts refreshes Claude Code skills, agents and /slm-loop when there is no plugin - #333
Conversation
|
Audit findings, each reproduced with a failing test on 25bd183 before any fix, then fixed in e6f69ba. With the source reverted to 25bd183 and the new tests kept, 12 of them fail; with the fix, all pass.
Regression guards for the refresh of files SLM wrote: an untouched recorded file is still refreshed with its mode and CRLF bytes kept and no leftover temp or backup; a refresh through a link that stays inside Verification: the two PR test files (46 tests) pass; the wider hooks, cli, packaging, release, plugin and upgrade packs pass (2635 passed, 12 skipped). Known limit: a rename-based write cannot close the instant between the final re-read and the rename without a lock an editor would ignore; that window is now microseconds instead of the whole run. |
… when there is no plugin On a Claude Code wired without the plugin, `slm upgrade-hosts` looked only at the hook entries in settings.json and printed "already current" while every skill and advisor was from the release that installed it and newer skills were missing. It now also adds and refreshes the slm-* skills, the slm-* advisors and /slm-loop, names each file in the preview, and reports "already current" only when all of it is. A file SLM wrote and you did not change is refreshed. A file you changed after SLM wrote it is kept and named. A file from before SLM kept a record is replaced only by --apply, after a .bak-slm-<version> copy. A skill you deleted is not put back, and a path that resolves outside ~/.claude is reported and left alone. With the plugin installed ~/.claude is not touched. The once-per-version daemon step adds missing files and refreshes the ones SLM wrote and you did not change. Also fixes a KeyError that stopped `upgrade-hosts --host claude-code` when the plugin is installed, ships the Claude Code skills, agents and command in the wheel, and adds a `slm doctor` row for them. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… and finds skills-only Claude Code installs - A file you save while the upgrade runs is re-checked right before it is replaced and kept. - A failed write leaves no stray backup; identical backups are reused, not stacked. - A file that cannot be read is reported as an error and retried, not as "you changed it". - Backups are listed as paths under ~/.claude, one per file. - A folder where a skill file belongs is reported as blocked in preview and apply alike. - --all-detected now finds a Claude Code that has SLM skills but no hooks. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ory tools The sub-agents that slm upgrade-hosts and the daemon install without the plugin now name SLM tools as mcp__superlocalmemory__<tool>, generated from the shared plugin-src agents, so an advisor that already works is left byte-identical. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
e6f69ba to
147c10b
Compare
|
Audit finding: the advisors this PR installed into ~/.claude/agents were copied from plugin-src, which names SLM tools bare. Claude Code resolves sub-agent tools by full name only, and a plugin-less install reaches SLM as a direct MCP server, so with adopt_unrecorded a working agent using mcp__superlocalmemory__ names would have been backed up and replaced by one with no memory tools (the bug #330 fixed). Fix: commit 147c10b. A new generated tree, claude-code-assets/agents, is built from plugin-src/agents by the existing directAgentTools transform in scripts/agent-tool-names.mjs (same output as the Muse build). It is a step in build-all-plugins, covered by --check and the plugin-drift CI paths. The wheel's data-files and the checkout both read it; plugin-src/agents is never installed. The installer also refuses any agent that still names an SLM tool bare. Rebased onto main. Tests: tests/test_hooks/test_claude_code_assets.py (installed agents carry only direct registered tool names; a current direct-form agent stays byte-identical with no backup; older direct agent refreshes to direct form; daemon step; bare-name source refused; LF and posix manifest keys), tests/test_plugin/test_claude_agent_tool_names.py (generated tree in sync, equals the JS transform and the Muse output), tests/release/test_artifact_contract.py (agent bytes inside the built wheel). Reverting the fix makes 7 of the new tests fail. |
Symptom
On a Claude Code wired without the plugin (MCP server and hooks in
~/.claude/settings.json, skills in~/.claude/skills/slm-*, advisors in~/.claude/agents/slm-*.md,/slm-loopin~/.claude/commands),slm upgrade-hostsprinted:while every skill and advisor was still the 4.1.24 text and four newer skills (
slm-media,slm-web-access,slm-bot-memory,slm-getting-started-bot) were missing. For Codex the same command does refresh skills. A second defect on the same path: with the Claude Code plugin installed,slm upgrade-hosts --host claude-codecrashed withKeyError: 'plugin-managed'.Cause
_upgrade_host("claude-code")only called the settings.json hook merge, so the line reported on hooks alone. Nothing in the package ever wrote Claude Code skills, agents or commands after the first install, and the wheel did not ship them (itsshare/held onlycodex/andportable-kit/). Theplugin-managedandchanged-meanwhileresults of the hook merge had no entry in the status tables.Fix
hooks/claude_code_assets.py. It owns only theslm-*skills,slm-*advisors andslm-loopcommand that the release ships, and decides who wrote a file from a digest manifest (~/.claude/.slm-managed.json), the way the Codex installer does:--apply, after the old copy is saved as<name>.bak-slm-<version>;~/.claude(linked checkout, dotfiles-managed skills folder): reported and left alone;~/.claudeis not touched.upgrade-hosts(preview and--apply) now runs hooks and assets together, lists every file it would add or refresh, and prints "already current" for the skills/agents/commands part only when they match. The line reports the worst of the two parts.--apply, which keeps a backup), and it is covered by the existing marker, opt-out and kill switch.pyproject.tomlshipsshare/superlocalmemory/claude-code/{skills,agents,commands}.slm doctorhas a "Host assets" row (read-only) for the same check.plugin-managedandchanged-meanwhileto the upgrade line's status tables.docs/host-upgrades.mdand the wiki page.Comparison with Codex: Codex overwrites its skill files without a record and protects only agent files. This keeps one rule for all three kinds and adds a backup for the one case where it cannot tell SLM's copy from a hand edit.
Tests
tests/test_hooks/test_claude_code_assets.py(20 tests) andtests/test_cli/test_upgrade_hosts_claude_assets.py(10 tests), all on a temp HOME: stale skill refreshed, new skill added, edited file kept, backup content checked, outside symlink (file and folder) untouched, plugin case leaves the tree byte-identical, "already current" only when everything matches, removed skill not re-added, non-SLM files untouched, CRLF compared as bytes, unwritable target is an error not a crash, once-per-version daemon step, drift guard betweenplugin-srcandpyproject.toml, installed-layout lookup.tests/release/test_artifact_contract.py: the built wheel contains all 21 files (ran with-m slow, passes). Also installed the built wheel into a clean venv with no checkout:source_root()resolves to the installedshare/.../claude-codeand 21 files install into an empty.claude.host_upgrades.pyreverted tomain, 8 of the 10 new CLI tests fail. Restored, all pass.Not in this PR
No CHANGELOG entry:
test_changelog_starts_with_the_current_package_versionrequires the top section to be the current version, so the entry belongs in the release commit.🤖 Generated with Claude Code