mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
fix: repair partial project init when config is missing
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
- **`doctor` no longer flags copy-managed skills as duplicates**
|
||||
- **`target remove` in project mode cleans up copy manifest**
|
||||
- **Copy mode no longer fails on stray files** in target directories or missing target paths
|
||||
- **`update` and `check` now honor HTTPS token auth** — private repo pull/remote checks now auto-detect `GITHUB_TOKEN`, `GITLAB_TOKEN`, `BITBUCKET_TOKEN`, and `SKILLSHARE_GIT_TOKEN` (same as install)
|
||||
- **Devcontainer project mode no longer pollutes workspace root** — `ss` keeps caller working directory and redirects `-p` from `/workspace` to demo project
|
||||
- **Project mode auto-repairs partial initialization** — if `.skillshare/` exists but `config.yaml` is missing, commands repair config instead of failing with "project already initialized"
|
||||
|
||||
### Changed
|
||||
- **`agents` target renamed to `universal`** — existing configs using `agents` continue to work (backward-compatible alias); Kimi and Replit paths updated to match upstream docs
|
||||
|
||||
@@ -83,15 +83,27 @@ func cmdInitProject(args []string) error {
|
||||
func performProjectInit(root string, opts projectInitOptions) error {
|
||||
projectDir := filepath.Join(root, ".skillshare")
|
||||
configPath := config.ProjectConfigPath(root)
|
||||
if _, err := os.Stat(projectDir); err == nil {
|
||||
if opts.discover {
|
||||
return reinitProjectWithDiscover(root, opts)
|
||||
partialInitRepair := false
|
||||
if info, err := os.Stat(projectDir); err == nil {
|
||||
if !info.IsDir() {
|
||||
return fmt.Errorf("project path exists but is not a directory: %s", projectDir)
|
||||
}
|
||||
return fmt.Errorf("project already initialized: %s\nRun 'skillshare init -p --discover' to add new targets", projectDir)
|
||||
if projectConfigExists(root) {
|
||||
if opts.discover {
|
||||
return reinitProjectWithDiscover(root, opts)
|
||||
}
|
||||
return fmt.Errorf("project already initialized: %s\nRun 'skillshare init -p --discover' to add new targets", projectDir)
|
||||
}
|
||||
partialInitRepair = true
|
||||
} else if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("failed to check project directory: %w", err)
|
||||
}
|
||||
|
||||
ui.Logo(version)
|
||||
ui.Header("Initializing project-level skills")
|
||||
if partialInitRepair {
|
||||
ui.Warning("Detected partial project initialization; repairing missing config")
|
||||
}
|
||||
|
||||
var selected []config.ProjectTargetEntry
|
||||
|
||||
@@ -112,10 +124,18 @@ func performProjectInit(root string, opts projectInitOptions) error {
|
||||
available = listAllProjectTargets()
|
||||
}
|
||||
|
||||
var err error
|
||||
selected, err = promptProjectTargets(available)
|
||||
if err != nil {
|
||||
return err
|
||||
if partialInitRepair {
|
||||
for _, target := range available {
|
||||
if target.exists || target.parentExists {
|
||||
selected = append(selected, config.ProjectTargetEntry{Name: target.name})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
selected, err = promptProjectTargets(available)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"skillshare/internal/testutil"
|
||||
@@ -82,3 +83,29 @@ func TestListProject_AutoDetectsMode(t *testing.T) {
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "Installed skills (project)")
|
||||
}
|
||||
|
||||
func TestListProject_PartialInit_RepairsMissingConfig(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
projectRoot := filepath.Join(sb.Root, "project")
|
||||
if err := os.MkdirAll(filepath.Join(projectRoot, ".skillshare", "skills"), 0755); err != nil {
|
||||
t.Fatalf("mkdir partial project skills dir: %v", err)
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Join(projectRoot, ".claude", "skills"), 0755); err != nil {
|
||||
t.Fatalf("mkdir project target dir: %v", err)
|
||||
}
|
||||
|
||||
result := sb.RunCLIInDir(projectRoot, "list", "-p")
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "No skills installed")
|
||||
|
||||
cfgPath := filepath.Join(projectRoot, ".skillshare", "config.yaml")
|
||||
if !sb.FileExists(cfgPath) {
|
||||
t.Fatalf("expected repaired config file at %s", cfgPath)
|
||||
}
|
||||
cfg := sb.ReadFile(cfgPath)
|
||||
if !strings.Contains(cfg, "claude") {
|
||||
t.Fatalf("expected repaired config to include detected claude target, got:\n%s", cfg)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user