Skip to content

fix(sync): never delete or re-point entries skillshare did not create - #914

Merged
runkids merged 9 commits into
runkids:mainfrom
endgame302:fix/keep-unowned-entries
Nov 16, 2026
Merged

runkids merged 9 commits into
runkids:mainfrom
endgame302:fix/keep-unowned-entries

Conversation

@endgame302

@endgame302 endgame302 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)
  • Approved feature or large change (the linked issue has the approved label)

Linked Issue

No issue yet. I found this testing 0.30.7 / 0.30.8 on Windows 10 against a copy of a real ~/.claude/skills. I'm happy to open an issue first if you'd rather discuss the approach there.

Summary

On a plain init followed by sync, skillshare deleted or re-pointed entries in ~/.claude/skills that it never created (Windows, junctions). .skillshare-manifest.json already records what skillshare made, so these paths now check it:

 PruneOrphanLinks (entry no longer in source)
   link into source, broken           -> remove                          (unchanged)
-  link outside source, broken        -> remove
+  link outside source, broken        -> remove only if in manifest or --force; else keep + warn
   real dir in manifest               -> remove                          (unchanged)
-  real dir named like _repo / a__b   -> os.RemoveAll (name heuristic)
+  real dir named like _repo / a__b   -> keep + warn; --force removes

 SyncTargetMerge (same-name entry exists in target)
-  link points elsewhere              -> os.Remove + relink
+  link points elsewhere, not in manifest, outside source -> Skipped ("kept local"); --force relinks

 init (every first sync, not only --copy-from): replaceIdenticalCopies
-  identical copy in target           -> os.RemoveAll
+  identical copy in target           -> trash.MoveToTrash under replaced-by-init/<tool>/

Docs: understand/sync-modes.md already said unknown directories are preserved, and the code now matches it. The page also gets notes on broken links and other tools' same-name links. reference/commands/init.md mentions the trash.

Evidence

Sandbox setup: a throwaway HOME on D: holding copies of a real ~/.claude/skills, plus four canaries:

  • a hand-made team__shared with an extra file
  • a _drafts notes folder
  • a broken junction
  • a same-name xlsx junction into another manager's store

The same script ran with 0.30.7 and with this branch: init → install pdf → sync → disable/enable → install xlsx + docx → uninstall.

  • Before (0.30.7): net change after the run was 6 entries removed (team__shared and its 2 files, _drafts and its file, broken-link), and xlsx re-pointed from the other store to skillshare's copy.
  • After: 0 removed, 0 re-pointed. Sync prints, for example:
    ! team__shared: named like a skillshare folder but not in its manifest, kept (delete it yourself, or sync with --force)
    ! claude: kept local: docx, xlsx (sync --force replaces them)
    

Regression tests: internal/sync/ownership_test.go and cmd/skillshare/init_apply_trash_test.go make links with createLink, so they also run on Windows without Developer Mode (junctions).

TestPruneKeepsUnmanagedFoldersWithSkillshareLikeNames   main: FAIL   here: PASS
TestPruneKeepsBrokenLinkItDidNotCreate                  main: FAIL   here: PASS
TestSyncMergeKeepsSameNameLinkFromAnotherTool           main: FAIL   here: PASS
TestReplaceIdenticalCopiesMovesCopiesToTrash            main: FAIL   here: PASS
TestPruneForceStillRemovesSkillshareLikeNames           PASS on both (--force unchanged)
TestPruneRemovesBrokenLinkItCreated                     PASS on both (manifest path unchanged)
TestSyncMergeForceReplacesSameNameLinkFromAnotherTool   PASS on both

TestSyncTargetMerge_FixesBrokenLink now records the link in the manifest first, because a same-name link that skillshare did not make is no longer re-pointed.

Merge Danger

Door: two-way. There's no data migration, and reverting restores the old behaviour.

Blast Radius: narrow

