Commit Graph
21 Commits
Author SHA1 Message Date
Willie 779ec26ff5 fix(upgrade): elevate only the binary replacement with sudo
When the binary lived in a root-owned directory, upgrade re-ran the whole
command under sudo. The built-in skill download, UI asset cache, and oplog
then landed in the user's home as root-owned files, and a later git pull
of the skills source failed with "unable to unlink old
'skillshare/SKILL.md': Permission denied".

The sudo child now only receives an internal --replace-binary=<version>
flag that downloads and swaps the binary. The parent waits for it and
does everything else as the invoking user. The needs-password hint shown
by the CLI and dashboard drops its sudo prefix, since a fully root
upgrade reproduces the same breakage.
2026-09-27 02:10:00 +08:00
Willie a1fc80c9d5 fix(upgrade): explain the password requirement instead of sudo's raw error
After the previous fix the dashboard failed fast but showed the whole
CLI transcript ending in "sudo: a password is required", which does not
tell the user what to do next.

Probe `sudo -n true` before re-executing and return a message naming the
terminal command. The server maps that to an `upgrade.needs_sudo` error
code so the update dialog and the Doctor page can show a translated
sentence in every locale.

Also bound the release download with a client timeout; http.Get had
none, so a stalled connection could hang an upgrade indefinitely.
2026-09-20 11:08:48 +08:00
Willie 306bf99e0e fix(version): handle release version formats
Accept leading v prefixes during version checks, keep local metadata builds in dev mode unless they are clean exact release tags, and prevent cleanup warnings from leaking into JSON-mode stderr.
2026-06-14 15:54:25 +08:00
Willie 7280ec265f fix(version): reject malformed version segments
Return explicit comparison errors for non-numeric version segments instead of treating them as zero.

Fail closed in update checks when current or cached latest versions are malformed, and cover numeric, malformed, and cache-preserving cases.
2026-06-14 14:01:01 +08:00
Willie dbce8ffa20 fix: update registry.yaml path and clean up formatting
Update registry.yaml path references from ~/.config/skillshare/
to ~/.config/skillshare/skills/ in schema description, quick
reference docs, and migration guide. Fix whitespace alignment
in lint.go constants and remove blank line in skill.go imports.
2026-03-27 02:17:54 +08:00
Willie dee3fcb1d0 refactor: move version under metadata in built-in SKILL.md
Move version field from top-level frontmatter to metadata block:
  metadata:
    version: v0.17.11

ReadLocalSkillVersion and FetchRemoteSkillVersion now parse
metadata.version with fallback to top-level version for backward
compatibility.
2026-03-25 21:14:16 +08:00
Willie 8a377481cb feat(version): Homebrew-aware version check
Homebrew formula updates lag GitHub Releases by hours/days, causing
Homebrew users to see "update available" when `brew upgrade` says
already up-to-date. Now detect install method from executable path
and query `brew info --json=v2` for Homebrew installs instead of
the GitHub Release API.

- Add InstallMethod type with DetectInstallMethod() and
  FetchBrewLatestVersion() in internal/version/homebrew.go
- Check() accepts InstallMethod to branch fetch strategy
- UpdateNotification() accepts upgradeCmd (shows correct command)
- UpgradeCommand() method on InstallMethod centralizes the mapping
- doctor.go reuses versioncheck.Check() (fixes semver string
  comparison bug in old fetchUpdateMessage)
- Remove duplicated isHomebrewInstall() from upgrade.go
- Skip post-command version check for doctor (has its own)
2026-03-02 02:23:50 +08:00
Willie ae16181689 refactor(auth): consolidate duplicated auth infra and fix GH_TOKEN gap
- Remove duplicated RateLimitError, newGitHubRequest, newGitHubClient,
  checkRateLimit from internal/version — now uses internal/github client,
  which also fixes missing `gh auth token` fallback for version checks
- Add GH_TOKEN as fallback in install.resolveToken() for GitHub platform,
  matching github.GetToken() resolution order (GITHUB_TOKEN → GH_TOKEN)
- Add GH_TOKEN to sanitizeTokens() redaction list
- Extract shared IsAuthError() in install/auth.go; push.go and
  wrapGitError() both delegate to it (adds "Access denied" coverage)
- Consolidate shouldFallback*TrackedClone auth checks via isAuthOrAccessError()
- Thread single *http.Client through search.Search() and all callees,
  reducing ~60 redundant TLS handshakes to connection-pooled reuse
