Commit Graph
3 Commits
Author SHA1 Message Date
yetone 178a781ff9 library: a skill made again under the same name after its repo's copy was deleted is filed under 本机 (X: AzheRise)
AzheRise on X: a skill downloaded from a GitHub repository was deleted,
another of the same name was made in an agent's own folder
(~/.dsh/skills), and once brought into the Library it sat under the old
repository instead of This computer.

Cause: two records outlive the skill and are matched by name only.
- The skills CLI's lock (~/.agents/.skill-lock.json, or under
  $XDG_STATE_HOME) keeps an entry for a skill deleted by hand or from
  magpie. repoOf filed the library's own copy (a folder moved in) under
  the lock's repository by its name, and tracer.folder did the same for
  one in ~/.agents/skills, which importSkill then kept as From. On this
  machine's real lock, agent-browser is such an entry, with no folder.
- CC Switch's folder (~/.cc-switch/skills/<name>) outlives a copy of it
  deleted from the library. ccSwitchOrigin filed any later own copy of
  that name under CC Switch's repository, and made it "updatable", so
  Update would have put the repository's skill in place of the user's.
- Sibling: a removed skill stayed in the user's own group (SkillGroups),
  hidden only while no skill had its name, so a new one of that name came
  back in the group.

Fix:
- A lock entry counts for a folder only when the CLI wrote that folder: a
  file in it is no newer than the entry's updatedAt (else installedAt)
  plus a minute (lockRepo, madeBy). On this machine's 27 live entries the
  CLI's files are 0.4 to 2.8s older than updatedAt. A lock without times
  groups by name as before. Brought in from an agent's folder, a copy the
  CLI wrote is kept as From at once, so an edit later leaves it grouped.
- Existing data is judged again on every read: a moved-in copy has no
  From and goes through lockRepo, and a From that is the lock's
  repository for a folder in ~/.agents/skills the CLI didn't write is
  passed over (staleFrom). So the reporter's skill moves to This computer
  with no action.
- ccSwitchOrigin takes a library-own copy as CC Switch's only when its
  SKILL.md is CC Switch's own.
- removeSkill drops the skill from the user's groups.

Not changed: noteFrom's pack rule (a skill traced nowhere, of a name a
repository being installed from has, is grouped with it when the library
has others from there). That is by name on purpose (White Immortal's
edited older copies), and runs only when the user installs from or
regroups that repository, not on import. MCP servers, hooks and
subagents keep no origin by name (a server's icon is by what it runs).

Tests: TestDeletedSkillsLockNotInherited (the reporter's case, one made
in ~/.agents/skills, the CLI's --copy copy and linked skill, data as
brought in before, an edited CLI copy), TestUndatedLockStillGroups,
TestRemovedSkillLeavesItsGroup, TestCCSwitchNameNotInherited.

Run at 76c130b29 plus this change, through mote-run, and again after the rebase onto dd7442f28 (vet of internal/library for darwin, linux and windows, and its tests, ok in 165.9s): gofmt -l internal clean;
go vet -tags nogui ./... for darwin, linux and windows ok; go test
-tags nogui -count=1 ./internal/library ok (186.7s). The new tests and
TestSkillRepo*, TestCCSwitch* also pass on Windows (win-run).
Broken by hand: with the three source files back at 76c130b29, three of the
new tests fail (notes and shared filed under someone/skills, the CLI
copy given no From, the group keeping notes, the user's pdf with CC
Switch's origin and updatable); TestUndatedLockStillGroups passes, as it
should.
Not tried: a real npx skills add / delete / re-create in the GUI, real
CC Switch, the full go test ./... suite, a copy moved into the library
across disks before this change (its files' times are reset, so it is no
longer grouped by the lock).
2026-11-01 04:36:37 +08:00
yetone 033b17bafe library: every skill named in another script is listed, under its folder's name
4db65681c carries this commit's first message by mistake (another session's amend read it from a shared file); it holds none of this change, which is here.

tnt1223 on Discord: Library › Skills listed 16 skills for
https://github.com/asdfgh1445/ctf-super-hub, which has 35 (one folder each
at the top, 35 SKILL.md in its recursive tree, not truncated).

Cause: the listing found all 35, but nameFor made each SKILL.md's `name`
fit for a file name by dropping everything outside ASCII. "CTF•密码学" and
ten more became "CTF", "Strix•RCE 测试" and nine more "Strix", "头脑风暴"
nothing, and unhiddenFirst lists skills of the same name once, so 35
became 16. Not a depth limit, cap, pagination or truncated tree: the probe
downloads the tarball and walks it; a truncated tree and GitHub's rate
limit are already said (skilltree.go, fetch).

Fix: a declared name that would lose a letter or digit (another script)
or comes out empty goes by its folder's name, which a repository keeps
apart. An ASCII name goes as before ("My Skill" is still My-Skill), so a
skill installed from one is still the library's. A skill at a
repository's top now falls back to the repository's name (srcFolder),
not the temporary download folder; candidates takes that name from each
caller (probe, Group again, CC Switch origin, new-skill check).

Tests: TestSkillsNamedInAnotherScriptAllListed probes and installs from a
fake of the repository built from its real tree (35 folders, front matter
names as written at 7715719); TestSkillNameFallsBackToFolderOnlyWhenLettersAreLost
and TestSkillAtTheTopNamedInAnotherScript cover the rule and the top
folder. No network.

Run:
- mote: go vet ./internal/library; GOOS=linux and GOOS=windows go vet
  -tags nogui ./internal/library; gofmt -l internal docs (empty);
  go test ./internal/library -run 'TestSkillsNamedInAnotherScript|
  TestSkillNameFallsBack|TestSkillAtTheTop|TestRepoWithAPlugin|Probe|
  CCSwitch|Regroup|NewSkill|From' -count=1: ok.
- wsl-run (magpie-desktop): go test -tags nogui ./internal/library
  -timeout 45m -count=1: ok 94.9s.
- Live, sandbox HOME (the package's TestMain/testenv), a throwaway test
  calling ProbeSkills("https://github.com/asdfgh1445/ctf-super-hub")
  against the real GitHub: 35 candidates, each named by its folder,
  nothing left out. Not committed.

Broken by hand: nameFor using the declared name whenever it isn't empty
(the old rule): TestSkillsNamedInAnotherScriptAllListed lists 16 with
names CTF/Strix/..., and the rule test fails on "CTF•密码学" and
"Café notes". Restored, green.

Not tried: the full ./... suite (mote at load ~350 from other runs; only
internal/library changed); the GUI suite (no app.js change); Windows test
run; installing the real repository's skills into a real agent. Not
changed: two different skills declaring the same ASCII name in folders of
different names are still listed once, as copies of one skill are
(unhiddenFirst).
2026-10-29 14:39:57 +08:00
yetone d1fe7a32ae library: a skill CC Switch installed can be updated from GitHub — linked from ~/.cc-switch/skills it had no source, so it showed no update button; the repository and branch CC Switch recorded for it are read (read-only) from its database, and updating fetches the skill from there and makes it the library's own copy, leaving CC Switch's folder as it was 2026-09-25 21:34:02 +08:00