The list endpoint walked every snapshot to size it, then walked all of
them again for the total. With thousands of files and a cold file cache
(right after an upgrade, for example) the Backup page took visibly long
to open.
Each snapshot folder is now walked once for both its size and file
count. Backup and total sizes are sums of those, and the per-folder
counts are returned as `entries` so the dashboard can show what each
folder holds.
skillshare backs up AGENTS.md, CLAUDE.md and shared-file locations before
rewriting them, but nothing could list or restore those copies, and a
target snapshot could not be deleted on its own. The file backups now
record why they were taken in their name (<time>.<reason>.bak; older ones
have none), and the server and CLI can list them, show a version and
restore it, saving the current content first. A link is only replaced
when the caller asks for it.
Also:
- DELETE /api/backups/{timestamp} and `backup --delete`.
- Agents snapshots (<target>-agents) could not be restored from the
dashboard: the name was looked up as a target.
- Project mode uses the project's backups folder for snapshots and lists
only file backups inside the project.
- MCP backups report which servers they changed and when.
Refs #299
Since Go 1.23, os.Lstat reports NTFS junctions as irregular files instead
of symlinks (winsymlink, active for go 1.25 in go.mod). Every check that
looked only at os.ModeSymlink therefore missed the junctions skillshare
itself creates on Windows: linked skills could be treated as local folders,
backed up, copied through, or left behind on prune.
Detect links through utils.IsLinkMode, which also asks the OS about the
reparse tag of irregular entries, and count only real symlinks and
junctions as links so OneDrive placeholders and deduplicated files stay
regular files. restore.go also used os.Stat for its link check, which
follows the link and never matched.
Refs #299
* fix(project): refuse to re-init a project that lost its config.yaml
Every project-mode command auto-initializes when .skillshare/config.yaml
is missing. That is right for a repository with no project directory at
all, and for the shared skills repo produced by 'init -p --config local',
which gitignores config.yaml so each developer regenerates their own.
It was wrong for the case in between. A .skillshare/ that already held
skills or agents, whose config.yaml was simply gone, was re-initialized
into an empty config. Every configured target was dropped, the target
symlinks were left behind pointing at a project the config no longer
described, and the command exited 0. Nothing said anything had happened.
Add ensureProjectConfig, which replaces the open-coded auto-init at every
project command entry point. It initializes as before when there is no
project directory, and when config.yaml is gitignored, so both intentional
cases keep working untouched. When the directory holds skills or agents
and its config is neither present nor gitignored, it now returns an error
pointing at version control or an explicit 'skillshare init -p' instead of
writing over the project.
The gitignore check is treated as inconclusive on error, so a repository
that cannot be inspected is guarded rather than overwritten.
* feat(project): support a visible skillshare/ project directory
Project mode is identified only by .skillshare/config.yaml, and trash,
backups, logs and audit-rules.yaml anchor to that same hidden directory.
The sources option (#153) made project content relocatable, but the
marker and operational state stay hidden, so repositories that treat
skills as reviewable content still carry a hidden directory whose only
job is to hold config.yaml.
Resolve the project directory through a new leaf package that checks
.skillshare/config.yaml first and skillshare/config.yaml second, and
derive every config, state, source-default and gitignore path from the
result. The hidden name wins whenever both exist, so an existing project
never moves and no migration is needed. The package imports nothing else
internal because internal/audit cannot import internal/config without a
cycle.
Add init -p --visible to create the visible layout. Default init -p
behaviour and output are unchanged.
Two ambiguities the visible name introduces:
- The global config directory is also called skillshare
(<config-home>/skillshare), so the two places that infer scope from a
config path now exclude the global location by full path rather than
by directory name. TestLogDir_Global asserted a fixture path without
declaring a config home, which hid this; it now sets XDG_CONFIG_HOME.
- An unrelated directory named skillshare/ must not be adopted as a
partially initialized project, so the visible name is only claimed
when it carries a marker of its own: a skills/ or agents/ directory,
or a .gitignore that ignores config.yaml.
The missing-config guard added in the previous commit is generalized to
resolve through the new package, so it covers both layouts. The
gitignored-config marker matters there too. A repository shared by
'init -p --visible --config local' before any skill was committed clones
with nothing but that .gitignore, because git drops the empty skills/
and agents/ directories; recognizing it keeps the repair pointed at the
visible directory instead of writing a hidden one beside it.
Refs #256
* fix(project): reconcile visible directory support with main
Consolidate the missing-config guard and regression tests already merged in #260. Preserve both directory layouts and document and test resyncing target links after a rename. Follow-up for #258.
---------
Co-authored-by: Willie <egg358358@gmail.com>
Pre-sync backups followed merge-mode skill symlinks and copied the resolved
content, so every snapshot duplicated the source — including gitignored
artifacts still sitting on disk (model weights, .venv, browser profiles).
Combined with retention that only ever ran on demand, backup directories grew
without bound; one user reported 500 GB and sync failing with ENOSPC.
A backup only needs to protect what sync can destroy: local content that
exists in the target but not in the source. Symlinks point into the source,
which is the single source of truth and already safe, and sync recreates them.
copyDir already skips symlinks, so copyDirFollowTopSymlinks is deleted.
Retention now runs after every automatic backup using the existing default
policy — in global sync and in both agent sync paths, since project agent
backups had the same unbounded growth.
Two related defects surfaced while wiring this up:
- Cleanup's size check could remove the newest snapshot, leaving no restore
point at all when a single snapshot exceeded the cap. It now always keeps
the newest.
- A target holding nothing but symlinks produced an empty snapshot that
consumed a retention slot and evicted snapshots that had content. Empty
snapshots are now discarded.
Behaviour change: restoring a merge-mode target recovers local content only;
run `skillshare sync` afterwards to recreate symlinks. Copy mode is unaffected
because those targets hold real files.
Refs #252
Add -p/--project support to 'backup agents' and 'restore agents' commands.
Project-mode backups are stored under .skillshare/backups/ (parallel to
.skillshare/trash/).
Backup engine changes:
- Add ProjectBackupDir(), CreateInDir(), ListInDir() to internal/backup
- Add RestoreLatestInDir(), FindBackupsForTargetInDir(),
GetBackupByTimestampInDir() to restore.go
- Existing global functions become thin wrappers (zero caller churn)
Command layer changes:
- Allow project mode through for kind=agents in cmdBackup/cmdRestore
- Auto-detect project mode when .skillshare/config.yaml exists
- Refactor backup_agents.go with resolveAgentBackupContext() to
resolve backup dir + agent targets per mode
Skills backup in project mode remains unsupported (error unchanged).
dirSize() was called synchronously for every backup version during list
population and on each cursor move, blocking the entire TUI event loop.
- Add ListBackupVersionsLite() that skips dirSize (TotalSize = -1)
- Compute size asynchronously via tea.Cmd, cache in versionSizeCache
- Replace redundant ListBackupVersions() in renderTargetDetail() with
direct os.ReadDir() on the latest backup directory
- Cap per-skill I/O (readSkillDescription + listSkillFiles) to 20 items
in both renderTargetDetail() and renderVersionDetail()
- Add expand state (Enter key toggle) for file-level diff display
- Show file list with +/-/~ icons for add/delete/modify files
- Show colored unified diff (green/red/cyan) for modified files
- Add source/target mtime rows in detail header
- Replace "Actions" section with "Next Steps" using prominent styling
- Update list item description with sync/local breakdown
- Add stat counts (err/diff/ok) to TUI title bar
- Fix freeze: defer file walk to Enter toggle instead of every render
- Fix gofmt in trash_tui.go and restore.go
Add ListBackupVersions() and ListTargetsWithBackups() for TUI timestamp
selection. Fix merge-mode targets producing empty backups by following
top-level symlinks in copyDirFollowTopSymlinks().
Separate backups/trash into XDG_DATA_HOME and logs into XDG_STATE_HOME
instead of keeping everything under XDG_CONFIG_HOME. Add automatic
migration at startup to move existing data to the new locations.
Fix Windows path resolution: DataDir() and StateDir() now fall back to
%AppData% on Windows (matching BaseDir()), preventing incorrect use of
~/.local/share and ~/.local/state paths.
Add MigrateWindowsLegacyDir() to move pre-v0.13.0 data from
~\.config\skillshare\ to %AppData%\skillshare\ on Windows.
Update doctor, oplog, backup, trash, and all tests/docs accordingly.
Add config.BaseDir() as single source of truth for base directory
resolution. Replace all hardcoded ~/.config/skillshare paths.
Path resolution priority:
1. SKILLSHARE_CONFIG env var (unchanged)
2. $XDG_CONFIG_HOME/skillshare (any platform)
3. %AppData%/skillshare (Windows only)
4. ~/.config/skillshare (Linux, macOS fallback)
- Add config.BaseDir() with XDG_CONFIG_HOME + Windows %AppData% support
- Update BackupDir(), TrashDir(), init default source to use BaseDir()
- Show resolved base directory in doctor output
- Add unit tests and integration tests for XDG override
- Document XDG_CONFIG_HOME and update Windows paths in docs
filepath.Walk fails on Windows NTFS junctions with "Incorrect function"
because os.Lstat returns nil info, bypassing all junction-detection logic
and crashing the entire backup for that target. This means one unreadable
junction prevents ALL local skills from being backed up.
Replace with os.ReadDir + os.Lstat so junctions are identified and skipped
before any read attempt. Also add Windows CI and unit tests for copyDir.
Fixesrunkids/skillshare#7
On Windows, filepath.Walk may fail when encountering junctions with
"Incorrect function" error. This fix:
- Gracefully handles walk errors for symlinks/junctions
- Uses SkipDir to avoid entering junction directories
- Double-checks with Lstat for Windows reparse points
- Add `diff` command to show differences between source and target
- Add `backup` command for manual backup with recent backup list
- Add `doctor` command to diagnose configuration issues
- Add internal/backup package for backup functionality
- Fix diff command incorrectly showing "not linked" for symlink mode targets
- Update README with new commands documentation