- Pass *http.Client to downloadFile() instead of creating per-file clients
- Replace sourceHost() with extractHost() (same package, identical purpose)
- Remove unused isGitRepo() alias; callers use IsGitRepo() directly
2026-03-02 02:23:50 +08:00
Willie ce5ba1442c fix: strip "v" prefix from skill version to prevent "vv" display
SKILL.md frontmatter may contain "version: v0.15.0" (with v prefix),
but callers already prepend "v" when formatting. Normalize at the
source by trimming the prefix in both ReadLocalSkillVersion and
FetchRemoteSkillVersion.
2026-02-22 08:08:35 +08:00
Willie d99653025c refactor: unify CacheDir into config package and document all platform paths
Move GetCacheDir() from version package to config.CacheDir(), consistent
with BaseDir()/DataDir()/StateDir() pattern including Windows fallback.
Add XDG_CACHE_HOME and cache paths to website docs.
2026-02-16 12:58:28 +08:00
Willie 41e822d979 feat: remove go:embed, serve UI exclusively via runtime download
Replace the embedded SPA (go:embed + build tags) with runtime download
from GitHub Releases. The binary no longer bundles UI assets — they are
downloaded on first `skillshare ui` launch and cached at
~/.cache/skillshare/ui/<version>/.

- Delete embed.go / embed_dev.go; add spa_disk.go with placeholder handler
- Simplify ensureUIAvailable(): cache check before dev-mode fallback
- Pre-download UI assets in `skillshare upgrade` (best-effort)
- Remove Node stages from production and CI Dockerfiles
- Keep Node stage in sandbox for playground UI cache pre-population
- Remove ui-embed-check CI job and -tags dev build flag
- Update Makefile, mise.toml, GoReleaser, release workflow
2026-02-16 02:58:22 +08:00
Willie 092fb14f8a feat: add web dashboard with embedded React SPA (skillshare ui)
Single-binary web UI for visual skill management — React 19 + Vite
frontend embedded via go:embed, Go net/http REST API backend (30+
endpoints). Includes dashboard, skills browser, targets, sync, collect,
search, install, config editor, backup/restore, and git sync pages.

Also adds Bitbucket/GitLab URL parsing for install, git operations
library, skill version checking, CI frontend build steps, Docker
sandbox support, and website docs for the ui command.
2026-02-08 05:08:30 +08:00
Willie d084e59c8d fix(upgrade): gracefully handle rate limit, use cached version
- Skip CLI upgrade silently when API rate limited and no cache
- Use cached version to upgrade when API fails but cache exists
- Extract BuildDownloadURL for direct URL construction without API
- Add GetCachedVersion to expose cached latest version
2026-02-01 08:33:54 +08:00
Willie Hung bf286f1d88 fix(upgrade): add Windows zip support
- Handle .zip format for Windows releases (vs .tar.gz for others)
- Add extractFromZip() and refactor extraction logic
- Update test to use --force flag for upgrade flow
2026-01-31 03:40:34 +08:00
Willie Hung f5798fc0ea fix(upgrade): add GitHub token support and improve rate limit handling
Refactored GitHub API logic into shared internal/version/github.go:
- Support GITHUB_TOKEN and GH_TOKEN environment variables
- Clear error message when rate limit exceeded with fix instructions
- Removed duplicate API code from upgrade.go and check.go
2026-01-31 03:10:55 +08:00
Willie Hung 3bb6edc12a feat(ui): redesign install command with tree-style output
- Add tree structure UI (▸ → ├─ → └─) for install progress
- Add SkillBox component for displaying skill details
- Customize survey multi-select with cleaner icons (✓, ▸)
- Unify UI across all install modes (discovery, track, subdir, direct)
- Show version number in logo for install commands
- Add logo to doctor and status commands
- Quiet git clone output for cleaner experience
2026-01-31 02:51:00 +08:00
Willie Hung 19d641d66b feat: move version cache to XDG-compliant location
Move version-check.json from ~/.skillshare/ to ~/.cache/skillshare/
to align with XDG Base Directory Specification. Add support for
XDG_CACHE_HOME environment variable. Auto-cleanup legacy cache
location on first run.
2026-01-24 23:34:23 +08:00
Willie Hung 10be270dcd fix: clear stale version cache when current >= cached latest
If user manually updates (not via skillshare upgrade), the cache
may still show an older "latest" version. Now clears cache when
current version >= cached latest to trigger fresh fetch.
2026-01-23 21:19:33 +08:00
Willie Hung fa6757664f feat: clear version cache after successful upgrade 2026-01-23 21:17:35 +08:00
Willie Hung 6fad4335d2 fix: Box padding and semver comparison
- Add padding to Box function for consistent border width
- Fix version comparison to handle semver properly (0.6.10 > 0.6.8)
2026-01-23 21:13:22 +08:00
Willie Hung fb077539da feat: add version check notification after commands
- Check GitHub releases API for new versions (24h cache)
- Display colorful update notification when update available
- Skip check for dev builds
- Cache stored at ~/.skillshare/version-check.json
2026-01-23 14:03:53 +08:00