mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
feat(updates): allow opting out of automatic version checks (#847)
Add a global automatic-update preference with an environment override, CLI controls and dashboard settings. Suppress automatic release checks and cached notices while retaining explicit checks and upgrades. Recheck policy before publishing in-flight results, preserve structured JSON errors, and reject incomplete manual checks. Include schema, completion, localization, documentation and regression coverage. Closes #846.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# CLI E2E Runbook: Automatic Version Check Preference
|
||||
|
||||
Verify issue #846: global opt-out, environment precedence, silent doctor output and manual check availability.
|
||||
|
||||
## Scope
|
||||
|
||||
- Global preference persists even when called from a project.
|
||||
- A process override does not change the saved preference.
|
||||
- CLI/doctor and the Web version API do not expose cached update notifications while disabled.
|
||||
- Manual checks and upgrades remain supported.
|
||||
|
||||
## Environment
|
||||
|
||||
Run in the devcontainer with a fresh ssenv. Use a current release-version build for the optional live-network manual check.
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Save the opt-out
|
||||
|
||||
```bash
|
||||
ss updates off --json
|
||||
```
|
||||
|
||||
**Expected:**
|
||||
- jq: .enabled == false and .configured == false and .envOverride == false
|
||||
|
||||
### 2. Environment override wins without changing the saved value
|
||||
|
||||
```bash
|
||||
SKILLSHARE_AUTO_UPDATE_CHECK=true ss updates --json
|
||||
```
|
||||
|
||||
**Expected:**
|
||||
- jq: .enabled == true and .configured == false and .envOverride == true
|
||||
|
||||
### 3. Doctor stays quiet about newer versions
|
||||
|
||||
```bash
|
||||
ss updates off --json >/dev/null
|
||||
ss doctor -g --json > "$HOME/updates-doctor.json"
|
||||
result=$?
|
||||
test "$result" -le 1
|
||||
jq '{quiet: (.version.update_available == false and (.version.latest // "") == "")}' "$HOME/updates-doctor.json"
|
||||
```
|
||||
|
||||
**Expected:**
|
||||
- jq: .quiet == true
|
||||
|
||||
### 4. Turn checks back on
|
||||
|
||||
```bash
|
||||
ss updates on --json
|
||||
```
|
||||
|
||||
**Expected:**
|
||||
- jq: .enabled == true and .configured == true and .envOverride == false
|
||||
|
||||
### 5. Manual check and upgrade commands remain discoverable
|
||||
|
||||
```bash
|
||||
ss updates --help
|
||||
ss upgrade --help
|
||||
```
|
||||
|
||||
**Expected:**
|
||||
- Check the CLI version now
|
||||
- skillshare upgrade
|
||||
|
||||
## Pass Criteria
|
||||
|
||||
All automated steps pass. Separately inspect Web Settings and desktop Updates:
|
||||
disable the switch, reload, confirm no update dialog/native notification/version badge,
|
||||
then use the explicit Check action and confirm its result does not re-enable alerts.
|
||||
@@ -14,7 +14,7 @@ _skillshare() {
|
||||
cword=$COMP_CWORD
|
||||
fi
|
||||
|
||||
local commands="init install uninstall link unlink move list search sync mcp hooks plugin status diff backup restore collect pull push commit doctor target project upgrade update check new trash analyze audit hub log ui tui extras enable disable completion version help"
|
||||
local commands="init install uninstall link unlink move list search sync mcp hooks plugin status diff backup restore collect pull push commit doctor target project upgrade updates update check new trash analyze audit hub log ui tui extras enable disable completion version help"
|
||||
|
||||
local global_flags="--project -p --global -g"
|
||||
|
||||
@@ -289,6 +289,7 @@ _skillshare() {
|
||||
commit) COMPREPLY=($(compgen -W "${commit_flags}" -- "${cur}")) ;;
|
||||
doctor) COMPREPLY=($(compgen -W "${doctor_flags} ${global_flags}" -- "${cur}")) ;;
|
||||
target) COMPREPLY=($(compgen -W "${target_flags} ${global_flags}" -- "${cur}")) ;;
|
||||
updates) COMPREPLY=($(compgen -W "on off check --json --help -h" -- "${cur}")) ;;
|
||||
upgrade) COMPREPLY=($(compgen -W "${upgrade_flags} ${global_flags}" -- "${cur}")) ;;
|
||||
update) COMPREPLY=($(compgen -W "${update_flags} ${global_flags}" -- "${cur}")) ;;
|
||||
check) COMPREPLY=($(compgen -W "${check_flags} ${global_flags}" -- "${cur}")) ;;
|
||||
|
||||
@@ -50,6 +50,10 @@ complete -c skillshare -n '__fish_skillshare_using_command project' -l global -s
|
||||
# End project command
|
||||
|
||||
# Commands
|
||||
complete -c skillshare -n __fish_skillshare_no_subcommand -a updates -d 'Control automatic version checks'
|
||||
complete -c skillshare -n '__fish_skillshare_using_command updates' -a 'on off check'
|
||||
complete -c skillshare -n '__fish_skillshare_using_command updates' -l json
|
||||
complete -c skillshare -n '__fish_skillshare_using_command updates' -l help -s h
|
||||
complete -c skillshare -n __fish_skillshare_no_subcommand -a init -d 'Initialize skillshare'
|
||||
complete -c skillshare -n __fish_skillshare_no_subcommand -a install -d 'Install skills/agents from local path or git repo'
|
||||
complete -c skillshare -n __fish_skillshare_no_subcommand -a uninstall -d 'Remove skills/agents from source directory'
|
||||
|
||||
@@ -27,6 +27,7 @@ def "nu-complete skillshare commands" [] {
|
||||
{ value: "doctor", description: "Check environment and diagnose issues" }
|
||||
{ value: "target", description: "Manage targets" }
|
||||
{ value: "project", description: "Manage project folders" }
|
||||
{ value: "updates", description: "Control automatic version checks" }
|
||||
{ value: "upgrade", description: "Upgrade CLI and/or skillshare skill" }
|
||||
{ value: "update", description: "Update skills/agents or tracked repositories" }
|
||||
{ value: "check", description: "Check for available updates" }
|
||||
@@ -47,6 +48,14 @@ def "nu-complete skillshare commands" [] {
|
||||
]
|
||||
}
|
||||
|
||||
# Update preferences
|
||||
def "nu-complete skillshare updates" [] { [on off check] }
|
||||
export extern "skillshare updates" [
|
||||
action?: string@"nu-complete skillshare updates"
|
||||
--json
|
||||
--help(-h)
|
||||
]
|
||||
|
||||
# Project command
|
||||
def "nu-complete skillshare project" [] { [list show add edit sync remove localize share] }
|
||||
def "nu-complete skillshare project-naming" [] { [flat standard prefixed] }
|
||||
|
||||
@@ -30,6 +30,7 @@ $_skillshareCompleter = {
|
||||
@{ Name = 'doctor'; Desc = 'Check environment and diagnose issues' }
|
||||
@{ Name = 'target'; Desc = 'Manage targets' }
|
||||
@{ Name = 'project'; Desc = 'Manage project folders' }
|
||||
@{ Name = 'updates'; Desc = 'Control automatic version checks' }
|
||||
@{ Name = 'upgrade'; Desc = 'Upgrade CLI and/or skillshare skill' }
|
||||
@{ Name = 'update'; Desc = 'Update skills/agents or tracked repositories' }
|
||||
@{ Name = 'check'; Desc = 'Check for available updates' }
|
||||
@@ -177,6 +178,11 @@ $_skillshareCompleter = {
|
||||
'update' = @(
|
||||
@{ Name = 'agents'; Desc = 'Update agents' }
|
||||
)
|
||||
'updates' = @(
|
||||
@{ Name = 'on'; Desc = 'Enable automatic version checks' }
|
||||
@{ Name = 'off'; Desc = 'Disable automatic version checks' }
|
||||
@{ Name = 'check'; Desc = 'Check the CLI version now' }
|
||||
)
|
||||
'tui' = @(
|
||||
@{ Name = 'on'; Desc = 'Enable TUI mode' }
|
||||
@{ Name = 'off'; Desc = 'Disable TUI mode' }
|
||||
@@ -219,6 +225,7 @@ $_skillshareCompleter = {
|
||||
'status' = '--json', '--help', '-h', '--project', '-p', '--global', '-g'
|
||||
'new' = '--pattern', '-P', '--dry-run', '-n', '--help', '-h', '--project', '-p', '--global', '-g'
|
||||
'search' = '--json', '--list', '-l', '--hub', '--limit', '-n', '--help', '-h', '--project', '-p', '--global', '-g'
|
||||
'updates' = '--json', '--help', '-h'
|
||||
'tui' = '--help', '-h'
|
||||
'hooks' = '--file', '--from', '--sync', '--replace', '--keep-files', '--revision', '--dry-run', '-n', '--json', '--help', '-h', '--project', '-p', '--global', '-g'
|
||||
'completion' = '--install', '--help', '-h'
|
||||
|
||||
@@ -28,6 +28,7 @@ _skillshare() {
|
||||
'doctor:Check environment and diagnose issues'
|
||||
'target:Manage targets'
|
||||
'project:Manage project folders'
|
||||
'updates:Control automatic version checks'
|
||||
'upgrade:Upgrade CLI and/or skillshare skill'
|
||||
'update:Update skills/agents or tracked repositories'
|
||||
'check:Check for available updates'
|
||||
@@ -65,6 +66,9 @@ _skillshare() {
|
||||
;;
|
||||
args)
|
||||
case ${words[1]} in
|
||||
updates)
|
||||
_arguments '1:action:(on off check)' '--json[Output JSON]' '--help[Show help]' '-h[Show help]'
|
||||
;;
|
||||
init)
|
||||
_arguments \
|
||||
'--source[Set source directory]:path:_files -/' \
|
||||
|
||||
+43
-11
@@ -26,11 +26,12 @@ import (
|
||||
|
||||
// doctorResult tracks issues and warnings
|
||||
type doctorResult struct {
|
||||
errors int
|
||||
warnings int
|
||||
checks []doctorCheck
|
||||
start time.Time
|
||||
next []string // command and reason pairs for the closing Next
|
||||
errors int
|
||||
warnings int
|
||||
checks []doctorCheck
|
||||
start time.Time
|
||||
next []string // command and reason pairs for the closing Next
|
||||
updateCommands []string // Suggestions belonging to automatic version notices.
|
||||
}
|
||||
|
||||
// doctorWidth aligns the labels of doctor's fixed rows.
|
||||
@@ -58,6 +59,11 @@ func (r *doctorResult) addInfo(name, message string) {
|
||||
r.addCheck(name, checkInfo, message, nil)
|
||||
}
|
||||
|
||||
func (r *doctorResult) suggestUpdate(cmd, why string) {
|
||||
r.suggest(cmd, why)
|
||||
r.updateCommands = append(r.updateCommands, cmd)
|
||||
}
|
||||
|
||||
// suggest adds a command to the closing Next, once each and at most three.
|
||||
func (r *doctorResult) suggest(cmd, why string) {
|
||||
if len(r.next) >= 6 {
|
||||
@@ -118,7 +124,7 @@ func cmdDoctorGlobal(jsonMode bool) error {
|
||||
updateCh := make(chan *versioncheck.CheckResult, 1)
|
||||
go func() { updateCh <- fetchDoctorUpdateResult() }()
|
||||
skillCh := make(chan string, 1)
|
||||
go func() { skillCh <- versioncheck.CachedRemoteSkillVersion() }()
|
||||
go func() { skillCh <- fetchDoctorSkillVersion() }()
|
||||
|
||||
var restoreUI func()
|
||||
if jsonMode {
|
||||
@@ -174,7 +180,7 @@ func cmdDoctorProject(root string, jsonMode bool) error {
|
||||
updateCh := make(chan *versioncheck.CheckResult, 1)
|
||||
go func() { updateCh <- fetchDoctorUpdateResult() }()
|
||||
skillCh := make(chan string, 1)
|
||||
go func() { skillCh <- versioncheck.CachedRemoteSkillVersion() }()
|
||||
go func() { skillCh <- fetchDoctorSkillVersion() }()
|
||||
|
||||
var restoreUI func()
|
||||
if jsonMode {
|
||||
@@ -272,6 +278,21 @@ func runDoctorChecks(cfg *config.Config, result *doctorResult, isProject bool, p
|
||||
}
|
||||
|
||||
func printDoctorSummary(result *doctorResult) {
|
||||
if !config.AutoUpdateCheckEnabled() {
|
||||
quiet := *result
|
||||
quiet.next = nil
|
||||
for i := 0; i+1 < len(result.next); i += 2 {
|
||||
if !slices.Contains(result.updateCommands, result.next[i]) {
|
||||
quiet.next = append(quiet.next, result.next[i:i+2]...)
|
||||
}
|
||||
}
|
||||
for _, check := range result.checks {
|
||||
if check.UpdateAvailable && check.Status == checkWarning {
|
||||
quiet.warnings--
|
||||
}
|
||||
}
|
||||
result = &quiet
|
||||
}
|
||||
fmt.Println()
|
||||
took := time.Since(result.start)
|
||||
switch {
|
||||
@@ -1521,10 +1542,11 @@ func checkVersionDoctor(cfg *config.Config, result *doctorResult, isProject bool
|
||||
return
|
||||
}
|
||||
|
||||
if remote := <-remoteSkill; versioncheck.SkillOutdated(localVersion, remote) {
|
||||
if remote := <-remoteSkill; config.AutoUpdateCheckEnabled() && versioncheck.SkillOutdated(localVersion, remote) {
|
||||
ui.Row(ui.MarkWarn, "Skill", localVersion+" → "+remote+" available", doctorWidth)
|
||||
result.suggest("skillshare upgrade --skill", "update the built-in skill")
|
||||
result.suggestUpdate("skillshare upgrade --skill", "update the built-in skill")
|
||||
result.addCheck("skill_version", checkWarning, fmt.Sprintf("Skill: %s (%s available)", localVersion, remote), nil)
|
||||
result.checks[len(result.checks)-1].UpdateAvailable = true
|
||||
result.addWarning()
|
||||
return
|
||||
}
|
||||
@@ -1535,7 +1557,17 @@ func checkVersionDoctor(cfg *config.Config, result *doctorResult, isProject bool
|
||||
// fetchDoctorUpdateResult checks if a newer version is available.
|
||||
// Uses the shared versioncheck.Check which handles caching, auth, and
|
||||
// proper semver comparison. Safe to call from a goroutine.
|
||||
func fetchDoctorSkillVersion() string {
|
||||
if !config.AutoUpdateCheckEnabled() {
|
||||
return ""
|
||||
}
|
||||
return versioncheck.CachedRemoteSkillVersion()
|
||||
}
|
||||
|
||||
func fetchDoctorUpdateResult() *versioncheck.CheckResult {
|
||||
if !config.AutoUpdateCheckEnabled() {
|
||||
return nil
|
||||
}
|
||||
method := versioncheck.DetectCurrentInstallMethod()
|
||||
if version == "" || version == "dev" {
|
||||
return &versioncheck.CheckResult{
|
||||
@@ -1549,7 +1581,7 @@ func fetchDoctorUpdateResult() *versioncheck.CheckResult {
|
||||
}
|
||||
|
||||
func printUpdateAvailable(update *versioncheck.CheckResult, result *doctorResult) {
|
||||
if update == nil || !update.UpdateAvailable {
|
||||
if update == nil || !update.UpdateAvailable || !config.AutoUpdateCheckEnabled() {
|
||||
return
|
||||
}
|
||||
available := ui.VersionLabel(update.CurrentVersion) + " → " + ui.VersionLabel(update.LatestVersion) + " available"
|
||||
@@ -1559,7 +1591,7 @@ func printUpdateAvailable(update *versioncheck.CheckResult, result *doctorResult
|
||||
}
|
||||
ui.Row(ui.MarkNone, "Update", available, doctorWidth)
|
||||
if cmd != "" {
|
||||
result.suggest(cmd, "update to "+ui.VersionLabel(update.LatestVersion))
|
||||
result.suggestUpdate(cmd, "update to "+ui.VersionLabel(update.LatestVersion))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"skillshare/internal/config"
|
||||
|
||||
versioncheck "skillshare/internal/version"
|
||||
)
|
||||
|
||||
@@ -16,11 +18,12 @@ const (
|
||||
|
||||
// doctorCheck represents a single health check result for JSON output.
|
||||
type doctorCheck struct {
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"` // checkPass, checkWarning, checkError
|
||||
Message string `json:"message"`
|
||||
Details []string `json:"details,omitempty"`
|
||||
Suggestions []string `json:"suggestions,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Status string `json:"status"` // checkPass, checkWarning, checkError
|
||||
Message string `json:"message"`
|
||||
Details []string `json:"details,omitempty"`
|
||||
Suggestions []string `json:"suggestions,omitempty"`
|
||||
UpdateAvailable bool `json:"update_available,omitempty"`
|
||||
}
|
||||
|
||||
type doctorOutput struct {
|
||||
@@ -78,8 +81,19 @@ func buildDoctorOutput(result *doctorResult) doctorOutput {
|
||||
// Shared by cmdDoctorGlobal and cmdDoctorProject.
|
||||
func finalizeDoctorJSON(restoreUI func(), result *doctorResult, updateCh <-chan *versioncheck.CheckResult) error {
|
||||
restoreUI()
|
||||
output := buildDoctorOutput(result)
|
||||
updateResult := <-updateCh
|
||||
if !config.AutoUpdateCheckEnabled() {
|
||||
updateResult = nil
|
||||
quiet := *result
|
||||
quiet.checks = nil
|
||||
for _, check := range result.checks {
|
||||
if !check.UpdateAvailable {
|
||||
quiet.checks = append(quiet.checks, check)
|
||||
}
|
||||
}
|
||||
result = &quiet
|
||||
}
|
||||
output := buildDoctorOutput(result)
|
||||
output.Version = &doctorVersion{Current: version}
|
||||
if updateResult != nil && updateResult.UpdateAvailable {
|
||||
output.Version.Latest = updateResult.LatestVersion
|
||||
@@ -87,8 +101,10 @@ func finalizeDoctorJSON(restoreUI func(), result *doctorResult, updateCh <-chan
|
||||
}
|
||||
if version == "" || version == "dev" {
|
||||
output.Version.DevMode = true
|
||||
output.Version.Latest = "dev-ui-flow"
|
||||
output.Version.UpdateAvailable = true
|
||||
if updateResult != nil {
|
||||
output.Version.Latest = "dev-ui-flow"
|
||||
output.Version.UpdateAvailable = true
|
||||
}
|
||||
}
|
||||
if result.errors > 0 {
|
||||
return writeJSONResult(output, fmt.Errorf("doctor found %d error(s)", result.errors))
|
||||
|
||||
@@ -42,6 +42,7 @@ var commands = map[string]func([]string) error{
|
||||
"target": cmdTarget,
|
||||
"project": cmdProject,
|
||||
"upgrade": cmdUpgrade,
|
||||
"updates": cmdUpdates,
|
||||
"update": cmdUpdate,
|
||||
"check": cmdCheck,
|
||||
"new": cmdNew,
|
||||
@@ -71,7 +72,7 @@ func main() {
|
||||
|
||||
// Project commands must not migrate or rewrite shared config at startup,
|
||||
// so they all skip opportunistic maintenance.
|
||||
skipMaintenance := len(os.Args) > 1 && os.Args[1] == "project" && projectSkipsMaintenance(os.Args[2:])
|
||||
skipMaintenance := len(os.Args) > 1 && (os.Args[1] == "updates" || os.Args[1] == "project" && projectSkipsMaintenance(os.Args[2:]))
|
||||
if !skipMaintenance {
|
||||
cleanupOldBinary()
|
||||
}
|
||||
@@ -170,9 +171,9 @@ func main() {
|
||||
|
||||
// Check for updates (non-blocking, silent on errors)
|
||||
// Skip for upgrade (just upgraded, old version in process) and doctor (has its own check)
|
||||
if !skipMaintenance && cmd != "upgrade" && cmd != "doctor" {
|
||||
if !skipMaintenance && cmd != "upgrade" && cmd != "doctor" && cmd != "updates" && config.AutoUpdateCheckEnabled() {
|
||||
method := versioncheck.DetectCurrentInstallMethod()
|
||||
if result := versioncheck.Check(version, method); result != nil && result.UpdateAvailable {
|
||||
if result := versioncheck.Check(version, method); result != nil && result.UpdateAvailable && config.AutoUpdateCheckEnabled() {
|
||||
ui.UpdateNotification(result.CurrentVersion, result.LatestVersion, result.InstallMethod.UpgradeCommand(), versioncheck.NixConfigUpgradeHint)
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,7 @@ func printUsage() {
|
||||
{"log", "See what ran"},
|
||||
}},
|
||||
helpGroup{title: "Git", rows: []helpRow{{"commit · push · pull", ""}}},
|
||||
helpGroup{title: "CLI", rows: []helpRow{{"upgrade · hub · tui · completion · version", ""}}},
|
||||
helpGroup{title: "CLI", rows: []helpRow{{"upgrade · updates · hub · tui · completion · version", ""}}},
|
||||
helpGroup{title: "Common options", rows: []helpRow{
|
||||
{"-p, --project", "Use this project's config"},
|
||||
{"-g, --global", "Use the global config"},
|
||||
|
||||
@@ -440,7 +440,16 @@ func checkSkillVersion(cfg *config.Config) {
|
||||
}
|
||||
|
||||
skill := cli + theme.Dim().Render(" · ") + "skill " + localVersion
|
||||
switch remoteVersion := versioncheck.CachedRemoteSkillVersion(); {
|
||||
if !config.AutoUpdateCheckEnabled() {
|
||||
fmt.Println(statusLine("Version", skill))
|
||||
return
|
||||
}
|
||||
remoteVersion := versioncheck.CachedRemoteSkillVersion()
|
||||
if !config.AutoUpdateCheckEnabled() {
|
||||
fmt.Println(statusLine("Version", skill))
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case remoteVersion == "":
|
||||
// Offline: show the local version only.
|
||||
fmt.Println(statusLine("Version", skill))
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"skillshare/internal/config"
|
||||
"skillshare/internal/oplog"
|
||||
"skillshare/internal/ui"
|
||||
versioncheck "skillshare/internal/version"
|
||||
)
|
||||
|
||||
func cmdUpdates(args []string) (err error) {
|
||||
if wantsHelp(args) {
|
||||
printUpdatesHelp()
|
||||
return nil
|
||||
}
|
||||
jsonMode := slices.Contains(args, "--json")
|
||||
defer func() {
|
||||
if jsonMode && err != nil {
|
||||
err = writeJSONError(err)
|
||||
}
|
||||
}()
|
||||
action := ""
|
||||
for _, arg := range args {
|
||||
if arg == "--json" {
|
||||
continue
|
||||
}
|
||||
if action != "" {
|
||||
return fmt.Errorf("unexpected argument: %s", arg)
|
||||
}
|
||||
action = arg
|
||||
}
|
||||
switch action {
|
||||
case "", "on", "off":
|
||||
if action != "" {
|
||||
start := time.Now()
|
||||
err := config.SetAutoUpdateCheck(action == "on")
|
||||
e := oplog.NewEntry("updates", statusFromErr(err), time.Since(start))
|
||||
e.Args = map[string]any{"auto_check": action == "on"}
|
||||
if err != nil {
|
||||
e.Message = err.Error()
|
||||
}
|
||||
oplog.WriteWithLimit(config.ConfigPath(), oplog.OpsFile, e, logMaxEntries()) //nolint:errcheck
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
p, err := config.ReadUpdatePolicy()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if jsonMode {
|
||||
return writeJSON(p)
|
||||
}
|
||||
state := "off"
|
||||
if p.Enabled {
|
||||
state = "on"
|
||||
}
|
||||
if p.EnvOverride {
|
||||
state += " · overridden by " + config.AutoUpdateCheckEnv
|
||||
}
|
||||
ui.Row(ui.MarkNone, "Automatic update checks", state, ui.RowWidth("Automatic update checks"))
|
||||
return nil
|
||||
case "check":
|
||||
result, err := versioncheck.CheckNow(version, versioncheck.DetectCurrentInstallMethod())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if jsonMode {
|
||||
return writeJSON(result)
|
||||
}
|
||||
if result.UpdateAvailable {
|
||||
ui.UpdateNotification(result.CurrentVersion, result.LatestVersion, result.InstallMethod.UpgradeCommand(), versioncheck.NixConfigUpgradeHint)
|
||||
} else {
|
||||
ui.Success("CLI is up to date (%s)", result.CurrentVersion)
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("unknown updates action %q (use on, off or check)", action)
|
||||
}
|
||||
}
|
||||
|
||||
func printUpdatesHelp() {
|
||||
printHelp("skillshare updates [on|off|check] [--json]", "Control automatic version checks globally. Manual checks and upgrades remain available.",
|
||||
helpGroup{title: "Actions", rows: []helpRow{
|
||||
{"on / off", "Save updates.auto_check in the global config"},
|
||||
{"check", "Check the CLI version now, even when automatic checks are off"},
|
||||
{"(no action)", "Show the effective preference"},
|
||||
}},
|
||||
helpGroup{title: "Options", rows: []helpRow{{"--json", "Output JSON"}, {"-h, --help", "Show help"}}},
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"skillshare/internal/config"
|
||||
versioncheck "skillshare/internal/version"
|
||||
)
|
||||
|
||||
type updateTestTransport func(*http.Request) (*http.Response, error)
|
||||
|
||||
func (f updateTestTransport) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) }
|
||||
|
||||
func TestStatusVersionOptOutDuringFetch(t *testing.T) {
|
||||
source := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(source, "skillshare"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(source, "skillshare", "SKILL.md"), []byte("---\nmetadata:\n version: 1.0.0\n---\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||||
t.Setenv("SKILLSHARE_CONFIG", path)
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "")
|
||||
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
||||
if err := os.WriteFile(path, []byte("updates: {auto_check: true}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
old := http.DefaultTransport
|
||||
defer func() { http.DefaultTransport = old }()
|
||||
calls := 0
|
||||
http.DefaultTransport = updateTestTransport(func(r *http.Request) (*http.Response, error) {
|
||||
calls++
|
||||
if err := os.WriteFile(path, []byte("updates: {auto_check: false}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader("---\nmetadata:\n version: 9.9.9\n---\n")), Request: r}, nil
|
||||
})
|
||||
out := captureStdout(t, func() { checkSkillVersion(&config.Config{Source: source}) })
|
||||
if calls != 1 || strings.Contains(out, "9.9.9") || strings.Contains(out, "available") {
|
||||
t.Fatalf("inflight update leaked: calls=%d output=%s", calls, out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDoctorOptOutSuppressesBufferedUpdates(t *testing.T) {
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "false")
|
||||
update := &versioncheck.CheckResult{CurrentVersion: "1.0.0", LatestVersion: "9.9.9", UpdateAvailable: true}
|
||||
out := captureStdout(t, func() { printUpdateAvailable(update, &doctorResult{}) })
|
||||
if out != "" {
|
||||
t.Fatalf("buffered text notice leaked: %s", out)
|
||||
}
|
||||
result := &doctorResult{warnings: 2, start: time.Now(), next: []string{"skillshare upgrade --skill", "update the built-in skill", "skillshare sync", "sync targets"}, updateCommands: []string{"skillshare upgrade --skill"}, checks: []doctorCheck{
|
||||
{Name: "skill_version", Status: checkWarning, Message: "update", UpdateAvailable: true},
|
||||
{Name: "config", Status: checkWarning, Message: "unrelated warning"},
|
||||
}}
|
||||
out = captureStdout(t, func() { printDoctorSummary(result) })
|
||||
if strings.Contains(out, "upgrade") || !strings.Contains(out, "1 warning") || !strings.Contains(out, "skillshare sync") {
|
||||
t.Fatalf("buffered summary leaked update or hid diagnostics: %s", out)
|
||||
}
|
||||
ch := make(chan *versioncheck.CheckResult, 1)
|
||||
ch <- update
|
||||
out = captureStdout(t, func() {
|
||||
if err := finalizeDoctorJSON(func() {}, result, ch); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
var body doctorOutput
|
||||
if err := json.Unmarshal([]byte(out), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body.Version.UpdateAvailable || body.Version.Latest != "" || body.Summary.Warnings != 1 || len(body.Checks) != 1 {
|
||||
t.Fatalf("buffered JSON leaked update: %s", out)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUpdatesJSONFailures(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
args []string
|
||||
config string
|
||||
network bool
|
||||
rateLimit bool
|
||||
}{
|
||||
{name: "unknown action", args: []string{"--json", "unknown"}},
|
||||
{name: "unexpected argument before JSON flag", args: []string{"off", "on", "--json"}},
|
||||
{name: "unexpected argument after JSON flag", args: []string{"--json", "off", "on"}},
|
||||
{name: "preference read", args: []string{"--json"}, config: "updates: ["},
|
||||
{name: "preference save on", args: []string{"on", "--json"}, config: "updates: ["},
|
||||
{name: "preference save off", args: []string{"off", "--json"}, config: "updates: ["},
|
||||
{name: "network failure", args: []string{"check", "--json"}, network: true},
|
||||
{name: "rate limit", args: []string{"check", "--json"}, network: true, rateLimit: true},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||||
t.Setenv("SKILLSHARE_CONFIG", path)
|
||||
if err := os.WriteFile(path, []byte(tt.config), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
calls := 0
|
||||
oldTransport := http.DefaultTransport
|
||||
if tt.network {
|
||||
http.DefaultTransport = updateTestTransport(func(r *http.Request) (*http.Response, error) {
|
||||
calls++
|
||||
if !tt.rateLimit {
|
||||
return nil, errors.New("network unavailable")
|
||||
}
|
||||
return &http.Response{StatusCode: http.StatusForbidden, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(`{"message":"API rate limit exceeded"}`)), Request: r}, nil
|
||||
})
|
||||
t.Cleanup(func() { http.DefaultTransport = oldTransport })
|
||||
}
|
||||
var gotErr error
|
||||
out := captureStdout(t, func() { gotErr = cmdUpdates(tt.args) })
|
||||
var silent *jsonSilentError
|
||||
if !errors.As(gotErr, &silent) {
|
||||
t.Fatalf("error must suppress main's text output, got %v", gotErr)
|
||||
}
|
||||
var payload struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(out), &payload); err != nil || payload.Error == "" {
|
||||
t.Fatalf("expected structured JSON error, got %q: %v", out, err)
|
||||
}
|
||||
if tt.network && calls != 1 {
|
||||
t.Fatalf("expected one explicit request, got %d", calls)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdatesPlainFailureRemainsPlain(t *testing.T) {
|
||||
var gotErr error
|
||||
out := captureStdout(t, func() { gotErr = cmdUpdates([]string{"unknown"}) })
|
||||
var silent *jsonSilentError
|
||||
if gotErr == nil || errors.As(gotErr, &silent) || out != "" {
|
||||
t.Fatalf("plain error changed: %v / %q", gotErr, out)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"skillshare/internal/config"
|
||||
versioncheck "skillshare/internal/version"
|
||||
)
|
||||
|
||||
func TestStatusVersionOptOutSuppressesCachedSkillUpdate(t *testing.T) {
|
||||
source := t.TempDir()
|
||||
skill := filepath.Join(source, "skillshare")
|
||||
if err := os.MkdirAll(skill, 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(skill, "SKILL.md"), []byte("---\nmetadata:\n version: 1.0.0\n---\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "false")
|
||||
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
||||
versioncheck.SaveRemoteSkillVersion("9.9.9")
|
||||
out := captureStdout(t, func() { checkSkillVersion(&config.Config{Source: source}) })
|
||||
if strings.Contains(out, "available") || strings.Contains(out, "9.9.9") {
|
||||
t.Fatalf("disabled status leaked update: %s", out)
|
||||
}
|
||||
if !strings.Contains(out, "1.0.0") {
|
||||
t.Fatalf("missing local version: %s", out)
|
||||
}
|
||||
}
|
||||
@@ -415,6 +415,7 @@ type Config struct {
|
||||
Hub HubConfig `yaml:"hub,omitempty"`
|
||||
Log LogConfig `yaml:"log,omitempty"`
|
||||
Backup BackupConfig `yaml:"backup,omitempty"`
|
||||
Updates UpdatesConfig `yaml:"updates,omitempty"`
|
||||
ContextBudget ContextBudgetConfig `yaml:"context_budget,omitempty"`
|
||||
TUI *bool `yaml:"tui,omitempty"` // nil = default true
|
||||
GitLabHosts []string `yaml:"gitlab_hosts,omitempty"`
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
var configSections = []string{
|
||||
"sources", "source", "agents_source", "extras_source", "git_root", "mode", "target_naming",
|
||||
"targets", "skills", "agents", "extras", "mcp", "plugins", "hooks",
|
||||
"projects", "hub", "log", "context_budget", "tui", "gitlab_hosts", "azure_hosts", "ignore", "audit",
|
||||
"updates", "projects", "hub", "log", "context_budget", "tui", "gitlab_hosts", "azure_hosts", "ignore", "audit",
|
||||
}
|
||||
|
||||
// marshalConfig encodes v the way the dashboard's Beautify lays out a config:
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
const AutoUpdateCheckEnv = "SKILLSHARE_AUTO_UPDATE_CHECK"
|
||||
|
||||
type UpdatesConfig struct {
|
||||
AutoCheck *bool `yaml:"auto_check,omitempty"`
|
||||
}
|
||||
|
||||
// UpdatePolicy keeps the saved preference separate from its process-local override.
|
||||
type UpdatePolicy struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Configured bool `json:"configured"`
|
||||
EnvOverride bool `json:"envOverride"`
|
||||
}
|
||||
|
||||
func (c UpdatesConfig) Policy() UpdatePolicy {
|
||||
configured := c.AutoCheck == nil || *c.AutoCheck
|
||||
p := UpdatePolicy{Enabled: configured, Configured: configured}
|
||||
if value, err := strconv.ParseBool(strings.TrimSpace(os.Getenv(AutoUpdateCheckEnv))); err == nil {
|
||||
p.Enabled, p.EnvOverride = value, true
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
// ReadUpdatePolicy reads only the global preference, without migrations or source discovery.
|
||||
func ReadUpdatePolicy() (UpdatePolicy, error) {
|
||||
var cfg struct {
|
||||
Updates UpdatesConfig `yaml:"updates"`
|
||||
}
|
||||
data, err := os.ReadFile(ReadOnlyConfigPath())
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return UpdatePolicy{}, err
|
||||
}
|
||||
if err == nil {
|
||||
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
||||
return UpdatePolicy{}, err
|
||||
}
|
||||
}
|
||||
return cfg.Updates.Policy(), nil
|
||||
}
|
||||
|
||||
// AutoUpdateCheckEnabled fails quiet when the config cannot be read.
|
||||
func AutoUpdateCheckEnabled() bool {
|
||||
p, err := ReadUpdatePolicy()
|
||||
return err == nil && p.Enabled
|
||||
}
|
||||
|
||||
func SetAutoUpdateCheck(enabled bool) error {
|
||||
path := ReadOnlyConfigPath()
|
||||
cfg, err := LoadReadOnlyPath(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cfg.Updates.AutoCheck = &enabled
|
||||
candidate, err := PrepareSave(path, cfg)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to prepare config: %w", err)
|
||||
}
|
||||
return candidate.Write()
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// An opt-out must suppress even a cached update, and env overrides must not be persisted.
|
||||
func TestUpdatePolicy(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
name, yaml, env string
|
||||
configured, enabled, overridden bool
|
||||
}{
|
||||
{"default", "targets: {}\n", "", true, true, false},
|
||||
{"disabled", "updates:\n auto_check: false\n", "", false, false, false},
|
||||
{"env disables", "updates:\n auto_check: true\n", "false", true, false, true},
|
||||
{"env enables", "updates:\n auto_check: false\n", "1", false, true, true},
|
||||
{"invalid env ignored", "updates:\n auto_check: false\n", "invalid", false, false, false},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||||
t.Setenv("SKILLSHARE_CONFIG", path)
|
||||
t.Setenv("SKILLSHARE_AUTO_UPDATE_CHECK", tt.env)
|
||||
if err := os.WriteFile(path, []byte(tt.yaml), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p, err := ReadUpdatePolicy()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p.Configured != tt.configured || p.Enabled != tt.enabled || p.EnvOverride != tt.overridden {
|
||||
t.Fatalf("policy = %+v", p)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdatePolicyMissingAndInvalidConfig(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||||
t.Setenv("SKILLSHARE_CONFIG", path)
|
||||
t.Setenv("SKILLSHARE_AUTO_UPDATE_CHECK", "")
|
||||
p, err := ReadUpdatePolicy()
|
||||
if err != nil || !p.Enabled {
|
||||
t.Fatalf("missing config: %+v, %v", p, err)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte("updates: ["), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := ReadUpdatePolicy(); err == nil {
|
||||
t.Fatal("invalid YAML must not enable background checks")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetAutoUpdateCheckPreservesConfig(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||||
t.Setenv("SKILLSHARE_CONFIG", path)
|
||||
t.Setenv("SKILLSHARE_AUTO_UPDATE_CHECK", "true")
|
||||
if err := os.WriteFile(path, []byte("# my config\nmode: copy\ntargets: {}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := SetAutoUpdateCheck(false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg, err := LoadReadOnly()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.Mode != "copy" || cfg.Updates.AutoCheck == nil || *cfg.Updates.AutoCheck {
|
||||
t.Fatalf("saved config = %+v", cfg)
|
||||
}
|
||||
p, err := ReadUpdatePolicy()
|
||||
if err != nil || !p.Enabled || p.Configured {
|
||||
t.Fatalf("policy = %+v, %v", p, err)
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ func (s *Server) handlePatchConfig(w http.ResponseWriter, r *http.Request) {
|
||||
LogMaxEntries *int `json:"logMaxEntries"`
|
||||
BackupMaxCount *int `json:"backupMaxCount"`
|
||||
BackupMaxSizeMB *int64 `json:"backupMaxSizeMB"`
|
||||
AutoUpdateCheck *bool `json:"autoUpdateCheck"`
|
||||
}
|
||||
if err := decodeJSON(w, r, &body, defaultJSONBodyLimit); err != nil {
|
||||
if !errors.Is(err, errBodyTooLarge) {
|
||||
@@ -59,8 +60,8 @@ func (s *Server) handlePatchConfig(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if body.Mode == nil && body.LogMaxEntries == nil && body.BackupMaxCount == nil && body.BackupMaxSizeMB == nil {
|
||||
writeError(w, http.StatusBadRequest, "mode, logMaxEntries, backupMaxCount or backupMaxSizeMB is required")
|
||||
if body.Mode == nil && body.LogMaxEntries == nil && body.BackupMaxCount == nil && body.BackupMaxSizeMB == nil && body.AutoUpdateCheck == nil {
|
||||
writeError(w, http.StatusBadRequest, "mode, logMaxEntries, backupMaxCount, backupMaxSizeMB or autoUpdateCheck is required")
|
||||
return
|
||||
}
|
||||
if body.Mode != nil && !slices.Contains(syncModes, *body.Mode) {
|
||||
@@ -84,6 +85,10 @@ func (s *Server) handlePatchConfig(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
// /api/config skips the auto-reload middleware, so pick up outside edits before writing.
|
||||
_ = s.reloadConfig()
|
||||
if body.AutoUpdateCheck != nil && s.cfg.Updates.Policy().EnvOverride {
|
||||
writeError(w, http.StatusConflict, "automatic update checks are controlled by "+config.AutoUpdateCheckEnv)
|
||||
return
|
||||
}
|
||||
args := map[string]any{"scope": "ui"}
|
||||
if body.Mode != nil {
|
||||
// Targets that inherit the mode must still be able to honour their naming.
|
||||
@@ -101,6 +106,10 @@ func (s *Server) handlePatchConfig(w http.ResponseWriter, r *http.Request) {
|
||||
s.cfg.Mode = *body.Mode
|
||||
args["mode"] = *body.Mode
|
||||
}
|
||||
if body.AutoUpdateCheck != nil {
|
||||
s.cfg.Updates.AutoCheck = body.AutoUpdateCheck
|
||||
args["auto_check"] = *body.AutoUpdateCheck
|
||||
}
|
||||
if body.LogMaxEntries != nil {
|
||||
s.cfg.Log.MaxEntries = body.LogMaxEntries
|
||||
args["log_max_entries"] = *body.LogMaxEntries
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"skillshare/internal/config"
|
||||
|
||||
"skillshare/internal/theme"
|
||||
)
|
||||
|
||||
@@ -36,8 +38,12 @@ func (s *Server) handleDoctor(w http.ResponseWriter, r *http.Request) {
|
||||
// internal env var so doctor reports "auto-detected", not "set via
|
||||
// SKILLSHARE_THEME" — the user didn't set anything.
|
||||
tm := theme.Get()
|
||||
globalConfigPath := s.configPath()
|
||||
if s.IsProjectMode() {
|
||||
globalConfigPath = config.ReadOnlyConfigPath()
|
||||
}
|
||||
cmd.Env = append(os.Environ(),
|
||||
"SKILLSHARE_CONFIG="+s.configPath(),
|
||||
"SKILLSHARE_CONFIG="+globalConfigPath,
|
||||
"_SKILLSHARE_THEME_FORWARDED="+string(tm.Mode),
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"skillshare/internal/config"
|
||||
versioncheck "skillshare/internal/version"
|
||||
)
|
||||
|
||||
type updateRoundTrip func(*http.Request) (*http.Response, error)
|
||||
|
||||
func (f updateRoundTrip) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) }
|
||||
|
||||
func TestVersionCheckRechecksPolicyBeforePublishing(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||||
t.Setenv("SKILLSHARE_CONFIG", path)
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "")
|
||||
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
||||
if err := os.WriteFile(path, []byte("updates: {auto_check: true}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
oldVersion, oldTransport := versioncheck.Version, http.DefaultTransport
|
||||
versioncheck.Version = "1.0.0"
|
||||
defer func() { versioncheck.Version = oldVersion; http.DefaultTransport = oldTransport }()
|
||||
calls := 0
|
||||
http.DefaultTransport = updateRoundTrip(func(r *http.Request) (*http.Response, error) {
|
||||
calls++
|
||||
if err := os.WriteFile(path, []byte("updates: {auto_check: false}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(`{"tag_name":"v9.9.9"}`)), Request: r}, nil
|
||||
})
|
||||
source := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(source, "skillshare"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(source, "skillshare", "SKILL.md"), []byte("---\nmetadata:\n version: 1.0.0\n---\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rec := httptest.NewRecorder()
|
||||
(&Server{cfg: &config.Config{Source: source}}).handleVersionCheck(rec, httptest.NewRequest(http.MethodGet, "/api/version", nil))
|
||||
var body map[string]any
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if calls != 1 || body["autoCheckEnabled"] != false || body["cliUpdateAvailable"] != false || body["cliLatest"] != nil {
|
||||
t.Fatalf("inflight opt-out leaked: calls=%d body=%s", calls, rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestManualVersionCheckSkillResult(t *testing.T) {
|
||||
for _, project := range []bool{false, true} {
|
||||
mode := "global"
|
||||
if project {
|
||||
mode = "project"
|
||||
}
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
status int
|
||||
body string
|
||||
networkError bool
|
||||
wantStatus int
|
||||
}{
|
||||
{name: "network failure", networkError: true, wantStatus: http.StatusBadGateway},
|
||||
{name: "HTTP failure", status: http.StatusServiceUnavailable, wantStatus: http.StatusBadGateway},
|
||||
{name: "missing version", status: http.StatusOK, body: "---\nname: skillshare\n---\n", wantStatus: http.StatusBadGateway},
|
||||
{name: "current", status: http.StatusOK, body: "---\nmetadata:\n version: 1.0.0\n---\n", wantStatus: http.StatusOK},
|
||||
} {
|
||||
t.Run(mode+"/"+tt.name, func(t *testing.T) {
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "false")
|
||||
source := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(source, "skillshare"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(source, "skillshare", "SKILL.md"), []byte("---\nmetadata:\n version: 1.0.0\n---\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||||
if err := os.WriteFile(path, []byte("source: "+source+"\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("SKILLSHARE_CONFIG", path)
|
||||
oldVersion, oldTransport := versioncheck.Version, http.DefaultTransport
|
||||
versioncheck.Version = "1.0.0"
|
||||
t.Cleanup(func() { versioncheck.Version = oldVersion; http.DefaultTransport = oldTransport })
|
||||
calls := 0
|
||||
http.DefaultTransport = updateRoundTrip(func(r *http.Request) (*http.Response, error) {
|
||||
calls++
|
||||
status, body := http.StatusOK, `{"tag_name":"v1.0.0"}`
|
||||
if r.URL.String() == versioncheck.SkillSourceURL {
|
||||
if tt.networkError {
|
||||
return nil, errors.New("skill request failed")
|
||||
}
|
||||
status, body = tt.status, tt.body
|
||||
}
|
||||
return &http.Response{StatusCode: status, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(body)), Request: r}, nil
|
||||
})
|
||||
s := &Server{cfg: &config.Config{Source: source}}
|
||||
if project {
|
||||
s.projectRoot = t.TempDir()
|
||||
s.cfg.Source = t.TempDir()
|
||||
}
|
||||
rec := httptest.NewRecorder()
|
||||
s.handleVersionCheck(rec, httptest.NewRequest(http.MethodGet, "/api/version?manual=true", nil))
|
||||
if rec.Code != tt.wantStatus || calls != 2 {
|
||||
t.Fatalf("status=%d calls=%d body=%s", rec.Code, calls, rec.Body.String())
|
||||
}
|
||||
var body map[string]any
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if tt.wantStatus != http.StatusOK {
|
||||
if body["error"] != "failed to check built-in skill version" {
|
||||
t.Fatalf("missing check failure: %s", rec.Body.String())
|
||||
}
|
||||
} else if body["skillLatest"] != "1.0.0" || body["skillUpdateAvailable"] != false || body["cliUpdateAvailable"] != false {
|
||||
t.Fatalf("current versions not verified: %s", rec.Body.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPatchUpdatePreference(t *testing.T) {
|
||||
s, _ := newTestServer(t)
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "")
|
||||
rec := httptest.NewRecorder()
|
||||
s.handlePatchConfig(rec, httptest.NewRequest(http.MethodPatch, "/api/config", strings.NewReader(`{"autoUpdateCheck":false}`)))
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("patch: %d %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
policy, err := config.ReadUpdatePolicy()
|
||||
if err != nil || policy.Enabled {
|
||||
t.Fatalf("saved preference: %+v %v", policy, err)
|
||||
}
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "true")
|
||||
rec = httptest.NewRecorder()
|
||||
s.handlePatchConfig(rec, httptest.NewRequest(http.MethodPatch, "/api/config", strings.NewReader(`{"autoUpdateCheck":false}`)))
|
||||
if rec.Code != http.StatusConflict {
|
||||
t.Fatalf("env must own effective setting: %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestManualVersionCheckRemainsAvailableWhenDisabled(t *testing.T) {
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "false")
|
||||
old := versioncheck.Version
|
||||
versioncheck.Version = "dev"
|
||||
defer func() { versioncheck.Version = old }()
|
||||
s := &Server{cfg: &config.Config{Source: t.TempDir()}}
|
||||
rec := httptest.NewRecorder()
|
||||
s.handleVersionCheck(rec, httptest.NewRequest(http.MethodGet, "/api/version?manual=true", nil))
|
||||
var body map[string]any
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["cliUpdateAvailable"] != true || body["autoCheckEnabled"] != false {
|
||||
t.Fatalf("manual check blocked: %s", rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestVersionCheckDisabledSuppressesCachedUpdates(t *testing.T) {
|
||||
t.Setenv("SKILLSHARE_AUTO_UPDATE_CHECK", "")
|
||||
t.Setenv("XDG_CACHE_HOME", t.TempDir())
|
||||
versioncheck.SaveRemoteSkillVersion("9.9.9")
|
||||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||||
t.Setenv("SKILLSHARE_CONFIG", path)
|
||||
if err := os.WriteFile(path, []byte("updates:\n auto_check: false\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s := &Server{cfg: &config.Config{Source: t.TempDir()}}
|
||||
rec := httptest.NewRecorder()
|
||||
s.handleVersionCheck(rec, httptest.NewRequest(http.MethodGet, "/api/version", nil))
|
||||
var body map[string]any
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if body["cliUpdateAvailable"] != false || body["skillUpdateAvailable"] != false || body["cliLatest"] != nil || body["skillLatest"] != nil {
|
||||
t.Fatalf("disabled check leaked an update: %s", rec.Body.String())
|
||||
}
|
||||
if body["autoCheckEnabled"] != false {
|
||||
t.Fatalf("policy missing: %s", rec.Body.String())
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,15 @@ import (
|
||||
versioncheck "skillshare/internal/version"
|
||||
)
|
||||
|
||||
func (s *Server) handleUpdatePolicy(w http.ResponseWriter, r *http.Request) {
|
||||
policy, err := config.ReadUpdatePolicy()
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
writeJSON(w, policy)
|
||||
}
|
||||
|
||||
func (s *Server) handleVersionCheck(w http.ResponseWriter, r *http.Request) {
|
||||
// Snapshot config under RLock, then release before I/O.
|
||||
s.mu.RLock()
|
||||
@@ -15,6 +24,13 @@ func (s *Server) handleVersionCheck(w http.ResponseWriter, r *http.Request) {
|
||||
s.mu.RUnlock()
|
||||
|
||||
isProjectMode := projectRoot != ""
|
||||
policy, err := config.ReadUpdatePolicy()
|
||||
if err != nil {
|
||||
writeError(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
manual := r.URL.Query().Get("manual") == "true"
|
||||
check := policy.Enabled || manual
|
||||
|
||||
cliVersion := versioncheck.Version
|
||||
method := detectUIInstallMethod()
|
||||
@@ -23,14 +39,27 @@ func (s *Server) handleVersionCheck(w http.ResponseWriter, r *http.Request) {
|
||||
cliDevMode := cliVersion == "" || cliVersion == "dev"
|
||||
|
||||
// Dev builds expose a simulated update so the browser update/restart flow can be tested.
|
||||
if cliDevMode {
|
||||
if check && cliDevMode {
|
||||
latest := "dev-ui-flow"
|
||||
cliUpdateAvailable = true
|
||||
cliLatest = &latest
|
||||
} else if result := versioncheck.Check(cliVersion, versioncheck.InstallDirect); result != nil {
|
||||
// CLI version check (uses 24h cache)
|
||||
cliUpdateAvailable = result.UpdateAvailable
|
||||
cliLatest = &result.LatestVersion
|
||||
} else if check {
|
||||
var result *versioncheck.CheckResult
|
||||
if manual {
|
||||
var err error
|
||||
result, err = versioncheck.CheckNow(cliVersion, method)
|
||||
if err != nil {
|
||||
writeError(w, http.StatusBadGateway, err.Error())
|
||||
return
|
||||
}
|
||||
} else {
|
||||
result = versioncheck.Check(cliVersion, method)
|
||||
}
|
||||
if result != nil {
|
||||
// CLI version check (uses 24h cache)
|
||||
cliUpdateAvailable = result.UpdateAvailable
|
||||
cliLatest = &result.LatestVersion
|
||||
}
|
||||
}
|
||||
|
||||
// `skillshare upgrade` updates both everywhere but leaves a Nix-store CLI
|
||||
@@ -44,8 +73,8 @@ func (s *Server) handleVersionCheck(w http.ResponseWriter, r *http.Request) {
|
||||
// Skill version (local) — always check global source for built-in skill
|
||||
skillSourceDir := source
|
||||
if isProjectMode {
|
||||
if globalCfg, err := config.Load(); err == nil {
|
||||
skillSourceDir = globalCfg.Source
|
||||
if globalCfg, err := config.LoadReadOnly(); err == nil {
|
||||
skillSourceDir = globalCfg.EffectiveSkillsSource()
|
||||
}
|
||||
}
|
||||
skillVersion := versioncheck.ReadLocalSkillVersion(skillSourceDir)
|
||||
@@ -53,14 +82,34 @@ func (s *Server) handleVersionCheck(w http.ResponseWriter, r *http.Request) {
|
||||
// Skill version (remote) — uses 24h cache, network call with 3s timeout
|
||||
var skillLatest *string
|
||||
skillUpdateAvailable := false
|
||||
if skillVersion != "" {
|
||||
if remote := versioncheck.CachedRemoteSkillVersion(); remote != "" {
|
||||
if check && skillVersion != "" && (manual || config.AutoUpdateCheckEnabled()) {
|
||||
var remote string
|
||||
if manual {
|
||||
remote = versioncheck.FetchRemoteSkillVersion()
|
||||
if remote == "" {
|
||||
writeError(w, http.StatusBadGateway, "failed to check built-in skill version")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
remote = versioncheck.CachedRemoteSkillVersion()
|
||||
}
|
||||
if remote != "" {
|
||||
skillLatest = &remote
|
||||
skillUpdateAvailable = versioncheck.SkillOutdated(skillVersion, remote)
|
||||
}
|
||||
}
|
||||
|
||||
if !manual {
|
||||
policy, err = config.ReadUpdatePolicy()
|
||||
if err != nil || !policy.Enabled {
|
||||
cliLatest, skillLatest = nil, nil
|
||||
cliUpdateAvailable, skillUpdateAvailable = false, false
|
||||
}
|
||||
}
|
||||
writeJSON(w, map[string]any{
|
||||
"autoCheckEnabled": policy.Enabled,
|
||||
"autoCheckConfigured": policy.Configured,
|
||||
"autoCheckEnvOverride": policy.EnvOverride,
|
||||
"cliVersion": cliVersion,
|
||||
"cliLatest": cliLatest,
|
||||
"cliUpdateAvailable": cliUpdateAvailable,
|
||||
|
||||
@@ -384,7 +384,7 @@ func (s *Server) shouldAutoReloadConfig(path string) bool {
|
||||
if !strings.HasPrefix(path, "/api/") {
|
||||
return false
|
||||
}
|
||||
if path == "/api/health" {
|
||||
if path == "/api/health" || path == "/api/update-settings" {
|
||||
return false
|
||||
}
|
||||
// Project handlers reload without persisting legacy migrations, after taking
|
||||
@@ -479,6 +479,7 @@ func (s *Server) StartWithContext(ctx context.Context) error {
|
||||
func (s *Server) registerRoutes() {
|
||||
// Health check
|
||||
s.mux.HandleFunc("GET /api/health", s.handleHealth)
|
||||
s.mux.HandleFunc("GET /api/update-settings", s.handleUpdatePolicy)
|
||||
|
||||
// Overview
|
||||
s.mux.HandleFunc("GET /api/overview", s.handleOverview)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package version
|
||||
|
||||
// CheckNow bypasses the automatic-check policy and cache for an explicit request.
|
||||
func CheckNow(current string, method InstallMethod) (*CheckResult, error) {
|
||||
var latest string
|
||||
var err error
|
||||
if method == InstallBrew {
|
||||
latest, err = FetchBrewLatestVersion()
|
||||
} else {
|
||||
latest, err = FetchLatestVersionOnly()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
available, err := compareVersions(current, latest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &CheckResult{CurrentVersion: current, LatestVersion: latest, UpdateAvailable: available, InstallMethod: method}, nil
|
||||
}
|
||||
@@ -27,6 +27,14 @@
|
||||
"default": "~/.config/skillshare/extras",
|
||||
"examples": ["~/.config/skillshare/extras"]
|
||||
},
|
||||
"updates": {
|
||||
"type": "object",
|
||||
"description": "Automatic version checks and notifications for the CLI, built-in skill and desktop app. Manual checks and upgrades remain available.",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"auto_check": { "type": "boolean", "default": true, "description": "Overridden by SKILLSHARE_AUTO_UPDATE_CHECK." }
|
||||
}
|
||||
},
|
||||
"log": {
|
||||
"type": "object",
|
||||
"description": "Operation log retention.",
|
||||
|
||||
@@ -88,6 +88,17 @@ Use `skillshare analyze --json` to inspect description/body size and estimated c
|
||||
cost per target. Estimates describe loaded skill text, not measured billing or cache savings.
|
||||
Use `--no-tui` for plain terminal output.
|
||||
|
||||
## updates
|
||||
|
||||
Automatic release-version checks and notifications are enabled by default.
|
||||
Use `skillshare updates off` / `on` to save global `updates.auto_check`, even from
|
||||
a project directory. `skillshare updates --json` reports `enabled`, `configured`
|
||||
and `envOverride`. `SKILLSHARE_AUTO_UPDATE_CHECK=false` overrides the saved value
|
||||
without writing it. The CLI, dashboard and desktop app share the preference.
|
||||
Disabled checks suppress cached notifications, dialogs and desktop version badges.
|
||||
Manual `skillshare updates check` (CLI version), UI check buttons and upgrades remain
|
||||
available. Source updates for installed resources are unaffected.
|
||||
|
||||
## upgrade
|
||||
|
||||
Upgrade CLI binary and/or built-in skillshare skill.
|
||||
|
||||
@@ -16,6 +16,16 @@ import (
|
||||
"skillshare/internal/testutil"
|
||||
)
|
||||
|
||||
func TestCompletion_Updates_AllShells(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
for _, shell := range []string{"bash", "zsh", "fish", "powershell", "nushell"} {
|
||||
result := sb.RunCLI("completion", shell)
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "updates")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompletion_Bash_OutputsScript(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
//go:build !online
|
||||
|
||||
package integration
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"skillshare/internal/config"
|
||||
"skillshare/internal/testutil"
|
||||
)
|
||||
|
||||
func TestUpdates_GlobalPreferenceAndDoctor(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
t.Setenv(config.AutoUpdateCheckEnv, "")
|
||||
if err := os.WriteFile(sb.ConfigPath, []byte("source: "+sb.SourcePath+"\nmode: copy\ntargets: {}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
project := filepath.Join(sb.Root, "project")
|
||||
if err := os.MkdirAll(filepath.Join(project, ".skillshare"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(project, ".skillshare", "config.yaml"), []byte("targets: {}\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Even from a project, updates changes the user's global preference.
|
||||
result := sb.RunCLIInDir(project, "updates", "off", "--json")
|
||||
result.AssertSuccess(t)
|
||||
var policy config.UpdatePolicy
|
||||
if err := json.Unmarshal([]byte(result.Stdout), &policy); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if policy.Enabled || policy.Configured {
|
||||
t.Fatalf("policy = %+v", policy)
|
||||
}
|
||||
cfg, err := config.LoadReadOnly()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.Mode != "copy" || cfg.Updates.AutoCheck == nil || *cfg.Updates.AutoCheck {
|
||||
t.Fatalf("saved preference lost: %+v", cfg)
|
||||
}
|
||||
for _, mode := range []string{"-g", "-p"} {
|
||||
result = sb.RunCLIInDir(project, "doctor", mode, "--json")
|
||||
var out struct {
|
||||
Version struct {
|
||||
Latest string
|
||||
UpdateAvailable bool `json:"update_available"`
|
||||
}
|
||||
}
|
||||
if err := json.Unmarshal([]byte(result.Stdout), &out); err != nil {
|
||||
t.Fatalf("doctor JSON: %s / %v", result.Stdout, err)
|
||||
}
|
||||
if out.Version.UpdateAvailable || out.Version.Latest != "" {
|
||||
t.Fatalf("doctor leaked update while disabled: %s", result.Stdout)
|
||||
}
|
||||
}
|
||||
result = sb.RunCLIEnv(map[string]string{config.AutoUpdateCheckEnv: "true"}, "updates", "--json")
|
||||
result.AssertSuccess(t)
|
||||
if err := json.Unmarshal([]byte(result.Stdout), &policy); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !policy.Enabled || !policy.EnvOverride || policy.Configured {
|
||||
t.Fatalf("override = %+v", policy)
|
||||
}
|
||||
result = sb.RunCLI("updates", "on", "--json")
|
||||
result.AssertSuccess(t)
|
||||
if err := json.Unmarshal([]byte(result.Stdout), &policy); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !policy.Enabled || !policy.Configured {
|
||||
t.Fatalf("re-enabled = %+v", policy)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdates_JSONFailures(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
args []string
|
||||
malformed bool
|
||||
}{
|
||||
{name: "unknown action", args: []string{"updates", "--json", "unknown"}},
|
||||
{name: "late JSON flag", args: []string{"updates", "off", "on", "--json"}},
|
||||
{name: "early JSON flag", args: []string{"updates", "--json", "off", "on"}},
|
||||
{name: "read error", args: []string{"updates", "--json"}, malformed: true},
|
||||
{name: "save error", args: []string{"updates", "off", "--json"}, malformed: true},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
data := "source: " + sb.SourcePath + "\nmode: copy\ntargets: {}\n"
|
||||
if tt.malformed {
|
||||
data = "updates: ["
|
||||
}
|
||||
if err := os.WriteFile(sb.ConfigPath, []byte(data), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result := sb.RunCLI(tt.args...)
|
||||
var payload struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
if result.ExitCode != 1 || result.Stderr != "" {
|
||||
t.Fatalf("unexpected exit/stderr: %+v", result)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(result.Stdout), &payload); err != nil || payload.Error == "" {
|
||||
t.Fatalf("JSON error contaminated: %q / %v", result.Stdout, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdates_RejectsUnexpectedArguments(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
for _, args := range [][]string{{"updates", "off", "on"}, {"updates", "--project"}, {"updates", "unknown"}} {
|
||||
if result := sb.RunCLI(args...); result.ExitCode == 0 {
|
||||
t.Fatalf("%v should fail", args)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import type { AgentignoreResponse, AvailableTarget, ConfigSaveResponse, Skillign
|
||||
export const configApi = {
|
||||
getConfig: () => apiFetch<{ config: unknown; raw: string }>('/config'),
|
||||
/** Settings the Settings page owns; the rest of config.yaml stays untouched. */
|
||||
patchConfig: (body: { mode?: string; logMaxEntries?: number; backupMaxCount?: number; backupMaxSizeMB?: number }) =>
|
||||
patchConfig: (body: { mode?: string; logMaxEntries?: number; backupMaxCount?: number; backupMaxSizeMB?: number; autoUpdateCheck?: boolean }) =>
|
||||
apiFetch<{ mode: string; logMaxEntries: number | null }>('/config', {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(body),
|
||||
|
||||
@@ -2,7 +2,8 @@ import { apiFetch } from './http';
|
||||
import type { AnalyzeResponse, DoctorResponse, VersionCheck } from './types/diagnostics';
|
||||
|
||||
export const systemApi = {
|
||||
getVersionCheck: () => apiFetch<VersionCheck>('/version'),
|
||||
getUpdatePolicy: () => apiFetch<{ enabled: boolean; configured: boolean; envOverride: boolean }>('/update-settings'),
|
||||
getVersionCheck: (manual = false) => apiFetch<VersionCheck>(manual ? '/version?manual=true' : '/version'),
|
||||
upgradeApp: () => apiFetch<{ ok: boolean; updated: boolean; devMode?: boolean; latestVersion?: string; output?: string }>('/upgrade', { method: 'POST' }),
|
||||
restartApp: (opts?: { clearCache?: boolean }) =>
|
||||
apiFetch<{ ok: boolean; restarting: boolean }>('/restart', {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export interface VersionCheck {
|
||||
autoCheckEnabled?: boolean;
|
||||
autoCheckConfigured?: boolean;
|
||||
autoCheckEnvOverride?: boolean;
|
||||
cliVersion: string;
|
||||
cliLatest?: string;
|
||||
cliUpdateAvailable: boolean;
|
||||
@@ -12,6 +15,7 @@ export interface VersionCheck {
|
||||
|
||||
// Doctor health check types
|
||||
export interface DoctorCheck {
|
||||
update_available?: boolean;
|
||||
name: string;
|
||||
status: 'pass' | 'warning' | 'error' | 'info';
|
||||
message: string;
|
||||
|
||||
@@ -12,6 +12,7 @@ vi.mock('../api/client', async (importOriginal) => {
|
||||
...actual,
|
||||
api: {
|
||||
...actual.api,
|
||||
getUpdatePolicy: vi.fn().mockResolvedValue({ enabled: true, configured: true, envOverride: false }),
|
||||
getVersionCheck: vi.fn().mockResolvedValue({
|
||||
cliVersion: '0.21.12',
|
||||
cliLatest: '0.21.13',
|
||||
@@ -28,6 +29,21 @@ vi.mock('../api/client', async (importOriginal) => {
|
||||
});
|
||||
|
||||
describe('UpdateDialog', () => {
|
||||
it('allows an explicitly requested upgrade while automatic checks are disabled', async () => {
|
||||
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
vi.mocked(api.getUpdatePolicy).mockResolvedValueOnce({ enabled: false, configured: false, envOverride: false });
|
||||
vi.mocked(api.upgradeApp).mockResolvedValueOnce({ ok: true, updated: true, devMode: true, latestVersion: '9.9.9' });
|
||||
const onDismiss = vi.fn();
|
||||
render(
|
||||
<QueryClientProvider client={queryClient}><I18nProvider>
|
||||
<UpdateDialog onDismiss={onDismiss} manualData={{ autoCheckEnabled: false, cliDevMode: true, cliVersion: '1.0.0', cliLatest: '9.9.9', cliUpdateAvailable: true, skillVersion: '', skillUpdateAvailable: false }} />
|
||||
</I18nProvider></QueryClientProvider>,
|
||||
);
|
||||
await userEvent.click(await screen.findByRole('button', { name: /Update now/ }));
|
||||
await waitFor(() => expect(api.upgradeApp).toHaveBeenCalled());
|
||||
await waitFor(() => expect(onDismiss).toHaveBeenCalledOnce(), { timeout: 2000 });
|
||||
});
|
||||
|
||||
it('keeps the UI the upgrade just downloaded when restarting', async () => {
|
||||
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
render(
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { VersionCheck } from '../api/client';
|
||||
import DialogShell from './DialogShell';
|
||||
import Button from './Button';
|
||||
import { useT } from '../i18n';
|
||||
import { useUpdatePolicy } from '../hooks/useUpdatePolicy';
|
||||
import { nixUpdateNote, upgradeErrorMessage } from '../lib/upgradeError';
|
||||
|
||||
const DISMISSED_KEY = 'ss-update-dialog-dismissed';
|
||||
@@ -21,8 +22,9 @@ const mockData: VersionCheck = {
|
||||
skillUpdateAvailable: true,
|
||||
};
|
||||
|
||||
export default function UpdateDialog() {
|
||||
export default function UpdateDialog({ manualData, onDismiss }: { manualData?: VersionCheck; onDismiss?: () => void } = {}) {
|
||||
const t = useT();
|
||||
const policy = useUpdatePolicy();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [updating, setUpdating] = useState(false);
|
||||
@@ -34,28 +36,30 @@ export default function UpdateDialog() {
|
||||
queryKey: queryKeys.versionCheck,
|
||||
queryFn: () => api.getVersionCheck(),
|
||||
staleTime: staleTimes.version,
|
||||
enabled: !isMockMode,
|
||||
enabled: !isMockMode && !manualData,
|
||||
});
|
||||
|
||||
const data = isMockMode ? mockData : realData;
|
||||
const data = manualData ?? (isMockMode ? mockData : realData);
|
||||
// Dev builds always report a simulated update; stay quiet unless ?update-test asks for the flow.
|
||||
const hasUpdate = !data?.cliDevMode && (data?.cliUpdateAvailable || data?.skillUpdateAvailable);
|
||||
const hasUpdate = (!!manualData || isMockMode || policy.data?.enabled === true) && (!!manualData || data?.autoCheckEnabled !== false) && (!!manualData || !data?.cliDevMode) && (data?.cliUpdateAvailable || data?.skillUpdateAvailable);
|
||||
|
||||
useEffect(() => {
|
||||
if (!hasUpdate) return;
|
||||
if (!isMockMode) {
|
||||
if (!isMockMode && !manualData) {
|
||||
try {
|
||||
if (sessionStorage.getItem(DISMISSED_KEY)) return;
|
||||
} catch { /* storage unavailable */ }
|
||||
}
|
||||
setOpen(true);
|
||||
}, [hasUpdate, isMockMode]);
|
||||
}, [hasUpdate, isMockMode, manualData]);
|
||||
|
||||
if (!data || !hasUpdate) return null;
|
||||
const nixNote = nixUpdateNote(data, t);
|
||||
|
||||
const dismiss = () => {
|
||||
setOpen(false);
|
||||
onDismiss?.();
|
||||
if (manualData) return;
|
||||
try { sessionStorage.setItem(DISMISSED_KEY, '1'); } catch {
|
||||
// Ignore storage access failures.
|
||||
}
|
||||
@@ -96,6 +100,7 @@ export default function UpdateDialog() {
|
||||
await new Promise((resolve) => setTimeout(resolve, 900));
|
||||
setUpdating(false);
|
||||
setOpen(false);
|
||||
onDismiss?.();
|
||||
return;
|
||||
}
|
||||
setStatus(t('updateDialog.restarting', {}, 'Restarting local UI server…'));
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { api } from '../api/client';
|
||||
import { queryKeys } from '../lib/queryKeys';
|
||||
import { invalidate } from '../lib/queryEvents';
|
||||
|
||||
/** Poll only the local preference, never a release endpoint. */
|
||||
export function useUpdatePolicy() {
|
||||
const queryClient = useQueryClient();
|
||||
return useQuery({
|
||||
queryKey: queryKeys.updatePolicy,
|
||||
queryFn: async () => {
|
||||
const previous = queryClient.getQueryData<{ enabled: boolean }>(queryKeys.updatePolicy);
|
||||
const next = await api.getUpdatePolicy();
|
||||
if (previous && previous.enabled !== next.enabled) void invalidate(queryClient, 'updatePolicyChanged');
|
||||
return next;
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
refetchIntervalInBackground: true,
|
||||
});
|
||||
}
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "Updates",
|
||||
"settings.updates.auto": "Automatisch nach Updates suchen",
|
||||
"settings.updates.hint": "Steuert automatische Versionsprüfungen und Hinweise in CLI, Web UI und Desktop-App. Manuelle Prüfungen und Upgrades bleiben verfügbar.",
|
||||
"settings.updates.environment": "Durch SKILLSHARE_AUTO_UPDATE_CHECK gesteuert.",
|
||||
"settings.updates.global": "Globale Einstellung; in den globalen Einstellungen ändern.",
|
||||
"settings.updates.manual": "Manuelle Versionsprüfung",
|
||||
"settings.updates.manualHint": "Prüft nur auf Anfrage, auch wenn automatische Prüfungen aus sind.",
|
||||
"settings.updates.check": "Nach Updates suchen",
|
||||
"settings.updates.available": "Verfügbare Versionen — CLI: {cli}; Skill: {skill}.",
|
||||
"settings.updates.current": "Keine neuere Version gefunden.",
|
||||
"audit.coverage.one": "{skipped} Datei übersprungen ({binary} binär, {oversized} zu groß)",
|
||||
"audit.coverage.other": "{skipped} Dateien übersprungen ({binary} binär, {oversized} zu groß)",
|
||||
"audit.sourceLinks.one": "{count} Quellverknüpfung nicht verfolgt",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "Updates",
|
||||
"settings.updates.auto": "Automatically check for updates",
|
||||
"settings.updates.hint": "Controls automatic version checks and notifications in the CLI, web UI and desktop app. Manual checks and upgrades remain available.",
|
||||
"settings.updates.environment": "Controlled by SKILLSHARE_AUTO_UPDATE_CHECK.",
|
||||
"settings.updates.global": "This preference is global. Change it in global Settings.",
|
||||
"settings.updates.manual": "Manual version check",
|
||||
"settings.updates.manualHint": "Checks only when you ask, even when automatic checks are off.",
|
||||
"settings.updates.check": "Check for updates",
|
||||
"settings.updates.available": "Available versions — CLI: {cli}; Skill: {skill}.",
|
||||
"settings.updates.current": "No newer version found.",
|
||||
"audit.coverage.one": "{skipped} file skipped ({binary} binary, {oversized} oversized)",
|
||||
"audit.coverage.other": "{skipped} files skipped ({binary} binary, {oversized} oversized)",
|
||||
"audit.sourceLinks.one": "{count} source link not followed",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "Actualizaciones",
|
||||
"settings.updates.auto": "Buscar actualizaciones automáticamente",
|
||||
"settings.updates.hint": "Controla las comprobaciones automáticas de versión y los avisos en CLI, Web UI y la aplicación. Las comprobaciones manuales y las actualizaciones siguen disponibles.",
|
||||
"settings.updates.environment": "Controlado por SKILLSHARE_AUTO_UPDATE_CHECK.",
|
||||
"settings.updates.global": "Esta preferencia es global. Cámbiala en los ajustes globales.",
|
||||
"settings.updates.manual": "Comprobación manual de versión",
|
||||
"settings.updates.manualHint": "Comprueba solo cuando lo solicitas, aunque las comprobaciones automáticas estén desactivadas.",
|
||||
"settings.updates.check": "Buscar actualizaciones",
|
||||
"settings.updates.available": "Versiones disponibles — CLI: {cli}; Skill: {skill}.",
|
||||
"settings.updates.current": "No se encontró una versión más reciente.",
|
||||
"audit.coverage.one": "{skipped} archivo omitido ({binary} binarios, {oversized} demasiado grandes)",
|
||||
"audit.coverage.other": "{skipped} archivos omitidos ({binary} binarios, {oversized} demasiado grandes)",
|
||||
"audit.sourceLinks.one": "{count} enlace de la fuente sin seguir",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "بهروزرسانیها",
|
||||
"settings.updates.auto": "بررسی خودکار بهروزرسانیها",
|
||||
"settings.updates.hint": "بررسی خودکار نسخه و اعلانها در CLI، رابط وب و برنامه دسکتاپ را کنترل میکند. بررسی و ارتقای دستی همچنان در دسترس است.",
|
||||
"settings.updates.environment": "توسط SKILLSHARE_AUTO_UPDATE_CHECK کنترل میشود.",
|
||||
"settings.updates.global": "این تنظیم سراسری است. آن را در تنظیمات سراسری تغییر دهید.",
|
||||
"settings.updates.manual": "بررسی دستی نسخه",
|
||||
"settings.updates.manualHint": "فقط به درخواست شما بررسی میکند، حتی اگر بررسی خودکار خاموش باشد.",
|
||||
"settings.updates.check": "بررسی بهروزرسانیها",
|
||||
"settings.updates.available": "نسخههای موجود — CLI: {cli}؛ Skill: {skill}.",
|
||||
"settings.updates.current": "نسخه جدیدتری پیدا نشد.",
|
||||
"audit.coverage.one": "{skipped} فایل رد شد ({binary} دودویی، {oversized} بیش از حد بزرگ)",
|
||||
"audit.coverage.other": "{skipped} فایل رد شد ({binary} دودویی، {oversized} بیش از حد بزرگ)",
|
||||
"audit.sourceLinks.one": "{count} پیوند منبع دنبال نشد",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "Mises à jour",
|
||||
"settings.updates.auto": "Rechercher automatiquement les mises à jour",
|
||||
"settings.updates.hint": "Contrôle les vérifications automatiques et les notifications de la CLI, de l’interface web et de l’application. Les vérifications et mises à jour manuelles restent disponibles.",
|
||||
"settings.updates.environment": "Contrôlé par SKILLSHARE_AUTO_UPDATE_CHECK.",
|
||||
"settings.updates.global": "Ce réglage est global. Modifiez-le dans les paramètres globaux.",
|
||||
"settings.updates.manual": "Vérification manuelle de version",
|
||||
"settings.updates.manualHint": "Vérifie uniquement sur demande, même si les vérifications automatiques sont désactivées.",
|
||||
"settings.updates.check": "Rechercher les mises à jour",
|
||||
"settings.updates.available": "Versions disponibles — CLI : {cli} ; Skill : {skill}.",
|
||||
"settings.updates.current": "Aucune version plus récente trouvée.",
|
||||
"audit.coverage.one": "{skipped} fichier ignoré ({binary} binaires, {oversized} trop volumineux)",
|
||||
"audit.coverage.other": "{skipped} fichiers ignorés ({binary} binaires, {oversized} trop volumineux)",
|
||||
"audit.sourceLinks.one": "{count} lien de la source non suivi",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "Pembaruan",
|
||||
"settings.updates.auto": "Periksa pembaruan otomatis",
|
||||
"settings.updates.hint": "Mengontrol pemeriksaan versi otomatis dan notifikasi di CLI, Web UI, dan aplikasi desktop. Pemeriksaan dan peningkatan manual tetap tersedia.",
|
||||
"settings.updates.environment": "Dikontrol oleh SKILLSHARE_AUTO_UPDATE_CHECK.",
|
||||
"settings.updates.global": "Preferensi ini global. Ubah di pengaturan global.",
|
||||
"settings.updates.manual": "Pemeriksaan versi manual",
|
||||
"settings.updates.manualHint": "Memeriksa hanya saat diminta, meskipun pemeriksaan otomatis dimatikan.",
|
||||
"settings.updates.check": "Periksa pembaruan",
|
||||
"settings.updates.available": "Versi tersedia — CLI: {cli}; Skill: {skill}.",
|
||||
"settings.updates.current": "Tidak ditemukan versi yang lebih baru.",
|
||||
"audit.coverage.one": "{skipped} file dilewati ({binary} biner, {oversized} terlalu besar)",
|
||||
"audit.coverage.other": "{skipped} file dilewati ({binary} biner, {oversized} terlalu besar)",
|
||||
"audit.sourceLinks.one": "{count} tautan sumber tidak diikuti",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "更新",
|
||||
"settings.updates.auto": "更新を自動的に確認",
|
||||
"settings.updates.hint": "CLI、Web UI、デスクトップアプリの自動バージョン確認と通知を制御します。手動確認とアップグレードは引き続き利用できます。",
|
||||
"settings.updates.environment": "SKILLSHARE_AUTO_UPDATE_CHECK により制御されています。",
|
||||
"settings.updates.global": "グローバル設定です。グローバルの設定画面で変更してください。",
|
||||
"settings.updates.manual": "手動バージョン確認",
|
||||
"settings.updates.manualHint": "自動確認が無効でも、要求したときだけ確認します。",
|
||||
"settings.updates.check": "更新を確認",
|
||||
"settings.updates.available": "利用可能なバージョン — CLI: {cli}、Skill: {skill}。",
|
||||
"settings.updates.current": "新しいバージョンは見つかりませんでした。",
|
||||
"audit.coverage.one": "{skipped} ファイルをスキップ(バイナリ {binary}、サイズ超過 {oversized})",
|
||||
"audit.coverage.other": "{skipped} ファイルをスキップ(バイナリ {binary}、サイズ超過 {oversized})",
|
||||
"audit.sourceLinks.one": "{count} 件のソースのリンクをたどれませんでした",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "업데이트",
|
||||
"settings.updates.auto": "자동으로 업데이트 확인",
|
||||
"settings.updates.hint": "CLI, Web UI 및 데스크톱 앱의 자동 버전 확인과 알림을 제어합니다. 수동 확인과 업그레이드는 계속 사용할 수 있습니다.",
|
||||
"settings.updates.environment": "SKILLSHARE_AUTO_UPDATE_CHECK에서 제어합니다.",
|
||||
"settings.updates.global": "전역 설정입니다. 전역 설정 화면에서 변경하세요.",
|
||||
"settings.updates.manual": "수동 버전 확인",
|
||||
"settings.updates.manualHint": "자동 확인이 꺼져 있어도 요청할 때만 확인합니다.",
|
||||
"settings.updates.check": "업데이트 확인",
|
||||
"settings.updates.available": "사용 가능한 버전 — CLI: {cli}; Skill: {skill}.",
|
||||
"settings.updates.current": "새 버전을 찾지 못했습니다.",
|
||||
"audit.coverage.one": "파일 {skipped}개 건너뜀(바이너리 {binary}개, 크기 초과 {oversized}개)",
|
||||
"audit.coverage.other": "파일 {skipped}개 건너뜀(바이너리 {binary}개, 크기 초과 {oversized}개)",
|
||||
"audit.sourceLinks.one": "소스 링크 {count}개를 따라가지 못함",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "Atualizações",
|
||||
"settings.updates.auto": "Verificar atualizações automaticamente",
|
||||
"settings.updates.hint": "Controla verificações automáticas de versão e avisos na CLI, Web UI e no aplicativo. Verificações manuais e atualizações continuam disponíveis.",
|
||||
"settings.updates.environment": "Controlado por SKILLSHARE_AUTO_UPDATE_CHECK.",
|
||||
"settings.updates.global": "Esta preferência é global. Altere nas configurações globais.",
|
||||
"settings.updates.manual": "Verificação manual de versão",
|
||||
"settings.updates.manualHint": "Verifica apenas quando solicitado, mesmo com verificações automáticas desativadas.",
|
||||
"settings.updates.check": "Verificar atualizações",
|
||||
"settings.updates.available": "Versões disponíveis — CLI: {cli}; Skill: {skill}.",
|
||||
"settings.updates.current": "Nenhuma versão mais recente encontrada.",
|
||||
"audit.coverage.one": "{skipped} arquivo ignorado ({binary} binários, {oversized} grandes demais)",
|
||||
"audit.coverage.other": "{skipped} arquivos ignorados ({binary} binários, {oversized} grandes demais)",
|
||||
"audit.sourceLinks.one": "{count} link da fonte não seguido",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "更新",
|
||||
"settings.updates.auto": "自动检查更新",
|
||||
"settings.updates.hint": "控制 CLI、Web UI 与桌面 App 的自动版本检查和通知。仍可手动检查与升级。",
|
||||
"settings.updates.environment": "由 SKILLSHARE_AUTO_UPDATE_CHECK 控制。",
|
||||
"settings.updates.global": "此设置应用于全局,请在全局设置中更改。",
|
||||
"settings.updates.manual": "手动版本检查",
|
||||
"settings.updates.manualHint": "仅在你要求时检查,即使已关闭自动检查。",
|
||||
"settings.updates.check": "检查更新",
|
||||
"settings.updates.available": "可用版本 — CLI:{cli};Skill:{skill}。",
|
||||
"settings.updates.current": "未发现更新的版本。",
|
||||
"audit.coverage.one": "已跳过 {skipped} 个文件(二进制 {binary} 个,超出大小限制 {oversized} 个)",
|
||||
"audit.coverage.other": "已跳过 {skipped} 个文件(二进制 {binary} 个,超出大小限制 {oversized} 个)",
|
||||
"audit.sourceLinks.one": "{count} 个 source 链接未跟随",
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"settings.updates.title": "更新",
|
||||
"settings.updates.auto": "自動檢查更新",
|
||||
"settings.updates.hint": "控制 CLI、Web UI 與桌面 App 的自動版本檢查和通知。仍可手動檢查與升級。",
|
||||
"settings.updates.environment": "由 SKILLSHARE_AUTO_UPDATE_CHECK 控制。",
|
||||
"settings.updates.global": "此設定套用全域,請在全域設定中變更。",
|
||||
"settings.updates.manual": "手動版本檢查",
|
||||
"settings.updates.manualHint": "只在你要求時檢查,即使已關閉自動檢查。",
|
||||
"settings.updates.check": "檢查更新",
|
||||
"settings.updates.available": "可用版本 — CLI:{cli};Skill:{skill}。",
|
||||
"settings.updates.current": "未發現較新的版本。",
|
||||
"audit.coverage.one": "已略過 {skipped} 個檔案(二進位 {binary} 個,超出大小限制 {oversized} 個)",
|
||||
"audit.coverage.other": "已略過 {skipped} 個檔案(二進位 {binary} 個,超出大小限制 {oversized} 個)",
|
||||
"audit.sourceLinks.one": "{count} 個 source 連結未跟進",
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { expect, it } from 'vitest';
|
||||
import { doctorWithUpdatePolicy } from './doctorUpdates';
|
||||
import type { DoctorResponse } from '../api/client';
|
||||
|
||||
it('hides cached update notices without hiding diagnostic warnings or miscounting them', () => {
|
||||
const data: DoctorResponse = {
|
||||
checks: [
|
||||
{name:'skill_version',status:'warning',message:'Skill update',update_available:true},
|
||||
{name:'skill_version',status:'warning',message:'Skill not found'},
|
||||
],
|
||||
summary:{total:2,pass:0,errors:0,warnings:2,info:0},
|
||||
version:{current:'1.0.0',latest:'9.9.9',update_available:true},
|
||||
};
|
||||
const quiet=doctorWithUpdatePolicy(data,false);
|
||||
expect(quiet.checks).toEqual([data.checks[1]]);
|
||||
expect(quiet.summary).toEqual({total:1,pass:0,errors:0,warnings:1,info:0});
|
||||
expect(quiet.version).toEqual({current:'1.0.0',update_available:false});
|
||||
expect(doctorWithUpdatePolicy(data,true)).toBe(data);
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { DoctorResponse } from '../api/client';
|
||||
|
||||
/** Remove cached update notices without hiding unrelated diagnostic warnings. */
|
||||
export function doctorWithUpdatePolicy(data: DoctorResponse, enabled: boolean): DoctorResponse {
|
||||
if (enabled) return data;
|
||||
const checks = data.checks.filter((check) => !check.update_available);
|
||||
return {
|
||||
...data,
|
||||
checks,
|
||||
summary: {
|
||||
total: checks.length,
|
||||
pass: checks.filter((check) => check.status === 'pass').length,
|
||||
warnings: checks.filter((check) => check.status === 'warning').length,
|
||||
errors: checks.filter((check) => check.status === 'error').length,
|
||||
info: checks.filter((check) => check.status === 'info').length,
|
||||
},
|
||||
version: data.version ? { current: data.version.current, dev_mode: data.version.dev_mode, update_available: false } : undefined,
|
||||
};
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { isCollection, isMap, isNode, isScalar, parseDocument, visit } from 'yam
|
||||
const CONFIG_SECTIONS = [
|
||||
'sources', 'source', 'agents_source', 'extras_source', 'git_root', 'mode', 'target_naming',
|
||||
'targets', 'skills', 'agents', 'extras', 'mcp', 'plugins', 'hooks',
|
||||
'projects', 'hub', 'log', 'context_budget', 'tui', 'gitlab_hosts', 'azure_hosts', 'ignore', 'audit',
|
||||
'updates', 'projects', 'hub', 'log', 'context_budget', 'tui', 'gitlab_hosts', 'azure_hosts', 'ignore', 'audit',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,7 @@ import { queryKeys as k } from './queryKeys';
|
||||
const cached = {
|
||||
overview: k.overview,
|
||||
version: k.versionCheck,
|
||||
policy: k.updatePolicy,
|
||||
skills: k.skills.all,
|
||||
skill: k.skills.detailOfKind('a', 'skill'),
|
||||
targets: k.targets.all,
|
||||
@@ -94,8 +95,9 @@ const stale: Record<QueryEvent, Label[] | { args: string[]; stale: Label[] }> =
|
||||
targetFilesChanged: { args: ['claude'], stale: ['targetFiles', 'targetFile'] },
|
||||
targetFileRemoved: { args: ['claude'], stale: ['targetFiles'] },
|
||||
|
||||
configSaved: ['config', ...M, 'overview', ...T, ...S, ...X, 'extrasDiff', 'diff', 'syncMatrix', 'doctor', 'instructions', 'memory', 'memoryOverview'],
|
||||
settingsSaved: ['config'],
|
||||
configSaved: ['policy', 'version', 'config', ...M, 'overview', ...T, ...S, ...X, 'extrasDiff', 'diff', 'syncMatrix', 'doctor', 'instructions', 'memory', 'memoryOverview'],
|
||||
updatePolicyChanged: ['version', 'doctor'],
|
||||
settingsSaved: ['policy', 'config', 'version', 'doctor'],
|
||||
skillignoreSaved: ['skillignore', 'diff', 'overview', ...S, 'doctor'],
|
||||
agentignoreSaved: ['agentignore', 'diff', 'overview', ...S, 'doctor'],
|
||||
extensionsChanged: ['extensions', 'extrasExtensions'],
|
||||
|
||||
@@ -46,8 +46,9 @@ const events = {
|
||||
targetFileRemoved: (target: string): InvalidateQueryFilters[] => [{ queryKey: k.targetFiles.list(target), exact: true }],
|
||||
|
||||
// Config
|
||||
configSaved: () => keys(k.config, k.mcp, k.overview, k.targets.all, k.skills.all, k.extras, k.extrasDiff(), k.diff(), k.syncMatrix(), k.doctor, k.instructions.all, k.memory.all),
|
||||
settingsSaved: () => keys(k.config),
|
||||
configSaved: () => keys(k.updatePolicy, k.versionCheck, k.config, k.mcp, k.overview, k.targets.all, k.skills.all, k.extras, k.extrasDiff(), k.diff(), k.syncMatrix(), k.doctor, k.instructions.all, k.memory.all),
|
||||
updatePolicyChanged: () => keys(k.versionCheck, k.doctor),
|
||||
settingsSaved: () => keys(k.updatePolicy, k.config, k.versionCheck, k.doctor),
|
||||
skillignoreSaved: () => keys(k.skillignore, ...ignoreFile),
|
||||
agentignoreSaved: () => keys(k.agentignore, ...ignoreFile),
|
||||
extensionsChanged: () => keys(k.extensions, k.extrasExtensions),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
export const queryKeys = {
|
||||
overview: ['overview'] as const,
|
||||
versionCheck: ['version-check'] as const,
|
||||
updatePolicy: ['update-policy'] as const,
|
||||
manualVersionCheck: ['manual-version-check'] as const,
|
||||
|
||||
skills: {
|
||||
all: ['skills'] as const,
|
||||
|
||||
@@ -38,6 +38,7 @@ import { PageSkeleton } from '../components/Skeleton';
|
||||
import { useToast } from '../components/Toast';
|
||||
import { useAppContext } from '../context/AppContext';
|
||||
import { useRepoUpdate } from '../hooks/useRepoUpdate';
|
||||
import { useUpdatePolicy } from '../hooks/useUpdatePolicy';
|
||||
import { useHooksQuery, useMcpQuery, useOverviewQuery } from '../hooks/useSharedQueries';
|
||||
import { invalidate } from '../lib/queryEvents';
|
||||
import MemoryOverview from '../components/memory/MemoryOverview';
|
||||
@@ -556,6 +557,7 @@ function TrackedRepos({ repos }: { repos: Overview['trackedRepos'] }) {
|
||||
|
||||
function Versions({ data }: { data: Overview }) {
|
||||
const t = useT();
|
||||
const policy = useUpdatePolicy();
|
||||
const { data: v, isPending } = useQuery({
|
||||
queryKey: queryKeys.versionCheck,
|
||||
queryFn: () => api.getVersionCheck(),
|
||||
@@ -578,20 +580,20 @@ function Versions({ data }: { data: Overview }) {
|
||||
<div className="ss-r">
|
||||
<span className="w-[120px] font-semibold">{t('dashboard.version.cli')}</span>
|
||||
<span className="flex-1 font-mono text-[13px]">{ver(v.cliVersion)}</span>
|
||||
{v.cliUpdateAvailable
|
||||
{policy.data?.enabled === true && (v.cliUpdateAvailable
|
||||
? <span className="ss-st warn">{t('dashboard.version.update', { version: ver(v.cliLatest) })}</span>
|
||||
: <span className="ss-st ok">{t('dashboard.version.upToDate')}</span>}
|
||||
: <span className="ss-st ok">{t('dashboard.version.upToDate')}</span>)}
|
||||
</div>
|
||||
<div className="ss-r">
|
||||
<span className="w-[120px] font-semibold">{t('dashboard.version.builtInSkill')}</span>
|
||||
<span className="flex-1 font-mono text-[13px]">{ver(v.skillVersion) || '—'}</span>
|
||||
{!v.skillVersion
|
||||
{policy.data?.enabled === true && (!v.skillVersion
|
||||
? <span className="ss-st off">{t('dashboard.version.notInstalled')}</span>
|
||||
: v.skillUpdateAvailable
|
||||
? <span className="ss-st warn">{t('dashboard.version.update', { version: ver(v.skillLatest) })}</span>
|
||||
: v.skillLatest
|
||||
? <span className="ss-st ok">{t('dashboard.version.upToDate')}</span>
|
||||
: <span className="ss-st off">{t('dashboard.version.checkFailed')}</span>}
|
||||
: <span className="ss-st off">{t('dashboard.version.checkFailed')}</span>)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -16,6 +16,8 @@ import { SettingsTabs } from './SettingsPage';
|
||||
import { useOverviewQuery } from '../hooks/useSharedQueries';
|
||||
import { invalidate } from '../lib/queryEvents';
|
||||
import { segSlide } from '../lib/segSlide';
|
||||
import { useUpdatePolicy } from '../hooks/useUpdatePolicy';
|
||||
import { doctorWithUpdatePolicy } from '../lib/doctorUpdates';
|
||||
|
||||
type Filter = 'all' | 'error' | 'warning' | 'pass';
|
||||
|
||||
@@ -36,7 +38,9 @@ export default function DoctorPage() {
|
||||
const [upgradeMessage, setUpgradeMessage] = useState<string | null>(null);
|
||||
|
||||
const overview = useOverviewQuery();
|
||||
const { data, isPending, error, isFetching, refetch } = useQuery({ queryKey: queryKeys.doctor, queryFn: () => api.doctor(), staleTime: staleTimes.doctor });
|
||||
const policy = useUpdatePolicy();
|
||||
const { data: rawData, isPending, error, isFetching, refetch } = useQuery({ queryKey: queryKeys.doctor, queryFn: () => api.doctor(), staleTime: staleTimes.doctor });
|
||||
const data = useMemo(() => rawData && doctorWithUpdatePolicy(rawData, policy.data?.enabled === true), [rawData, policy.data?.enabled]);
|
||||
|
||||
const checks = useMemo(() => {
|
||||
const all = data?.checks ?? [];
|
||||
@@ -163,11 +167,11 @@ export default function DoctorPage() {
|
||||
</span>
|
||||
</span>
|
||||
{upgradeMessage && <span className="text-[13px] text-ink-2">{upgradeMessage}</span>}
|
||||
{data!.version.update_available ? (
|
||||
{policy.data?.enabled === true && (data!.version.update_available ? (
|
||||
<Button variant="primary" size="sm" onClick={upgrade} loading={upgrading}><ArrowUpCircle size={14} />{t('updateDialog.updateNow')}</Button>
|
||||
) : (
|
||||
<span className="ss-st ok">{t('dashboard.version.upToDate')}</span>
|
||||
)}
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,10 @@ import { Link } from 'react-router-dom';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { api } from '../api/client';
|
||||
import PageHeader from '../components/PageHeader';
|
||||
import Button from '../components/Button';
|
||||
import UpdateDialog from '../components/UpdateDialog';
|
||||
import type { VersionCheck } from '../api/client';
|
||||
import { useUpdatePolicy } from '../hooks/useUpdatePolicy';
|
||||
import { Select } from '../components/Select';
|
||||
import { useToast } from '../components/Toast';
|
||||
import { useAppContext } from '../context/AppContext';
|
||||
@@ -59,9 +63,10 @@ export default function SettingsPage() {
|
||||
const config = useQuery({ queryKey: queryKeys.config, queryFn: () => api.getConfig(), staleTime: staleTimes.config });
|
||||
const cfg = (config.data?.config ?? {}) as ConfigShape;
|
||||
const [threshold, setThreshold] = useState<string | null>(null);
|
||||
const [manualUpgrade, setManualUpgrade] = useState<VersionCheck | null>(null);
|
||||
|
||||
const patch = useMutation({
|
||||
mutationFn: (body: { mode?: string; logMaxEntries?: number }) => api.patchConfig(body),
|
||||
mutationFn: (body: { mode?: string; logMaxEntries?: number; autoUpdateCheck?: boolean }) => api.patchConfig(body),
|
||||
onSuccess: () => { void invalidate(queryClient, 'settingsSaved'); toast(t('settings.toast.saved'), 'success'); },
|
||||
onError: (e: Error) => toast(e.message, 'error'),
|
||||
});
|
||||
@@ -73,6 +78,11 @@ export default function SettingsPage() {
|
||||
|
||||
const home = isProjectMode ? projectRoot : overview.data?.configDir;
|
||||
const logLimit = cfg.Log?.MaxEntries ?? 1000;
|
||||
const updatePolicy = useUpdatePolicy();
|
||||
const manualCheck = useQuery({ queryKey: queryKeys.manualVersionCheck, queryFn: () => api.getVersionCheck(true), enabled: false, retry: false });
|
||||
const policy = updatePolicy.data;
|
||||
const manualResult = manualCheck.error ? undefined : manualCheck.data;
|
||||
|
||||
|
||||
return (
|
||||
<div className="ss-wrap animate-page-in">
|
||||
@@ -116,6 +126,37 @@ export default function SettingsPage() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<div className="ss-sec"><h2 className="ss-h2">{t('settings.updates.title')}</h2></div>
|
||||
<div className="ss-list">
|
||||
<div className="ss-setrow">
|
||||
<div className="l">
|
||||
<b id="auto-update-label">{t('settings.updates.auto')}</b>
|
||||
<span>{t(policy?.envOverride ? 'settings.updates.environment' : isProjectMode ? 'settings.updates.global' : 'settings.updates.hint')}</span>
|
||||
</div>
|
||||
<button type="button" role="switch" aria-labelledby="auto-update-label" aria-checked={policy?.enabled ?? true}
|
||||
className={`ss-sw ${policy?.enabled !== false ? 'on' : ''}`}
|
||||
disabled={!policy || isProjectMode || policy.envOverride || patch.isPending}
|
||||
onClick={() => patch.mutate({ autoUpdateCheck: !policy?.enabled })}><i /></button>
|
||||
</div>
|
||||
<div className="ss-setrow">
|
||||
<div className="l">
|
||||
<b>{t('settings.updates.manual')}</b>
|
||||
<span>{t('settings.updates.manualHint')}</span>
|
||||
</div>
|
||||
<Button variant="secondary" loading={manualCheck.isFetching} onClick={() => { void manualCheck.refetch(); }}>{t('settings.updates.check')}</Button>
|
||||
</div>
|
||||
</div>
|
||||
{manualCheck.error && <p className="ss-note bad">{t('dashboard.version.couldNotCheck')}</p>}
|
||||
{manualResult && <p className="ss-note inf" role="status">
|
||||
{manualResult.cliUpdateAvailable || manualResult.skillUpdateAvailable
|
||||
? t('settings.updates.available', { cli: manualResult.cliLatest ?? manualResult.cliVersion, skill: manualResult.skillLatest ?? manualResult.skillVersion })
|
||||
: t('settings.updates.current')}
|
||||
</p>}
|
||||
{manualResult && (manualResult.cliUpdateAvailable || manualResult.skillUpdateAvailable) && <Button variant="primary" onClick={() => setManualUpgrade(manualResult)}>{t('updateDialog.updateNow')}</Button>}
|
||||
{manualUpgrade && <UpdateDialog manualData={manualUpgrade} onDismiss={() => setManualUpgrade(null)} />}
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<div className="ss-sec"><h2 className="ss-h2">{t('settings.appearance.title')}</h2></div>
|
||||
<div className="ss-list">
|
||||
|
||||
@@ -8,6 +8,21 @@ All environment variables recognized by skillshare.
|
||||
|
||||
## Configuration
|
||||
|
||||
### SKILLSHARE_AUTO_UPDATE_CHECK {#skillshare_auto_update_check}
|
||||
|
||||
Override global `updates.auto_check` for automatic release-version checks and notifications.
|
||||
|
||||
```bash
|
||||
SKILLSHARE_AUTO_UPDATE_CHECK=false skillshare status
|
||||
```
|
||||
|
||||
**Default:** `updates.auto_check` in config.yaml, or `true` when unset.
|
||||
Accepts `true`/`false`, `1`/`0`, `t`/`f` and Go boolean case variants; empty or
|
||||
invalid values are ignored. The environment takes precedence without rewriting config.
|
||||
CLI, web UI and desktop app version notifications are suppressed when false;
|
||||
explicit checks and upgrades remain available. GUI apps must inherit this variable
|
||||
when launched. See [updates](/docs/reference/commands/updates).
|
||||
|
||||
### SKILLSHARE_CONFIG
|
||||
|
||||
Override the config file path.
|
||||
|
||||
@@ -70,6 +70,7 @@ Complete reference for all skillshare commands.
|
||||
| [new](./new.md) | Create a new skill |
|
||||
| [check](./check.md) | Check for available updates |
|
||||
| [update](./update.md) | Update a skill or tracked repo |
|
||||
| [updates](/docs/reference/commands/updates) | Control automatic version checks and notifications |
|
||||
| [upgrade](./upgrade.md) | Upgrade CLI or built-in skill |
|
||||
| [enable / disable](./enable.md) | Temporarily enable or disable skills |
|
||||
| [move](./move.md) | Move installed skills or folders without losing install records |
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
# updates
|
||||
|
||||
Control automatic version checks and update notifications for the CLI, built-in skill,
|
||||
web dashboard and desktop app. This is a **global preference**, including in project mode.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
skillshare updates # Show the effective preference
|
||||
skillshare updates off # Disable automatic checks and notifications
|
||||
skillshare updates on # Restore automatic checks
|
||||
skillshare updates check # Explicitly check the CLI version now
|
||||
skillshare updates --json # Read the saved and effective preference
|
||||
```
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `on` / `off` | Save the global preference |
|
||||
| `check` | Check the CLI version now, bypassing the preference and version cache |
|
||||
| `--json` | Output JSON |
|
||||
| `--help`, `-h` | Show help |
|
||||
|
||||
The JSON preference has `enabled` (effective), `configured` (saved, or the default),
|
||||
and `envOverride` fields. Setting a preference does not change an environment override.
|
||||
|
||||
## Configuration {#configuration}
|
||||
|
||||
Automatic checks are enabled by default. To opt out, set this in the global `config.yaml`:
|
||||
|
||||
```yaml
|
||||
updates:
|
||||
auto_check: false
|
||||
```
|
||||
|
||||
Or override it for a process and its children:
|
||||
|
||||
```bash
|
||||
SKILLSHARE_AUTO_UPDATE_CHECK=false skillshare status
|
||||
```
|
||||
|
||||
Precedence: **environment variable > config.yaml > true**. Accepted values are
|
||||
`true`/`false`, `1`/`0`, `t`/`f` and their Go boolean case variants.
|
||||
Empty or invalid values are ignored. Environment overrides are never written back.
|
||||
|
||||
With checks disabled, ordinary commands and `doctor` do not check release versions
|
||||
or show update notifications, even when an older check cached a newer release.
|
||||
The web UI does not automatically show an update dialog or version-status badges.
|
||||
An already-open dashboard refreshes the local preference every five seconds (without
|
||||
checking releases), so turning checks off from the CLI or app also hides existing prompts.
|
||||
|
||||
In Web **Settings → General** and desktop **Settings → Updates**, the automatic-check
|
||||
switch writes the same global preference. An environment override locks the switch.
|
||||
The desktop app refreshes external preference changes within a minute and hides
|
||||
version badges as well as native version notifications. Its CLI must support
|
||||
`updates` to read/write the saved preference; older CLIs keep the existing default
|
||||
and require a CLI upgrade to enable the switch. Environment opt-out still works.
|
||||
|
||||
## Manual checks and upgrades {#manual-checks}
|
||||
|
||||
`skillshare updates check`, Web Settings' **Check for updates**, desktop **Check**,
|
||||
and [upgrade](/docs/reference/commands/upgrade) remain available.
|
||||
Manual results are shown where requested, without re-enabling automatic notifications.
|
||||
Web Settings offers **Update now** after an explicit check finds an update. Cached
|
||||
Doctor update notices are hidden too; JSON checks mark these with `update_available: true`
|
||||
so unrelated diagnostic warnings remain visible.
|
||||
Desktop skill, agent, plugin and repository source checks are not release-version checks
|
||||
and are unchanged.
|
||||
|
||||
See [environment variables](/docs/reference/appendix/environment-variables).
|
||||
+10
@@ -8,6 +8,16 @@ skillshare が認識するすべての環境変数です。
|
||||
|
||||
## 設定
|
||||
|
||||
### SKILLSHARE_AUTO_UPDATE_CHECK {#skillshare_auto_update_check}
|
||||
|
||||
グローバル config.yaml の `updates.auto_check` より優先されます。`false` にすると CLI、Web UI、デスクトップアプリの自動バージョン確認、更新通知とバージョンバッジを無効にします。手動確認とアップグレードは利用できます。設定ファイルへの書き戻しは行いません。未設定時は設定ファイルを使い、既定値は `true` です。`true/false`、`1/0`、`t/f` と Go の真偽値の大文字小文字表記を受け付け、空または無効な値は無視します。GUI アプリは起動時にこの環境変数を継承する必要があります。
|
||||
|
||||
```bash
|
||||
SKILLSHARE_AUTO_UPDATE_CHECK=false skillshare status
|
||||
```
|
||||
|
||||
[updates](/docs/reference/commands/updates)
|
||||
|
||||
### SKILLSHARE_CONFIG
|
||||
|
||||
Config ファイルのパスを上書きします。
|
||||
|
||||
@@ -67,6 +67,7 @@ skillshare のすべてのコマンドに関する完全なリファレンスで
|
||||
| [new](./new.md) | 新しい Skill を作成 |
|
||||
| [check](./check.md) | 利用可能な更新を確認 |
|
||||
| [update](./update.md) | Skill またはトラック対象リポジトリを更新 |
|
||||
| [updates](/docs/reference/commands/updates) | 自動バージョン確認と更新通知を制御 |
|
||||
| [upgrade](./upgrade.md) | CLI または組み込み Skill をアップグレード |
|
||||
| [enable / disable](./enable.md) | Skill を一時的に有効化/無効化 |
|
||||
|
||||
|
||||
+10
@@ -8,6 +8,16 @@ skillshare가 인식하는 모든 환경 변수입니다.
|
||||
|
||||
## 설정
|
||||
|
||||
### SKILLSHARE_AUTO_UPDATE_CHECK {#skillshare_auto_update_check}
|
||||
|
||||
전역 config.yaml의 `updates.auto_check`보다 우선합니다. `false`이면 CLI, Web UI 및 데스크톱 앱의 자동 버전 확인, 업데이트 알림과 버전 배지를 끕니다. 수동 확인과 업그레이드는 계속 사용할 수 있습니다. 설정 파일은 변경하지 않습니다. 미설정 시 설정 파일을 따르며 기본값은 `true`입니다. `true/false`, `1/0`, `t/f` 및 Go 불리언 대소문자 표기를 허용하고 빈 값이나 잘못된 값은 무시합니다. GUI 앱은 시작할 때 이 환경 변수를 상속해야 합니다.
|
||||
|
||||
```bash
|
||||
SKILLSHARE_AUTO_UPDATE_CHECK=false skillshare status
|
||||
```
|
||||
|
||||
[updates](/docs/reference/commands/updates)
|
||||
|
||||
### SKILLSHARE_CONFIG
|
||||
|
||||
설정 파일 경로를 재정의합니다.
|
||||
|
||||
@@ -67,6 +67,7 @@ sidebar_position: 1
|
||||
| [new](./new.md) | 새 skill 생성 |
|
||||
| [check](./check.md) | 사용 가능한 업데이트 확인 |
|
||||
| [update](./update.md) | skill 또는 tracked 저장소 업데이트 |
|
||||
| [updates](/docs/reference/commands/updates) | 자동 버전 확인과 업데이트 알림 제어 |
|
||||
| [upgrade](./upgrade.md) | CLI 또는 built-in skill 업그레이드 |
|
||||
| [enable / disable](./enable.md) | skill을 임시로 활성화/비활성화 |
|
||||
|
||||
|
||||
+10
@@ -8,6 +8,16 @@ skillshare 识别的所有环境变量。
|
||||
|
||||
## Configuration
|
||||
|
||||
### SKILLSHARE_AUTO_UPDATE_CHECK {#skillshare_auto_update_check}
|
||||
|
||||
覆盖全局 config.yaml 的 `updates.auto_check`。设为 `false` 时,CLI、Web UI 和桌面 App 停止自动版本检查,不显示更新通知或版本徽章;仍可手动检查与升级。环境变量优先于配置文件,不会回写。未设置时使用配置文件,默认为 `true`。接受 `true/false`、`1/0`、`t/f` 及 Go 布尔值大小写变体;空值或无效值忽略。GUI App 必须在启动时继承此环境变量。
|
||||
|
||||
```bash
|
||||
SKILLSHARE_AUTO_UPDATE_CHECK=false skillshare status
|
||||
```
|
||||
|
||||
[updates](/docs/reference/commands/updates)
|
||||
|
||||
### SKILLSHARE_CONFIG
|
||||
|
||||
覆盖配置文件路径。
|
||||
|
||||
+1
@@ -67,6 +67,7 @@ skillshare 全部命令的完整参考。
|
||||
| [new](./new.md) | 创建一个新的 Skill |
|
||||
| [check](./check.md) | 检查是否有可用更新 |
|
||||
| [update](./update.md) | 更新一个 Skill 或 tracked repo |
|
||||
| [updates](/docs/reference/commands/updates) | 控制自动版本检查与更新通知 |
|
||||
| [upgrade](./upgrade.md) | 升级 CLI 或内置 Skill |
|
||||
| [enable / disable](./enable.md) | 临时启用或禁用 Skill |
|
||||
|
||||
|
||||
+10
@@ -8,6 +8,16 @@ skillshare 所辨識的所有環境變數。
|
||||
|
||||
## 設定
|
||||
|
||||
### SKILLSHARE_AUTO_UPDATE_CHECK {#skillshare_auto_update_check}
|
||||
|
||||
覆蓋全域 config.yaml 的 `updates.auto_check`。設為 `false` 時,CLI、Web UI 和桌面 App 停止自動版本檢查,不顯示更新通知或版本徽章;仍可手動檢查與升級。環境變數優先於設定檔,不會回寫。未設定時採用設定檔,預設為 `true`。接受 `true/false`、`1/0`、`t/f` 及 Go 布林值大小寫變體;空值或無效值忽略。GUI App 必須在啟動時繼承此環境變數。
|
||||
|
||||
```bash
|
||||
SKILLSHARE_AUTO_UPDATE_CHECK=false skillshare status
|
||||
```
|
||||
|
||||
[updates](/docs/reference/commands/updates)
|
||||
|
||||
### SKILLSHARE_CONFIG
|
||||
|
||||
覆寫設定檔路徑。
|
||||
|
||||
+1
@@ -67,6 +67,7 @@ skillshare 所有指令的完整參考。
|
||||
| [new](./new.md) | 建立新的 skill |
|
||||
| [check](./check.md) | 檢查是否有可用更新 |
|
||||
| [update](./update.md) | 更新一個 skill 或 tracked repo |
|
||||
| [updates](/docs/reference/commands/updates) | 控制自動版本檢查與更新通知 |
|
||||
| [upgrade](./upgrade.md) | 升級 CLI 或內建 skill |
|
||||
| [enable / disable](./enable.md) | 暫時啟用或停用 skills |
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ const sidebars: SidebarsConfig = {
|
||||
'reference/commands/check',
|
||||
'reference/commands/update',
|
||||
'reference/commands/upgrade',
|
||||
'reference/commands/updates',
|
||||
'reference/commands/enable',
|
||||
'reference/commands/move',
|
||||
],
|
||||
|
||||
@@ -21,7 +21,7 @@ export type FeatureGroup = {
|
||||
const C = '/docs/reference/commands/';
|
||||
const D = '/docs/';
|
||||
|
||||
export const COMMAND_COUNT = 39;
|
||||
export const COMMAND_COUNT = 40;
|
||||
export const TARGET_COUNT = 79;
|
||||
|
||||
export const FEATURE_GROUPS: FeatureGroup[] = [
|
||||
@@ -39,6 +39,7 @@ export const FEATURE_GROUPS: FeatureGroup[] = [
|
||||
{cmd: 'doctor', what: 'Check config, targets and symlink health', kw: 'diagnose broken health fix', href: C + 'doctor'},
|
||||
{cmd: 'completion', what: 'Shell completions for zsh, bash and fish', kw: 'shell tab autocomplete', href: C + 'completion'},
|
||||
{cmd: 'upgrade', what: 'Upgrade the skillshare binary itself', kw: 'version latest self update', href: C + 'upgrade'},
|
||||
{cmd: 'updates', what: 'Control automatic version checks and notifications', kw: 'release version opt out config environment', href: C + 'updates'},
|
||||
],
|
||||
guides: [
|
||||
{label: 'First sync in 5 minutes', href: D + 'getting-started/first-sync'},
|
||||
|
||||
Reference in New Issue
Block a user