Two groups see a change:

  • Users who relied on sync removing these entries silently: look-alike folders, broken links made by other tools, and other tools' same-name links now produce a warning or "kept local", and sync --force is needed to remove or replace them.
  • Very old installs: links that skillshare made before the manifest existed, and that now point outside the source, are kept until --force.

Checks

Run on a Windows 10 host, not in the devcontainer:

  • go vet and go build for ./internal/sync ./internal/trash ./cmd/skillshare
  • go test on the same packages: the same set of failures with and without this change, 90 in internal/sync + internal/trash and 21 in cmd/skillshare. Almost all are os.Symlink needing Developer Mode; the rest are Windows-environment tests. The 7 tests above pass.
  • python3 scripts/ai-context.py check

Not run: make check in the devcontainer (no Docker on this machine), tests/integration, and the UI tests.

Not covered:

  • Agent .md links. PruneOrphanAgentLinks still removes broken links it did not make, because agents have no link manifest.
  • A link the manifest records that another tool later re-pointed. It looks the same as a link left behind when the source moved, so sync still treats it as its own.
  • Dashboard: with Force on, the preview no longer lists look-alike folders that sync would remove; a kept link's row still reads "Edited in target"; Restore is still offered on replaced-by-init rows and shows the refusal.

Checklist

  • I've read CONTRIBUTING.md, including its AI-assisted contributions section (for the author to confirm)
  • I've reviewed every line of the diff and can explain it (for the author, before marking ready)
  • Tests included and passing (make check) — tests are included; make check was not run, see Checks
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

Written with AI assistance (Claude Code). It stays a draft until the author has reviewed it.

🤖 Generated with Claude Code

endgame302 and others added 2 commits November 15, 2026 00:45
On Windows, a plain `init` followed by `sync` deleted things in
~/.claude/skills that skillshare never created, with no backup and no
prompt. It also re-pointed another tool's junction. Seen in a sandbox
run of v0.30.7:

- prune removed real folders whose names only look like skillshare's
  flat naming (team__shared, _drafts), via the name heuristic
- prune removed a broken link that another tool or the user made
- merge sync deleted and re-created a same-name link that pointed into
  another manager's store
- init's import deleted original folders that matched the source
  byte for byte

The manifest already records what skillshare made, so use it:

- prune keeps a look-alike folder that is not in the manifest and warns
  once per sync; --force still removes it
- prune removes a broken external link only if the manifest records it
  (e.g. after the source moved); otherwise it keeps the link and warns
- merge sync re-points a link only if the manifest records it or it
  already points into the source; otherwise it reports the entry as
  kept local, as it already does for a real folder; --force replaces it
- init's import moves identical copies to the trash under
  replaced-by-init/<target>/ instead of deleting them

Tests: ownership_test.go adds regression tests that use createLink, so
they run on Windows without Developer Mode (junctions). The 4 keep
tests fail without this change. TestSyncTargetMerge_FixesBrokenLink now
records the link in the manifest first, since a same-name link that
skillshare did not make is no longer re-pointed. Existing tests in
internal/sync, internal/trash and cmd/skillshare show the same failures
on a Windows host with and without the change (symlink privilege). The
devcontainer suite has not been run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit makes sync and init leave alone entries skillshare
did not create. Update the pages that describe that behaviour:

- sync-modes: merge mode keeps a same-name link from another tool and
  reports it as local; orphan cleanup keeps folders that only look like
  skillshare's flat names, and broken links outside the source that the
  manifest does not record. sync --force still removes them.
- init: identical folders replaced with links during the first sync go
  to the trash first (replaced-by-init/<tool>/, cleaned after 7 days).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o longer needs

replaceIdenticalCopies now moves an identical copy to the trash instead
of calling os.RemoveAll, so TestRawWriteRatchet reports its allowance as
stale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@runkids runkids left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, and for the careful sandbox evidence. The direction is right: deleting a user's own team__x folder because of its name, or re-pointing another tool's link, is data loss, and the manifest is the right source of truth.

