Commit Graph
23 Commits
Author SHA1 Message Date
Willie 16c6e8ec8d feat(server): git operations honor git_root scope + POST /git/root to switch scope
- extract shared git.InitScopeRepo/WriteScopeGitignore/EnsureLocalIdentity (UI-free)
- cmd init delegates to the shared helpers (no logic duplication)
- handler_git operations use EffectiveGitRoot; status exposes the scope
- new POST /api/git/root inits a repo at the target scope dir + persists git_root
2026-05-30 19:23:12 +08:00
Willie 012a4ba97e fix(ui): resolve stuck update checks 2026-05-25 00:33:26 +08:00
Willie 63a4a57a0c feat(ui): allow editing source URL on skill detail page
Add PATCH /api/resources/{name}/source endpoint to update the source URL
for installed skills. For tracked repos, all sibling skills sharing the
same git remote are updated together with the new repo base URL, and the
git remote origin is also updated.

Frontend changes:
- Add Source URL input field in the skill editor (visible for all skills
  with metadata)
- Use shared Input/Textarea components in FrontmatterEditor for visual
  consistency, with new size='sm' variant
- Replace custom kind-badge/tracked-badge with shared KindBadge/SourceBadge
  components in the editor header
- Preserve original YAML frontmatter formatting when only the body or
  source URL is changed (avoids spurious quote style / line wrap diffs)
- Skip diff review dialog when only source URL is modified

Backend fixes:
- Two-pass skill lookup in handleGetSkill: prefer exact FlatName match
  over baseName fallback to prevent name collisions between standalone
  and tracked repo skills
- Add basename-only fallback in MetadataStore.GetByPath for tracked repo
  skills stored with short keys
- Use cfg.Source (global) consistently in save/patch handlers to match
  the source used by list/detail handlers in project mode

Closes #142
2026-04-22 23:06:53 +08:00
Willie 354db51928 feat(check): branch-aware remote ref comparison and registry rebuild
- Add GetRemoteRefHash/WithAuth/WithEnv to internal/git/info.go:
  uses git ls-remote with refs/heads/<branch> when branch is set,
  falls back to HEAD when branch is empty
- Add Branch field to URLCheckInput and URLCheckOutput in check/parallel.go;
  ParallelCheckURLs dispatches to GetRemoteRefHashWithAuth when Branch is set
- check.go: group skills by RepoURL@branch composite key so skills on
  different branches of the same repo are checked against the correct ref;
  urlHashMap keyed by same composite key for correct broadcast
- install_config.go (InstallFromConfig): propagate SkillEntryDTO.Branch
  into Source.Branch for both plain and tracked skill phases so registry
  rebuild (install --from-config) respects the recorded branch
2026-04-01 00:32:49 +08:00
Willie 3d58765953 fix(git): propagate error from GetRemoteURL instead of swallowing it
Callers can now distinguish between "no remote configured" and real
failures (e.g. git not in PATH). All existing callers already guard
with err == nil so behavior is unchanged.
2026-03-14 04:01:10 +08:00
Willie 7d0952b8b6 feat(ui): add branch switcher to Git Sync page
Allow non-technical users to switch branches from the Web UI without
needing a terminal. The dropdown shows local branches first, then
remote-only branches tagged "(remote)".

Backend:
- Add ListLocalBranches, ListRemoteBranches, Checkout to internal/git
- Add GET /api/git/branches (?fetch=true for remote discovery)
- Add POST /api/git/checkout with dirty-check guard + fetch-before-switch
- Oplog instrumentation for checkout operations

Frontend:
- Branch Select dropdown replaces static text when >1 branch exists
- Refresh button to fetch new remote branches on demand
- Dirty state disables switching with visual hint
- Card overflow + z-index fix for playful theme dropdown clipping
2026-03-14 04:01:10 +08:00
Willie d842d7a871 feat(ui): add Repository Info Card to Git Sync page
Replace the minimal Repo Status Card with a full Repository Info Card
showing remote URL with platform detection (GitHub/GitLab/Bitbucket),
branch tracking info, HEAD commit hash and message, and status badges.

Backend: export GetRemoteURL, add GetHeadMessage and GetTrackingBranch
to internal/git, extend /api/git/status with 4 new fields.

Frontend: new parseRemoteURL utility parses SSH/HTTPS remote URLs and
detects platform by exact hostname match. RepoInfoCard displays parsed
owner/repo with platform icon, clickable link, copy button, and
graceful fallbacks for missing remote or unparseable URLs.
2026-03-14 04:01:10 +08:00
Willie 0a3305f617 fix(update): capture git stderr and show actionable error messages
The update handler used internal/git which ran git commands without
capturing stderr, so failures like divergent branches only showed
"exit status 128". Now runGitWithProgress captures stderr and pipes
it through install.WrapGitError for meaningful messages.

