Commit Graph
21 Commits
Author SHA1 Message Date
Willie 6996237796 fix(install): keep the SSH reason when a git remote cannot be read
extractGitFatal kept only git's "fatal:" line, so SSH clone/fetch failures
(install from git@host:..., hub indexes over SSH, updates) reported just
"Could not read from remote repository." and dropped the ssh line that says
why: publickey denied, host key verification, unresolved hostname, or a
refused/timed-out connection.

For that generic message, append the preceding transport line (skipping
"Cloning into" and warning chatter). When the reason is a publickey denial,
WrapGitError adds an "ssh -T user@host" hint. Other errors are unchanged.
2026-09-30 16:35:30 +08:00
Willie de1abd4b33 feat(install): pin project skills to a commit with a lockfile
config.yaml records which skills a project wants, but not which commit
each one resolved to, so two teammates running `install -p` a week apart
could end up with different skill contents.

Project mode now writes .skillshare/skills.lock.json next to the config.
`install -p` checks out the locked commit for skills and tracked repos,
and brings an already installed skill to the lock when they differ.
`update -p` and the dashboard move a pin only for skills whose commit
actually changed, so a stale local copy cannot roll the team back, and
uninstall drops the pin. A locked value is only honoured when it is a
full SHA for the same source, since it ends up as a git argument.
2026-09-21 04:31:22 +08:00
Willie 338bc2c2a4 fix(install): harden ref pinning after code review
- Fallback fetch pulled only the default branch because a depth-1 clone
  is single-branch; fetch all heads and tags so an abbreviated SHA off
  the default branch resolves.
- Move the --track guard from CLI flag parsing into InstallTrackedRepo
  so the Web UI is covered too, and reject tags as well as SHAs: both
  leave HEAD detached with nothing for `git pull` to follow.
- An all-hex branch or tag name (e.g. 20240915) was treated as a SHA in
  check and never queried; look the ref up first and fall back to the
  literal SHA only when the remote has no such ref. Full 40-char SHAs
  still skip the network.
- Rename the git package's 7-char shortHash to abbrevHash to avoid
  clashing with install's 12-char helper.

Refs #281
2026-09-21 02:26:55 +08:00
Willie 3000227175 feat(install): support commit SHA and tag pinning via --branch
Teams with supply-chain review need reproducible installs, but --branch
only worked for branch names because git clone --branch rejects SHAs.

Clone the default branch and detach at the pinned commit (targeted
depth-1 fetch, falling back to --unshallow for abbreviated SHAs or
servers that refuse arbitrary wants). Resolve tags in check via
refs/tags and the peeled ^{} commit, and short-circuit SHA pins without
a network round-trip since they can never move. Reject --track with a
SHA: a tracked repo must follow a branch to pull.

Closes #281
2026-09-21 02:07:50 +08:00
zishuo 9fcba2744d feat: 支持配置自定义 CNB 和 Gitea 主机
将 CNBHosts 和 GiteaHosts 配置从 InstallContext 传递到 Source,使认证、平台检测和克隆操作能正确识别自定义的 CNB 和 Gitea 实例,而非仅依赖内置默认域名。
2026-06-23 18:45:43 +08:00
zishuo 49e33c564d Merge remote-tracking branch 'upstream/main' into develop 2026-06-23 17:05:33 +08:00
Willie 30bdd72b6f fix: retry nested GitLab repo URLs
Retry generic HTTPS clone failures by progressively treating additional path segments as part of a nested GitLab repository. Limit retry to repo-boundary errors and preserve the final fallback error for debugging.
2026-06-18 23:56:54 +08:00
Willie 6f49546476 fix(install): warn when temp repo cleanup fails
Route temp clone cleanup through a shared helper that logs cleanup failures with path and error while preserving existing best-effort cleanup semantics.

Cover cleanup failure logging with a deterministic unit test.
2026-06-14 14:52:22 +08:00
Willie 01d721a670 fix(git): preserve push stdout diagnostics 2026-06-13 22:15:25 +08:00
Willie 1d0ee69955 feat: support SSH hub sources for private and GHE hosts
Hub index fetch previously handled only unauthenticated HTTP(S) GET or
local file paths, leaving private and GitHub Enterprise repos out of
reach — raw HTTPS URLs redirect to login before token headers apply, and
SSH-style hub URLs were unrecognized.

Resolve SSH hub sources by shallow-cloning the repo with the user's SSH
keys and reading the index from it. The in-repo index path uses the
existing //path subdir convention (consistent with `install`), defaulting
to skillshare-hub.json at the repo root. Both scp-style and ssh:// URLs
are accepted. In the web dashboard, SSH clones are restricted to saved
hubs so a request-supplied URL can't drive an arbitrary clone.

Ref #185
2026-06-02 16:29:25 +08:00
zishuo ce9593e98e feat(install): add Gitea platform support with API fast path
Support Gitea (gitea.com and self-hosted instances) as a git hosting
platform for installing skills. Includes both core platform integration
and a Gitea Contents API fast path for direct file downloads without
full git clone.

Platform support (P0):
- auth.go: add PlatformGitea, detect gitea hosts, resolve GITEA_TOKEN
- config.go / project.go: add gitea_hosts config field with normalization,
  env var merge (SKILLSHARE_GITEA_HOSTS), and EffectiveGiteaHosts()
- source.go: add isGiteaHost() and GiteaHosts to ParseOptions
- install.go: pass GiteaHosts from config to source parsing
- install_git.go: include GITEA_TOKEN in auth error hints