I ran the change in the Linux devcontainer image: go vet and go test ./internal/... ./cmd/... -count=1 both pass. tests/integration and Windows were not run on my side.

The skills merge path is fixed, but a few consumers still describe or do the old behaviour. Here is what I found, most important first.

Consumers that now disagree with sync

  1. Dashboard diff predicts the old behaviour. internal/server/handler_diff_stream.go:239-241 still predicts prune / "orphan managed directory" for an unmanaged team__x or _repo folder, which sync now keeps. Lines 196-200 still predict update / "symlink points elsewhere" for another tool's same-name link, which sync now reports as kept local.
  2. doctor recommends a fix that no longer works. cmd/skillshare/doctor.go (checkBrokenSymlinks, around line 1195) reports every broken link as an error and suggests skillshare sync to prune it. A broken link skillshare did not create is now kept, so doctor keeps failing and its suggestion never clears it. website/docs/reference/commands/doctor.md:303-307 says the same.
  3. TestSync_Pruning_RemovesBrokenExternalSymlinks no longer tests anything. tests/integration/sync_test.go:407 expects sync to remove a broken external link that is not in the manifest. The link is now kept, but the test still passes because sb.FileExists uses os.Stat, which returns false for a broken link. It should assert the link is kept (via Lstat), plus a manifest-recorded variant that asserts removal.
  4. Two paths still re-point links skillshare did not create. Copy mode (internal/sync/copy.go:154-160) removes any same-name link and writes a copy. Agent merge (internal/sync/agent_sync.go:140-156) re-points any same-name link to the source. Either cover them here, ideally through one shared "is this link ours?" helper used by skills merge, agents merge and copy mode (agents prune already has prunableLink), or list them under "Not covered" so the title's "never re-point" stays accurate.

replaceIdenticalCopies and the trash

  1. Restoring from the trash lands in the source. trash list shows the entry as replaced-by-init/claude/alpha. trash restore (CLI cmd/skillshare/trash.go:203, dashboard internal/server/handler_trash.go:166) restores into the skills source, so the folder ends up at <source>/replaced-by-init/claude/alpha and the next sync picks it up as a new nested skill. No data is lost, since the content is identical to the source, but the docs promise the folder "can be recovered". Please either say the trash copy is for manual recovery only, or keep it out of the restorable skills trash.
  2. A failed move is reported as "differs from the source". When MoveToTrash fails (init_apply.go:313-315), the folder goes into kept, and init.go:421 prints "Kept local copies that differ from the source". The folder is identical; the real error is dropped. MoveToTrash can also return a path together with an error ("copied to trash but failed to remove original"). Only the success path is tested.

Smaller points

  1. ManagedOnly behaviour changed without a note. Dropping !opts.ManagedOnly from the broken-external-link branch (sync.go:901) means the legacy project cleanup (legacy_project.go:104) now removes manifest-recorded broken external links. That seems reasonable, but the PruneOptions.ManagedOnly comment (sync.go:773-776) still says broken-external-link cleanup is skipped, and nothing tests it.
  2. Translations. reference/commands/init.md and understand/sync-modes.md have copies under website/i18n/{ja,ko,zh-Hans,zh-Hant}/docusaurus-plugin-content-docs/current/, and none were updated with the trash sentence or the new sync-modes bullets.
  3. PR body. It says init --copy-from: replaceIdenticalCopies, but replaceIdenticalCopies runs on every init's first sync (firstSync), not only with --copy-from. The docs ("During the first sync") are correct.
  4. Untested states: project mode with relative links, installs whose links predate the manifest (source moved), ManagedOnly, target_naming: standard, and dry-run output for the new prune branches.

A small cleanup, optional: prune looks up manifest.Managed[name] three times for the same entry; computing owned := inManifest || force once would simplify the branches.

Happy to help with any of these. Feel free to ask if a point is unclear or you disagree with it.