Also adds:
- extractGitFatal() strips verbose hint: lines from git output
- Force checkbox and per-item Force retry button in Update UI
- "(try force update)" / "(try --force)" hint on pull failures
2026-03-13 09:45:56 +08:00
Willie b014f8c6dc feat: optimize large-repo install and update flows
Implement Issue #46 across install/update paths to reduce perceived hangs and improve subdir installation performance on large repositories.

Main changes:
- Add git progress streaming primitives in internal/install/git_progress.go.
  - runGitCommandWithProgress supports stderr streaming callbacks in TTY mode.
  - scanGitProgress handles both CR and LF progress delimiters.
- Thread InstallOptions.OnProgress through clone/pull/discovery/install/update paths.
  - Keep non-TTY behavior quiet to avoid noisy logs.
  - Add TreeSpinner.Update for live message updates.
- Add progress-aware git update APIs in internal/git/info.go:
  - PullWithProgress and ForcePullWithProgress (keep PullWithEnv/ForcePullWithEnv for compatibility).
- Introduce shared GitHub client utilities in internal/github/client.go.
  - Centralize token lookup, request construction, and rate-limit handling.
  - Refactor internal/search/search.go to use shared client while preserving compatibility aliases.
- Add GitHub/GHE API subdir fast path in internal/install/github_download.go.
  - github.com => api.github.com
  - github-like enterprise hosts => https://<host>/api/v3
  - On API failure, emit warning and fallback to git-based flows.
- Add sparse checkout fallback for non-GitHub subdir sources in internal/install/sparse_checkout.go.
  - Use filter+no-checkout+depth=1 then sparse-checkout set + checkout.
- Extend discovery/install metadata plumbing.
  - DiscoveryResult now includes CommitHash and Warnings.
  - install/discover subdir paths preserve warnings and commit hashes from API/sparse/full-clone flows.
- Preserve compatibility and UX expectations.
  - Keep existing action strings (for tests/UI stability).
  - Keep legacy discover/pull APIs as wrappers around new progress-aware variants.
- Improve --track download efficiency.
  - Track clone now attempts --filter=blob:none --depth 1 --single-branch first.
  - Falls back to full clone only on remote capability mismatch, not on auth/not-found errors.

CLI wiring:
- cmd/skillshare/install.go
  - TTY handlers now pass progress callbacks and use with-progress discover APIs.
  - Subdir handler shows API-vs-clone stage messages and renders discovery fallback warnings.
- cmd/skillshare/update.go and cmd/skillshare/update_project.go
  - Use PullWithProgress/ForcePullWithProgress for tracked repos.
  - Ensure reinstall/update install flows forward progress callbacks.

Tests added/updated:
- internal/install/git_progress_test.go
- internal/install/github_download_test.go
- internal/install/sparse_checkout_test.go
- internal/install/tracked_clone_test.go
- internal/install/source_test.go (GitHubOwner/GitHubRepo coverage)
- internal/git/info_test.go (PullWithProgress/ForcePullWithProgress)
- tests/integration/install_subdir_optimization_test.go
- tests/integration/install_online_test.go (GitHub API subdir case)

Validation performed:
- go test ./internal/install -count=1
- go test ./internal/git -run 'Test.*Pull.*' -count=1
- go build -o bin/skillshare ./cmd/skillshare && SKILLSHARE_TEST_BINARY="/Users/williehung/Developer/Apps/github/skillshare/bin/skillshare" go test ./tests/integration -run 'TestInstall_Subdir|TestUpdate_' -count=1
- go build -o bin/skillshare ./cmd/skillshare && SKILLSHARE_TEST_BINARY="/Users/williehung/Developer/Apps/github/skillshare/bin/skillshare" go test ./tests/integration -run 'TestInstall_Track_|TestUpdate_TrackedRepo' -count=1
- go test -tags online ./tests/integration -run TestInstall_GitHubSubdirViaAPI -count=1
- make lint
- make test
2026-02-25 07:02:54 +08:00
Willie a0bfe9958a fix: batch update error propagation, skip-audit passthrough, and security hardening (#39)
- P1: Batch/all update now returns non-zero when repos are blocked by
  security audit (fail-closed for CI pipelines)
- P2: Pass --skip-audit to regular skill update via InstallOptions
- P2: Add path containment check in content integrity to prevent
  directory traversal via crafted file_hashes keys
- P3: Switch git diff parsing to NUL-delimited (-z) for safe handling
  of special filenames
2026-02-23 04:18:01 +08:00
Willie a5f84c2485 feat: auto-audit gate after update with rollback and --diff summary (#39)
Supply-chain hardening Phase 2:
- Add post-pull audit gate: HIGH/CRITICAL findings auto-rollback in
  non-interactive mode (fail-closed), prompt in TTY mode
- Use full 40-char commit hashes for reliable rollback (avoids short-hash ambiguity)
- Add --skip-audit flag to bypass the gate when risk is accepted
- Add --diff flag to show file-level change summary after tracked repo update
- Add GetChangedFiles() and ResetHard() git helpers
- Add audit gate in install --update git-pull path to prevent bypass
2026-02-23 04:18:01 +08:00
Willie 3b8c681bb2 feat: auto-inject auth tokens for hub search and Web UI git operations
Add token auto-injection for private repo support across all platforms:
- Hub search (--hub): normalize web URLs to raw-content URLs and apply
  platform-specific auth headers (GitLab, GitHub, Bitbucket)
- Web UI push/pull/update: use *WithAuth variants for git operations
- Export ResolveTokenForURL and DetectPlatformForURL from install/auth
2026-02-22 15:13:10 +08:00
Willie 836f1b498b refactor: dedupe git helpers and isolate test state 2026-02-21 21:12:51 +08:00
Willie 89055804ff fix: harden pull/push first-sync flow and add regression coverage 2026-02-21 21:12:51 +08:00
Willie 6b8c38455c fix: overhaul push/pull/init git remote flow
Fixes multiple issues with the cross-machine sync workflow reported
in runkids/skillshare#35:

- push/pull auto-detect missing upstream and set it on first use
  (push uses -u, pull uses fetch + reset + set-upstream-to)
- First pull checks local/remote skill directories before resetting;
  refuses to overwrite local skills unless --force is passed
- init --remote auto-initializes git when config exists but .git does not
- HTTPS token auth (GITHUB_TOKEN, GITLAB_TOKEN, etc.) injected into
  push, pull, and init remote fetch
- init --help shows init-specific flags and examples
- Remote repos with only files (README) no longer misdetected as
  having skills (uses git ls-tree -d)
- Error hints suggest skillshare init --remote instead of raw git
2026-02-21 21:12:51 +08:00
Willie 3e218266b4 fix: add HTTPS token auth to check paths 2026-02-21 06:07:35 +08:00
Willie 15e2b6db58 fix: add HTTPS token auth to update pull paths 2026-02-21 06:07:35 +08:00
Willie 0c49860d63 feat: add project mode labels, privacy-first messaging, and UI polish
- Add (project) labels to status, sync, collect, target, and uninstall
  headers for clear mode distinction (matching list/target list pattern)
- Add ui.WithModeLabel() helper for shared functions that run in both modes
- Update uninstall confirmation prompt: "from the project?" in project mode
- Add "Privacy-first" to README Why section and website homepage
- Replace "Unified Source" card with "Privacy-First" card on website
- Unify Quick Actions card heights with h-full in DashboardPage
- Add frontend rebuild note to Docker sandbox docs
2026-02-09 21:08:03 +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 Hung 9fbfe0e88a fix: resolve box rendering issues and improve list UI
- Add displayWidth() to calculate visible string width excluding ANSI codes
- Fix box padding calculation in Box, WarningBox, SummaryBox, UpdateNotification
- Disable git color output in GetCommitsBetween to prevent ANSI codes in commit hashes
- Improve list command: dynamic name alignment, add icons, remove duplicate separators
2026-01-25 02:49:54 +08:00
Willie Hung 806e14096d feat: handle force push when updating tracked repos
When using --force flag, use git fetch + reset --hard instead of
git pull. This handles cases where remote history was rewritten
(force push).
2026-01-24 00:07:27 +08:00
Willie Hung dda075cffb fix: disable color in git status output for consistent box rendering 2026-01-23 21:04:38 +08:00
Willie Hung 936a200198 feat: upgrade install/update UI with PTerm
- Add PTerm library for modern CLI output
- Add internal/ui/pterm.go with spinner, box, progress bar utilities
- Add internal/git/info.go for git diff/commit info retrieval
- Update install.go with header boxes, spinners, progress bars
- Update update.go with header boxes, spinners, change summaries
- Fallback to plain text for non-TTY environments
2026-01-23 13:50:57 +08:00