API fast path (P1):
- gitea_download.go: Gitea Contents API recursive directory download
  (GET /api/v1/repos/{owner}/{repo}/contents/{path}), matching the
  GitHub Contents API pattern
- install_apply.go / install_discovery.go: hook Gitea API fallback
  after sparse checkout, before full clone
2026-05-26 19:00:25 +08:00
zishuo 17a9a0879b feat(install): add CNB platform support
Support CNB (Cloud Native Base, cnb.cool) as a git hosting platform for
installing skills. This adds platform detection, token authentication
via CNB_TOKEN, host configuration (cnb_hosts / SKILLSHARE_CNB_HOSTS),
and URL parsing for both direct and web URLs (including /-/tree paths).

Changes:
- auth.go: add PlatformCNB, detect cnb.cool hosts, resolve CNB_TOKEN
- config.go / project.go: add cnb_hosts config field with normalization
  and env var merge, plus EffectiveCNBHosts() accessor
- source.go: add isCNBHost() and CNBHosts to ParseOptions
- install.go: pass CNBHosts from config to source parsing
- install_git.go: include CNB_TOKEN in auth error hints
2026-05-26 19:00:25 +08:00
Willie 55ce0fb89e feat(install): pass --branch to discovery clone for regular installs
Source.Branch threads the branch parameter through discovery.
cloneRepo() passes --branch to git clone when set.
source.Branch is set from parsed.opts.Branch in cmdInstall.

Ref: #90
2026-04-01 00:32:49 +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 c16dc22af6 fix(install): show actionable error messages when git stderr is empty
When git commands fail with an empty stderr (common in --progress mode),
wrapGitError() was returning the raw exec.ExitError which only produces
"exit status 128" — giving users no clue about the actual problem.

Now extracts the exit code and maps it to actionable messages:
- exit 128: "repository not found or authentication required"
- exit 128 + token: "authentication token was rejected"
- exit 1: "check network connectivity and repository URL"
2026-03-13 09:45:56 +08:00
Willie 272735c607 feat(install): detect SSL certificate errors and show actionable guidance
When git operations fail due to SSL certificate issues (self-signed certs,
internal CAs), the error message now suggests GIT_SSL_CAINFO, GIT_SSL_NO_VERIFY,
and SSH as alternatives instead of showing raw git stderr.

Env vars like GIT_SSL_CAINFO are already inherited via os.Environ() in
gitCommand() — the actual gap was error detection and user guidance.
2026-03-05 02:13:21 +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 a88bb101c5 feat(auth): add AZURE_DEVOPS_TOKEN for Azure DevOps HTTPS authentication
Add PlatformAzureDevOps detection (dev.azure.com, ssh.dev.azure.com,
visualstudio.com) and AZURE_DEVOPS_TOKEN env var support. Token is
auto-injected via git config insteadOf rewrite, same pattern as
GITHUB_TOKEN/GITLAB_TOKEN/BITBUCKET_TOKEN.

Update error messages, sanitizeTokens redaction, environment-variables
docs with PAT creation guide and official Microsoft docs link, and
url-formats docs with Azure DevOps auth section.
2026-02-26 22:27:23 +08:00
Willie ce8608a6b1 fix(check): normalize leading slash in subdir for tree hash comparison
The // subdir syntax (e.g., repo//skills/foo) stores meta.Subdir with
a leading "/". git rev-parse and ls-tree paths never have leading
slashes, causing tree hash lookups to fail silently.

Strip leading "/" in getSubdirTreeHash(), resolveSkillStatuses(), and
handler_check.go. Add LeadingSlash unit test and E2E runbook.
2026-02-25 07:02:54 +08:00
Willie 117b319050 feat(check): per-skill tree hash comparison for precise update detection
Previously `skillshare check` compared repo-level commit hashes, causing
all skills from a registry repo to show "update_available" whenever any
commit was pushed — even if the individual skill's files were unchanged.

Now each skill records its git tree hash (subdir-level SHA) at install
time. During check, a three-tier comparison is used:

1. Fast path: commit hash matches → up_to_date (zero extra cost)
2. Tree hash path: blobless fetch (~150KB) + batch ls-tree → per-skill
   comparison; unchanged subdirs stay up_to_date
3. Fallback: no tree hash (old installs) → commit comparison (unchanged)

Also fixes pterm progress bar printing twice when it auto-stops at 100%.
2026-02-25 07:02:54 +08:00
Willie 3ae2a16440 refactor: split install implementation into focused files
Restructure the install package to reduce install.go size and isolate responsibilities without changing exported API signatures.

Changes:
- convert internal/install/install.go into a thin facade (types, test hook, exported wrappers)
- extract install flows into install_apply.go
- extract discovery flows into install_discovery.go
- extract update flow into install_update.go
- extract audit logic into install_audit.go
- extract git helpers into install_git.go
- extract tracked repo flow into install_tracked.go
- extract updatable/tracked query helpers into install_queries.go
- extract copy helpers into copy.go

Compatibility:
- exported API signatures are unchanged
- package remains flat as package install
- behavior is intended to remain equivalent; only code organization changed

Verification run before and after split:
- go test ./internal/install -count=1
- go test ./cmd/skillshare -run 'TestRenderInstallWarnings_CompactSuppressesExtraDetails|TestRenderBlockedAuditError_TrackedRepositoryContext' -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|TestInstall_Track_BlocksCritical' -count=1
- go test ./...
2026-02-25 07:02:54 +08:00