@runkids runkids added bug Something isn't working sync Sync behavior across targets windows Windows-specific behavior labels Nov 15, 2026
Review of the first commit found places that still did, or predicted,
the old behaviour. One rule now decides whether a link is skillshare's:
Manifest.OwnsLink (the manifest records a link there, or it points into
the source). It compares canonical paths, so a source reached through an
alias and a relative project link still count as skillshare's.

- copy mode kept re-pointing: it removed any same-name link and wrote a
  copy. It now keeps a link it does not own, like merge mode.
- the dashboard diff predicted a prune for a folder that is only named
  like skillshare's, and an update for another tool's link. It now
  reports them as local and kept. The orphan-link prediction uses the
  same rule as prune.
- `diff` reported a target as in sync while sync printed "kept local"
  for another tool's link. It lists the link as a local override.
- doctor reported a broken link skillshare did not create as an error
  and suggested `skillshare sync`, which now keeps it. It is a warning
  with its own row, and `broken_symlinks` is `warning` in --json.
- `trash restore` put a folder init had replaced into the source as a
  new nested skill. Restore refuses entries under replaced-by-init/ and
  names the trash folder to copy from.
- init reported a folder it could not move to the trash as one that
  differs from the source, and dropped the error. It is reported
  separately, with the error.
- the PruneOptions.ManagedOnly comment still said broken external links
  are skipped; manifest-recorded ones are removed.

Tests cover the states the review listed: a source behind an alias, a
relative project link, ManagedOnly, standard naming, dry run with
--force, and a recorded copy the user replaced with a link.
TestSync_Pruning_RemovesBrokenExternalSymlinks passed without testing
anything, because FileExists follows links; it is now two tests that
use Lstat, one per owner.

Agent merge is unchanged: agents have no link manifest.
Copy mode now keeps a same-name link skillshare did not create, but both
diffs read the entry with os.Stat. A broken link showed as a skill to
add on every run, and a live one as a plain local copy, while sync kept
both and said "kept local".

`diff` and the dashboard diff check the link first and report it the way
merge mode does: a local override, kept until --force.
@runkids
runkids marked this pull request as ready for review November 16, 2026 19:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T20:00:38.969016Z b60bf1c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

TestSyncMergeRepointsUnrecordedLinkIntoAliasedSource failed on Windows:
it linked straight to a missing folder, and a junction cannot be made
to one. It now links first and removes the folder after, like the other
broken-link tests in this file.
@runkids

runkids commented Nov 16, 2026

Copy link
Copy Markdown
Owner

@codex review

linksIntoSource resolved both paths with EvalSymlinks, which gives up on
a path that does not exist. A broken link is exactly that, so a link
into a source reached through an alias (a symlinked config folder, or a
short 8.3 path on Windows) compared an unresolved path with a resolved
one and was taken for another tool's link. Sync then kept it instead of
repairing or pruning it.

It now uses sourcewalk.Canonical, which resolves the nearest folder that
exists and keeps the missing tail. The test covers both spellings: the
alias in the link, and the alias in the configured source.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6adb75f71d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/skillshare/init_apply.go Outdated
return 0, nil, nil, err
}
kept = replaceIdenticalCopies(cfg, discovered)
kept, notTrashed = replaceIdenticalCopies(cfg, discovered)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface first-sync warnings for preserved foreign links

When initializing against an existing repository while a tool has a same-name link into another manager’s store, merge and copy sync now preserve that link. However, firstSync discards the results from runParallelSyncQuiet, and kept/notTrashed only describe real folders inspected by replaceIdenticalCopies. Consequently, performFreshInit prints “Synced …” without warning that the repository’s version was not activated or explaining how to replace the existing link. Propagate the actual sync results’ kept-link and prune warnings through the initialization output as well.

AGENTS.md reference: AGENTS.md:L36-L36

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b60bf1c. firstSync now returns the warnings a plain sync prints, and init shows them, so a kept link, a look-alike folder and a broken link from another tool are all listed.

Comment on lines +239 to 241
_, inManifest := manifest.Managed[eName]
if manifest.OwnsLink(eName, entryPath, source) && (os.IsNotExist(statErr) || inManifest) {
dt.Items = append(dt.Items, diffItem{Skill: eName, Action: "prune", Reason: "orphan symlink", Kind: kindSkill})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match orphan previews to the live-external-link pruning rule

When a user changes the skills source through the dashboard configuration editor but retains the old checkout, an old skill absent from the new source can still have a manifest symlink record and a live external destination. Both OwnsLink and inManifest are then true, so this condition advertises a prune, but PruneOrphanLinksWithSkills explicitly keeps live external links unless forced (internal/sync/sync.go:910-916). The Sync page therefore counts a removal that ordinary sync never performs, and subsequent previews retain the same pending removal. Mirror the actual pruning predicate instead of treating the manifest record alone as sufficient for a live external link.

AGENTS.md reference: AGENTS.md:L36-L36

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b60bf1c. The orphan preview now uses prune's rule: a link into the source goes when broken or recorded; any other link only when broken and recorded.

Two previews said less, or more, than sync does.

init ran its first sync quietly and printed only "Synced". Sync now keeps
a link another tool put on a skill's name, a folder that is only named
like skillshare's, and a broken link it did not create, so the skill was
reported as synced while the tool still loaded the other copy. firstSync
returns the warnings a plain sync prints, and init shows them. They
already name the folders that differ from the source, so the separate
list of those is gone.

The dashboard diff counted an orphan link as a removal whenever the
manifest recorded it. Prune keeps a recorded link that still resolves
outside the source (the source moved and the old checkout stayed), so
the Sync page showed a removal that never happened. The diff now uses
prune's own rule: a link into the source goes when broken or recorded;
any other link only when broken and recorded.
@runkids

runkids commented Nov 16, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: b60bf1c26c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@runkids
runkids merged commit 1419b62 into runkids:main Nov 16, 2026
9 checks passed
endgame302 added a commit to endgame302/skillshare that referenced this pull request Nov 16, 2026
Add the four marketplace commits to the fork README's table. Record that
runkids#914 was squash-merged upstream as 1419b62 after
v0.30.9, so the replay will not drop the three runkids#914 commits by itself;
they have to be dropped by hand once an upstream release contains it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
endgame302 added a commit to endgame302/skillshare that referenced this pull request Nov 16, 2026
Add the four marketplace commits to the fork README's table. Record that
runkids#914 was squash-merged upstream as 1419b62 after
v0.30.9, so the replay will not drop the three runkids#914 commits by itself;
they have to be dropped by hand once an upstream release contains it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@runkids

runkids commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks for this, @endgame302. The sandbox evidence made the problem easy to confirm, and the manifest-based rule is the right one. I pushed follow-up commits to your branch for the review points rather than send them back to you, and merged it. The main additions: the same rule now applies in diff, doctor and the dashboard, copy mode keeps another tool's link too, and a broken link into an aliased source is still repaired on Windows. It will be in the next release. If anything behaves differently from what you saw, please tell me.

runkids added a commit that referenced this pull request Nov 17, 2026
…board (#937)

The Sync page predicted which orphan links sync would remove with its
own copy of prune's rule. The copy had already drifted once (#914), and
it still disagreed in two cases: prune treats a link it cannot follow,
such as a loop, as broken, while the page only counted a missing
destination; and prune keeps a link whose target it cannot read.

The decision now lives in sync.OrphanLink. Prune and the dashboard diff
both call it, so a later change to the rule reaches both. Prune's
results, warnings and dry-run text are unchanged. LinksIntoSource, added
for the dashboard's copy, is no longer needed and is removed.
runkids added a commit that referenced this pull request Nov 17, 2026
The Latest callout still named 0.30.9. Point it at the Codex hook trust
that 0.30.10 ships, in every translated README, and add the author of
#914 to the contributors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working sync Sync behavior across targets windows Windows-specific behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants