mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-19 02:17:09 +00:00
feat!: rename pull <target> to collect, simplify pull for git-only
BREAKING CHANGE: Command restructure for clearer symmetry - Local sync: sync/collect (Source ↔ Targets) - Remote sync: push/pull (Source ↔ Git Remote) Changes: - Add `collect` command (was `pull <target>`) - Simplify `pull` to git remote only (was `pull --remote`) - Add spinner effects to pull and push commands - Update all documentation and skill references - Add CHANGELOG.md - Update help examples with practical workflows Migration: pull claude → collect claude pull --all → collect --all pull --remote → pull
This commit is contained in:
+101
@@ -0,0 +1,101 @@
|
||||
# Changelog
|
||||
|
||||
## [0.8.0] - 2026-01-31
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
**Command Rename: `pull <target>` → `collect <target>`**
|
||||
|
||||
For clearer command symmetry, `pull` is now exclusively for git operations:
|
||||
|
||||
| Before | After | Description |
|
||||
|--------|-------|-------------|
|
||||
| `pull claude` | `collect claude` | Collect skills from target to source |
|
||||
| `pull --all` | `collect --all` | Collect from all targets |
|
||||
| `pull --remote` | `pull` | Pull from git remote |
|
||||
|
||||
### New Command Symmetry
|
||||
|
||||
| Operation | Commands | Direction |
|
||||
|-----------|----------|-----------|
|
||||
| Local sync | `sync` / `collect` | Source ↔ Targets |
|
||||
| Remote sync | `push` / `pull` | Source ↔ Git Remote |
|
||||
|
||||
```
|
||||
Remote (git)
|
||||
↑ push ↓ pull
|
||||
Source
|
||||
↓ sync ↑ collect
|
||||
Targets
|
||||
```
|
||||
|
||||
### Migration
|
||||
|
||||
```bash
|
||||
# Before
|
||||
skillshare pull claude
|
||||
skillshare pull --remote
|
||||
|
||||
# After
|
||||
skillshare collect claude
|
||||
skillshare pull
|
||||
```
|
||||
|
||||
## [0.7.0] - 2026-01-20
|
||||
|
||||
### Added
|
||||
- Full Windows support (NTFS junctions, zip downloads, self-upgrade)
|
||||
- `search` command to discover skills from GitHub
|
||||
- Interactive skill selector for search results
|
||||
|
||||
### Changed
|
||||
- Windows uses NTFS junctions instead of symlinks (no admin required)
|
||||
|
||||
## [0.6.0] - 2026-01-15
|
||||
|
||||
### Added
|
||||
- Team Edition with tracked repositories
|
||||
- `--track` flag for `install` command
|
||||
- `update` command for tracked repos
|
||||
- Nested skill support with `__` separator
|
||||
|
||||
## [0.5.0] - 2026-01-10
|
||||
|
||||
### Added
|
||||
- `new` command to create skills with template
|
||||
- `doctor` command for diagnostics
|
||||
- `upgrade` command for self-upgrade
|
||||
|
||||
### Changed
|
||||
- Improved sync output with detailed statistics
|
||||
|
||||
## [0.4.0] - 2026-01-05
|
||||
|
||||
### Added
|
||||
- `diff` command to show differences
|
||||
- `backup` and `restore` commands
|
||||
- Automatic backup before sync
|
||||
|
||||
### Changed
|
||||
- Default sync mode changed to `merge`
|
||||
|
||||
## [0.3.0] - 2025-12-20
|
||||
|
||||
### Added
|
||||
- `push` and `pull --remote` for cross-machine sync
|
||||
- Git integration in `init` command
|
||||
|
||||
## [0.2.0] - 2025-12-15
|
||||
|
||||
### Added
|
||||
- `install` and `uninstall` commands
|
||||
- Support for git repo installation
|
||||
- `target add` and `target remove` commands
|
||||
|
||||
## [0.1.0] - 2025-12-10
|
||||
|
||||
### Added
|
||||
- Initial release
|
||||
- `init`, `sync`, `status`, `list` commands
|
||||
- Symlink and merge sync modes
|
||||
- Multi-target support
|
||||
@@ -34,7 +34,7 @@
|
||||
</p>
|
||||
|
||||
> [!NOTE]
|
||||
> **[What's New in 0.7.0](https://github.com/runkids/skillshare/releases/tag/v0.7.0)**: Full Windows support (NTFS junctions, zip downloads, self-upgrade), [Search skills](#search-skills) from GitHub. [Previous: Team Edition → docs/team-edition.md](docs/team-edition.md)
|
||||
> **[What's New in 0.8.0](https://github.com/runkids/skillshare/releases/tag/v0.8.0)**: Command rename: `pull <target>` → `collect <target>`, `pull --remote` → `pull`. Clearer command symmetry. [Previous: Windows support → v0.7.0](https://github.com/runkids/skillshare/releases/tag/v0.7.0)
|
||||
|
||||
## Why skillshare?
|
||||
|
||||
@@ -132,8 +132,9 @@ Done. Your skills are now synced across all AI CLI tools.
|
||||
| `new <name>` | Create a new skill with SKILL.md template |
|
||||
| `search <query>` | [Search GitHub for skills](#search-skills) |
|
||||
| `sync` | Sync skills to all targets |
|
||||
| `pull <target>` | Pull skills from target back to source |
|
||||
| `collect <target>` | Collect skills from target back to source |
|
||||
| `push` | Push to git remote (cross-machine) |
|
||||
| `pull` | Pull from git remote and sync |
|
||||
| `install <source>` | Install skill from path or git repo |
|
||||
| `uninstall <name>` | Remove skill from source |
|
||||
| `update <name>` | Update skill or tracked repo |
|
||||
@@ -179,7 +180,7 @@ AI reads skillshare skill → runs: skillshare sync
|
||||
✓ Synced 5 skills to claude, codex, cursor
|
||||
```
|
||||
|
||||
> **Try it:** *"Show my skillshare status"*, *"Pull skills from Claude"*, *"Install the pdf skill from anthropics/skills"*
|
||||
> **Try it:** *"Show my skillshare status"*, *"Collect skills from Claude"*, *"Install the pdf skill from anthropics/skills"*
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"skillshare/internal/config"
|
||||
"skillshare/internal/sync"
|
||||
"skillshare/internal/ui"
|
||||
)
|
||||
|
||||
// collectLocalSkills collects local skills from targets (non-symlinked)
|
||||
func collectLocalSkills(targets map[string]config.TargetConfig, source string) []sync.LocalSkillInfo {
|
||||
var allLocalSkills []sync.LocalSkillInfo
|
||||
for name, target := range targets {
|
||||
skills, err := sync.FindLocalSkills(target.Path, source)
|
||||
if err != nil {
|
||||
ui.Warning("%s: %v", name, err)
|
||||
continue
|
||||
}
|
||||
for i := range skills {
|
||||
skills[i].TargetName = name
|
||||
}
|
||||
allLocalSkills = append(allLocalSkills, skills...)
|
||||
}
|
||||
return allLocalSkills
|
||||
}
|
||||
|
||||
// displayLocalSkills shows the local skills found
|
||||
func displayLocalSkills(skills []sync.LocalSkillInfo) {
|
||||
ui.Header("Local skills found")
|
||||
for _, skill := range skills {
|
||||
ui.ListItem("info", skill.Name, fmt.Sprintf("[%s] %s", skill.TargetName, skill.Path))
|
||||
}
|
||||
}
|
||||
|
||||
func cmdCollect(args []string) error {
|
||||
dryRun := false
|
||||
force := false
|
||||
collectAll := false
|
||||
var targetName string
|
||||
|
||||
for _, arg := range args {
|
||||
switch arg {
|
||||
case "--dry-run", "-n":
|
||||
dryRun = true
|
||||
case "--force", "-f":
|
||||
force = true
|
||||
case "--all", "-a":
|
||||
collectAll = true
|
||||
default:
|
||||
if targetName == "" && !strings.HasPrefix(arg, "-") {
|
||||
targetName = arg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Select targets to collect from
|
||||
targets, err := selectCollectTargets(cfg, targetName, collectAll)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if targets == nil {
|
||||
return nil // User needs to specify target
|
||||
}
|
||||
|
||||
// Collect all local skills
|
||||
allLocalSkills := collectLocalSkills(targets, cfg.Source)
|
||||
|
||||
if len(allLocalSkills) == 0 {
|
||||
ui.Info("No local skills to collect")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Display found skills
|
||||
displayLocalSkills(allLocalSkills)
|
||||
|
||||
if dryRun {
|
||||
ui.Info("Dry run - no changes made")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Confirm unless --force
|
||||
if !force {
|
||||
if !confirmCollect() {
|
||||
ui.Info("Cancelled")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Execute collect
|
||||
return executeCollect(allLocalSkills, cfg.Source, dryRun, force)
|
||||
}
|
||||
|
||||
func selectCollectTargets(cfg *config.Config, targetName string, collectAll bool) (map[string]config.TargetConfig, error) {
|
||||
if targetName != "" {
|
||||
if t, exists := cfg.Targets[targetName]; exists {
|
||||
return map[string]config.TargetConfig{targetName: t}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("target '%s' not found", targetName)
|
||||
}
|
||||
|
||||
if collectAll || len(cfg.Targets) == 1 {
|
||||
return cfg.Targets, nil
|
||||
}
|
||||
|
||||
// If no target specified and multiple targets exist, ask or require --all
|
||||
ui.Warning("Multiple targets found. Specify a target name or use --all")
|
||||
fmt.Println(" Available targets:")
|
||||
for name := range cfg.Targets {
|
||||
fmt.Printf(" - %s\n", name)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func confirmCollect() bool {
|
||||
fmt.Println()
|
||||
fmt.Print("Collect these skills to source? [y/N]: ")
|
||||
var input string
|
||||
fmt.Scanln(&input)
|
||||
input = strings.ToLower(strings.TrimSpace(input))
|
||||
return input == "y" || input == "yes"
|
||||
}
|
||||
|
||||
func executeCollect(skills []sync.LocalSkillInfo, source string, dryRun, force bool) error {
|
||||
ui.Header("Collecting skills")
|
||||
result, err := sync.PullSkills(skills, source, sync.PullOptions{
|
||||
DryRun: dryRun,
|
||||
Force: force,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Display results
|
||||
for _, name := range result.Pulled {
|
||||
ui.Success("%s: copied to source", name)
|
||||
}
|
||||
for _, name := range result.Skipped {
|
||||
ui.Warning("%s: skipped (already exists in source, use --force to overwrite)", name)
|
||||
}
|
||||
for name, err := range result.Failed {
|
||||
ui.Error("%s: %v", name, err)
|
||||
}
|
||||
|
||||
if len(result.Pulled) > 0 {
|
||||
showCollectNextSteps(source)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func showCollectNextSteps(source string) {
|
||||
fmt.Println()
|
||||
ui.Info("Run 'skillshare sync' to distribute to all targets")
|
||||
|
||||
// Check if source has git
|
||||
gitDir := filepath.Join(source, ".git")
|
||||
if _, err := os.Stat(gitDir); err == nil {
|
||||
ui.Info("Commit changes: cd %s && git add . && git commit", source)
|
||||
}
|
||||
}
|
||||
+10
-7
@@ -23,6 +23,7 @@ var commands = map[string]func([]string) error{
|
||||
"diff": cmdDiff,
|
||||
"backup": cmdBackup,
|
||||
"restore": cmdRestore,
|
||||
"collect": cmdCollect,
|
||||
"pull": cmdPull,
|
||||
"push": cmdPush,
|
||||
"doctor": cmdDoctor,
|
||||
@@ -153,7 +154,7 @@ func printUsage() {
|
||||
|
||||
// Sync & Backup
|
||||
fmt.Println("SYNC & BACKUP")
|
||||
cmd("pull", "[target]", "Pull local skills from target(s) to source")
|
||||
cmd("collect", "[target]", "Collect local skills from target(s) to source")
|
||||
cmd("backup", "", "Create backup of target(s)")
|
||||
cmd("restore", "<target>", "Restore target from latest backup")
|
||||
fmt.Println()
|
||||
@@ -161,7 +162,7 @@ func printUsage() {
|
||||
// Git Remote
|
||||
fmt.Println("GIT REMOTE")
|
||||
cmd("push", "", "Commit and push source to git remote")
|
||||
cmd("pull", "--remote", "Pull from git remote and sync to targets")
|
||||
cmd("pull", "", "Pull from git remote and sync to targets")
|
||||
fmt.Println()
|
||||
|
||||
// Utilities
|
||||
@@ -173,11 +174,13 @@ func printUsage() {
|
||||
|
||||
// Examples
|
||||
fmt.Println("EXAMPLES")
|
||||
fmt.Println(g + " skillshare init --source ~/.skills")
|
||||
fmt.Println(" skillshare new my-skill")
|
||||
fmt.Println(" skillshare install github.com/user/skill-repo")
|
||||
fmt.Println(" skillshare target add claude ~/.claude/skills")
|
||||
fmt.Println(" skillshare sync" + r)
|
||||
fmt.Println(g + " skillshare status # Check current state")
|
||||
fmt.Println(" skillshare sync --dry-run # Preview before sync")
|
||||
fmt.Println(" skillshare collect claude # Import local skills")
|
||||
fmt.Println(" skillshare push -m \"Add new skill\" # Push to remote")
|
||||
fmt.Println(" skillshare pull # Pull from remote")
|
||||
fmt.Println(" skillshare install github.com/team/skills --track # Team repo")
|
||||
fmt.Println(" skillshare update --all # Update all repos" + r)
|
||||
}
|
||||
|
||||
// cleanupOldBinary removes leftover .old files from Windows self-upgrade.
|
||||
|
||||
+15
-155
@@ -8,31 +8,16 @@ import (
|
||||
"strings"
|
||||
|
||||
"skillshare/internal/config"
|
||||
"skillshare/internal/sync"
|
||||
"skillshare/internal/ui"
|
||||
)
|
||||
|
||||
func cmdPull(args []string) error {
|
||||
dryRun := false
|
||||
force := false
|
||||
pullAll := false
|
||||
pullRemote := false
|
||||
var targetName string
|
||||
|
||||
for _, arg := range args {
|
||||
switch arg {
|
||||
case "--dry-run", "-n":
|
||||
dryRun = true
|
||||
case "--force", "-f":
|
||||
force = true
|
||||
case "--all", "-a":
|
||||
pullAll = true
|
||||
case "--remote", "-r":
|
||||
pullRemote = true
|
||||
default:
|
||||
if targetName == "" && !strings.HasPrefix(arg, "-") {
|
||||
targetName = arg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,148 +26,19 @@ func cmdPull(args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Handle --remote: pull from git remote and sync
|
||||
if pullRemote {
|
||||
return pullFromRemote(cfg, dryRun)
|
||||
}
|
||||
|
||||
// Select targets to pull from
|
||||
targets, err := selectPullTargets(cfg, targetName, pullAll)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if targets == nil {
|
||||
return nil // User needs to specify target
|
||||
}
|
||||
|
||||
// Collect all local skills
|
||||
allLocalSkills := collectLocalSkills(targets, cfg.Source)
|
||||
|
||||
if len(allLocalSkills) == 0 {
|
||||
ui.Info("No local skills to pull")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Display found skills
|
||||
displayLocalSkills(allLocalSkills)
|
||||
|
||||
if dryRun {
|
||||
ui.Info("Dry run - no changes made")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Confirm unless --force
|
||||
if !force {
|
||||
if !confirmPull() {
|
||||
ui.Info("Cancelled")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Execute pull
|
||||
return executePull(allLocalSkills, cfg.Source, dryRun, force)
|
||||
}
|
||||
|
||||
func selectPullTargets(cfg *config.Config, targetName string, pullAll bool) (map[string]config.TargetConfig, error) {
|
||||
if targetName != "" {
|
||||
if t, exists := cfg.Targets[targetName]; exists {
|
||||
return map[string]config.TargetConfig{targetName: t}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("target '%s' not found", targetName)
|
||||
}
|
||||
|
||||
if pullAll || len(cfg.Targets) == 1 {
|
||||
return cfg.Targets, nil
|
||||
}
|
||||
|
||||
// If no target specified and multiple targets exist, ask or require --all
|
||||
ui.Warning("Multiple targets found. Specify a target name or use --all")
|
||||
fmt.Println(" Available targets:")
|
||||
for name := range cfg.Targets {
|
||||
fmt.Printf(" - %s\n", name)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func collectLocalSkills(targets map[string]config.TargetConfig, source string) []sync.LocalSkillInfo {
|
||||
var allLocalSkills []sync.LocalSkillInfo
|
||||
for name, target := range targets {
|
||||
skills, err := sync.FindLocalSkills(target.Path, source)
|
||||
if err != nil {
|
||||
ui.Warning("%s: %v", name, err)
|
||||
continue
|
||||
}
|
||||
for i := range skills {
|
||||
skills[i].TargetName = name
|
||||
}
|
||||
allLocalSkills = append(allLocalSkills, skills...)
|
||||
}
|
||||
return allLocalSkills
|
||||
}
|
||||
|
||||
func displayLocalSkills(skills []sync.LocalSkillInfo) {
|
||||
ui.Header("Local skills found")
|
||||
for _, skill := range skills {
|
||||
ui.ListItem("info", skill.Name, fmt.Sprintf("[%s] %s", skill.TargetName, skill.Path))
|
||||
}
|
||||
}
|
||||
|
||||
func confirmPull() bool {
|
||||
fmt.Println()
|
||||
fmt.Print("Pull these skills to source? [y/N]: ")
|
||||
var input string
|
||||
fmt.Scanln(&input)
|
||||
input = strings.ToLower(strings.TrimSpace(input))
|
||||
return input == "y" || input == "yes"
|
||||
}
|
||||
|
||||
func executePull(skills []sync.LocalSkillInfo, source string, dryRun, force bool) error {
|
||||
ui.Header("Pulling skills")
|
||||
result, err := sync.PullSkills(skills, source, sync.PullOptions{
|
||||
DryRun: dryRun,
|
||||
Force: force,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Display results
|
||||
for _, name := range result.Pulled {
|
||||
ui.Success("%s: copied to source", name)
|
||||
}
|
||||
for _, name := range result.Skipped {
|
||||
ui.Warning("%s: skipped (already exists in source, use --force to overwrite)", name)
|
||||
}
|
||||
for name, err := range result.Failed {
|
||||
ui.Error("%s: %v", name, err)
|
||||
}
|
||||
|
||||
if len(result.Pulled) > 0 {
|
||||
showPullNextSteps(source)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func showPullNextSteps(source string) {
|
||||
fmt.Println()
|
||||
ui.Info("Run 'skillshare sync' to distribute to all targets")
|
||||
|
||||
// Check if source has git
|
||||
gitDir := filepath.Join(source, ".git")
|
||||
if _, err := os.Stat(gitDir); err == nil {
|
||||
ui.Info("Commit changes: cd %s && git add . && git commit", source)
|
||||
}
|
||||
return pullFromRemote(cfg, dryRun)
|
||||
}
|
||||
|
||||
// pullFromRemote pulls from git remote and syncs to all targets
|
||||
func pullFromRemote(cfg *config.Config, dryRun bool) error {
|
||||
ui.Header("Pulling from remote")
|
||||
|
||||
spinner := ui.StartSpinner("Checking repository...")
|
||||
|
||||
// Check if source is a git repo
|
||||
gitDir := filepath.Join(cfg.Source, ".git")
|
||||
if _, err := os.Stat(gitDir); os.IsNotExist(err) {
|
||||
ui.Error("Source is not a git repository")
|
||||
spinner.Fail("Source is not a git repository")
|
||||
ui.Info(" Run: cd %s && git init", cfg.Source)
|
||||
return nil
|
||||
}
|
||||
@@ -192,7 +48,7 @@ func pullFromRemote(cfg *config.Config, dryRun bool) error {
|
||||
cmd.Dir = cfg.Source
|
||||
output, err := cmd.Output()
|
||||
if err != nil || strings.TrimSpace(string(output)) == "" {
|
||||
ui.Error("No git remote configured")
|
||||
spinner.Fail("No git remote configured")
|
||||
ui.Info(" Run: cd %s && git remote add origin <url>", cfg.Source)
|
||||
return nil
|
||||
}
|
||||
@@ -202,17 +58,19 @@ func pullFromRemote(cfg *config.Config, dryRun bool) error {
|
||||
cmd.Dir = cfg.Source
|
||||
output, err = cmd.Output()
|
||||
if err != nil {
|
||||
spinner.Fail("Failed to check git status")
|
||||
return fmt.Errorf("failed to check git status: %w", err)
|
||||
}
|
||||
|
||||
if len(strings.TrimSpace(string(output))) > 0 {
|
||||
ui.Error("Local changes detected - commit or stash first")
|
||||
spinner.Fail("Local changes detected")
|
||||
ui.Info(" Run: skillshare push")
|
||||
ui.Info(" Or: cd %s && git stash", cfg.Source)
|
||||
return nil
|
||||
}
|
||||
|
||||
if dryRun {
|
||||
spinner.Stop()
|
||||
ui.Warning("[dry-run] No changes will be made")
|
||||
fmt.Println()
|
||||
ui.Info("Would run: git pull")
|
||||
@@ -221,17 +79,19 @@ func pullFromRemote(cfg *config.Config, dryRun bool) error {
|
||||
}
|
||||
|
||||
// Git pull
|
||||
ui.Info("Running git pull...")
|
||||
spinner.Update("Running git pull...")
|
||||
cmd = exec.Command("git", "pull")
|
||||
cmd.Dir = cfg.Source
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
pullOutput, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
spinner.Fail("git pull failed")
|
||||
fmt.Println(string(pullOutput))
|
||||
return fmt.Errorf("git pull failed: %w", err)
|
||||
}
|
||||
|
||||
spinner.Success("Pull complete")
|
||||
|
||||
// Sync to all targets
|
||||
fmt.Println()
|
||||
ui.Info("Syncing to all targets...")
|
||||
return cmdSync([]string{})
|
||||
}
|
||||
|
||||
+24
-21
@@ -43,10 +43,10 @@ func parsePushArgs(args []string) *pushOptions {
|
||||
}
|
||||
|
||||
// checkGitRepo verifies source is a git repo with remote
|
||||
func checkGitRepo(sourcePath string) error {
|
||||
func checkGitRepo(sourcePath string, spinner *ui.Spinner) error {
|
||||
gitDir := sourcePath + "/.git"
|
||||
if _, err := os.Stat(gitDir); os.IsNotExist(err) {
|
||||
ui.Error("Source is not a git repository")
|
||||
spinner.Fail("Source is not a git repository")
|
||||
ui.Info(" Run: cd %s && git init", sourcePath)
|
||||
return fmt.Errorf("not a git repository")
|
||||
}
|
||||
@@ -55,7 +55,7 @@ func checkGitRepo(sourcePath string) error {
|
||||
cmd.Dir = sourcePath
|
||||
output, err := cmd.Output()
|
||||
if err != nil || strings.TrimSpace(string(output)) == "" {
|
||||
ui.Error("No git remote configured")
|
||||
spinner.Fail("No git remote configured")
|
||||
ui.Info(" Run: cd %s && git remote add origin <url>", sourcePath)
|
||||
ui.Info(" Or: skillshare init --remote <url>")
|
||||
return fmt.Errorf("no remote configured")
|
||||
@@ -76,18 +76,20 @@ func getGitChanges(sourcePath string) (string, error) {
|
||||
}
|
||||
|
||||
// stageAndCommit stages all changes and commits
|
||||
func stageAndCommit(sourcePath, message string) error {
|
||||
ui.Info("Staging changes...")
|
||||
func stageAndCommit(sourcePath, message string, spinner *ui.Spinner) error {
|
||||
spinner.Update("Staging changes...")
|
||||
cmd := exec.Command("git", "add", "-A")
|
||||
cmd.Dir = sourcePath
|
||||
if err := cmd.Run(); err != nil {
|
||||
spinner.Fail("Failed to stage changes")
|
||||
return fmt.Errorf("failed to stage changes: %w", err)
|
||||
}
|
||||
|
||||
ui.Info("Committing...")
|
||||
spinner.Update("Committing...")
|
||||
cmd = exec.Command("git", "commit", "-m", message)
|
||||
cmd.Dir = sourcePath
|
||||
if err := cmd.Run(); err != nil {
|
||||
spinner.Fail("Failed to commit")
|
||||
return fmt.Errorf("failed to commit: %w", err)
|
||||
}
|
||||
|
||||
@@ -95,16 +97,16 @@ func stageAndCommit(sourcePath, message string) error {
|
||||
}
|
||||
|
||||
// gitPush pushes to remote
|
||||
func gitPush(sourcePath string) error {
|
||||
ui.Info("Pushing to remote...")
|
||||
func gitPush(sourcePath string, spinner *ui.Spinner) error {
|
||||
spinner.Update("Pushing to remote...")
|
||||
cmd := exec.Command("git", "push")
|
||||
cmd.Dir = sourcePath
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Println()
|
||||
ui.Error("Push failed - remote may have newer changes")
|
||||
ui.Info(" Run: skillshare pull --remote")
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
spinner.Fail("Push failed")
|
||||
fmt.Println(string(output))
|
||||
ui.Info(" Remote may have newer changes")
|
||||
ui.Info(" Run: skillshare pull")
|
||||
ui.Info(" Then: skillshare push")
|
||||
return fmt.Errorf("push failed")
|
||||
}
|
||||
@@ -121,17 +123,21 @@ func cmdPush(args []string) error {
|
||||
|
||||
ui.Header("Pushing to remote")
|
||||
|
||||
if err := checkGitRepo(cfg.Source); err != nil {
|
||||
spinner := ui.StartSpinner("Checking repository...")
|
||||
|
||||
if err := checkGitRepo(cfg.Source, spinner); err != nil {
|
||||
return nil // Error already displayed
|
||||
}
|
||||
|
||||
changes, err := getGitChanges(cfg.Source)
|
||||
if err != nil {
|
||||
spinner.Fail("Failed to check git status")
|
||||
return err
|
||||
}
|
||||
hasChanges := changes != ""
|
||||
|
||||
if opts.dryRun {
|
||||
spinner.Stop()
|
||||
ui.Warning("[dry-run] No changes will be made")
|
||||
fmt.Println()
|
||||
if hasChanges {
|
||||
@@ -149,18 +155,15 @@ func cmdPush(args []string) error {
|
||||
}
|
||||
|
||||
if hasChanges {
|
||||
if err := stageAndCommit(cfg.Source, opts.message); err != nil {
|
||||
if err := stageAndCommit(cfg.Source, opts.message, spinner); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
ui.Info("No changes to commit")
|
||||
}
|
||||
|
||||
if err := gitPush(cfg.Source); err != nil {
|
||||
if err := gitPush(cfg.Source, spinner); err != nil {
|
||||
return nil // Error already displayed
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
ui.Success("Pushed to remote")
|
||||
spinner.Success("Push complete")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ skillshare push -m "Add new pdf skill"
|
||||
### Machine B: Pull and Sync
|
||||
|
||||
```bash
|
||||
skillshare pull --remote
|
||||
skillshare pull
|
||||
```
|
||||
|
||||
That's it. Your skills are now synced across machines.
|
||||
@@ -108,13 +108,13 @@ skillshare push -m "Add pdf" # Custom message
|
||||
Pull remote changes and sync to all targets.
|
||||
|
||||
```bash
|
||||
skillshare pull --remote
|
||||
skillshare pull
|
||||
```
|
||||
|
||||
**What happens:**
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ skillshare pull --remote │
|
||||
│ skillshare pull │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
@@ -187,26 +187,26 @@ skillshare sync
|
||||
|
||||
```
|
||||
$ skillshare push
|
||||
Error: remote has changes. Run 'skillshare pull --remote' first.
|
||||
Error: remote has changes. Run 'skillshare pull' first.
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
```bash
|
||||
skillshare pull --remote # Get remote changes first
|
||||
skillshare push # Now push works
|
||||
skillshare pull # Get remote changes first
|
||||
skillshare push # Now push works
|
||||
```
|
||||
|
||||
### Pull Fails (Local Uncommitted Changes)
|
||||
|
||||
```
|
||||
$ skillshare pull --remote
|
||||
$ skillshare pull
|
||||
Error: local has uncommitted changes. Run 'skillshare push' first.
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
```bash
|
||||
skillshare push -m "Save local changes"
|
||||
skillshare pull --remote
|
||||
skillshare pull
|
||||
```
|
||||
|
||||
### Merge Conflicts
|
||||
|
||||
+4
-4
@@ -53,7 +53,7 @@ Use git-based cross-machine sync:
|
||||
skillshare push -m "Add new skill"
|
||||
|
||||
# Machine B: pull and sync
|
||||
skillshare pull --remote
|
||||
skillshare pull
|
||||
```
|
||||
|
||||
See [cross-machine.md](cross-machine.md) for full setup.
|
||||
@@ -154,17 +154,17 @@ ignore:
|
||||
|
||||
### Pull conflicts with local changes
|
||||
|
||||
If `pull --remote` fails due to local changes:
|
||||
If `pull` fails due to local changes:
|
||||
|
||||
```bash
|
||||
# Option 1: Push your changes first
|
||||
skillshare push -m "Local changes"
|
||||
skillshare pull --remote
|
||||
skillshare pull
|
||||
|
||||
# Option 2: Discard local changes
|
||||
cd ~/.config/skillshare/skills
|
||||
git checkout -- .
|
||||
skillshare pull --remote
|
||||
skillshare pull
|
||||
```
|
||||
|
||||
### Skill not appearing in AI CLI
|
||||
|
||||
+36
-21
@@ -1,4 +1,16 @@
|
||||
# Sync, Pull, Push & Backup
|
||||
# Sync, Collect, Pull, Push & Backup
|
||||
|
||||
## Command Overview
|
||||
|
||||
| 操作類型 | 命令 | 方向 |
|
||||
|----------|------|------|
|
||||
| **本地同步** | `sync` / `collect` | Source ↔ Targets |
|
||||
| **遠端同步** | `push` / `pull` | Source ↔ Git Remote |
|
||||
|
||||
- `sync` = 從 Source 分發到 Targets
|
||||
- `collect` = 從 Targets 收集回 Source
|
||||
- `push` = 推送到 git 遠端
|
||||
- `pull` = 從 git 遠端拉取並同步
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -10,13 +22,13 @@
|
||||
│ │ Remote │ │
|
||||
│ │ (git) │ │
|
||||
│ └────┬─────┘ │
|
||||
│ push ↑ │ ↓ pull --remote │
|
||||
│ push ↑ │ ↓ pull │
|
||||
│ │ │
|
||||
│ ┌────────────────────────┼────────────────────────┐ │
|
||||
│ │ SOURCE │ │
|
||||
│ │ ~/.config/skillshare/skills/ │ │
|
||||
│ └────────────────────────┬────────────────────────┘ │
|
||||
│ sync ↓ │ ↑ pull <target> │
|
||||
│ sync ↓ │ ↑ collect │
|
||||
│ ┌───────────────────┼───────────────────┐ │
|
||||
│ ▼ ▼ ▼ │
|
||||
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
||||
@@ -29,9 +41,9 @@
|
||||
| Command | Direction | Description |
|
||||
|---------|-----------|-------------|
|
||||
| `sync` | Source → Targets | Push skills to all targets |
|
||||
| `pull <target>` | Target → Source | Pull skills from one target |
|
||||
| `collect <target>` | Target → Source | Collect skills from target to source |
|
||||
| `push` | Source → Remote | Commit and push to git |
|
||||
| `pull --remote` | Remote → Source → Targets | Pull from git, then sync |
|
||||
| `pull` | Remote → Source → Targets | Pull from git, then sync |
|
||||
|
||||
---
|
||||
|
||||
@@ -145,7 +157,7 @@ claude
|
||||
- local-only-skill local only
|
||||
|
||||
Run 'sync' to add missing, 'sync --force' to replace local copies
|
||||
Run 'pull claude' to import local-only skills to source
|
||||
Run 'collect claude' to import local-only skills to source
|
||||
```
|
||||
|
||||
### Symbols
|
||||
@@ -154,27 +166,25 @@ Run 'pull claude' to import local-only skills to source
|
||||
|--------|---------|--------|
|
||||
| `+` | In source, missing in target | `sync` will add |
|
||||
| `~` | Both have it, but target is a local copy (not symlink) | `sync --force` to replace with symlink |
|
||||
| `-` | Only in target, not in source | `pull` to import to source |
|
||||
| `-` | Only in target, not in source | `collect` to import to source |
|
||||
|
||||
---
|
||||
|
||||
## Pull
|
||||
## Collect
|
||||
|
||||
Pull skills from a target back to source.
|
||||
|
||||
### Pull from Target
|
||||
Collect skills from a target back to source.
|
||||
|
||||
```bash
|
||||
skillshare pull claude # Pull from Claude
|
||||
skillshare pull claude --dry-run # Preview
|
||||
skillshare pull --all # Pull from all targets
|
||||
skillshare collect claude # Collect from Claude
|
||||
skillshare collect claude --dry-run # Preview
|
||||
skillshare collect --all # Collect from all targets
|
||||
```
|
||||
|
||||
**When to use**: You created/edited a skill directly in a target (e.g., `~/.claude/skills/`) and want to bring it to source.
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ skillshare pull claude │
|
||||
│ skillshare collect claude │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
@@ -196,23 +206,28 @@ skillshare pull --all # Pull from all targets
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**After pulling:**
|
||||
**After collecting:**
|
||||
```bash
|
||||
skillshare pull claude
|
||||
skillshare collect claude
|
||||
skillshare sync # ← Distribute to other targets
|
||||
```
|
||||
|
||||
### Pull from Remote
|
||||
---
|
||||
|
||||
## Pull
|
||||
|
||||
Pull from git remote and sync to all targets.
|
||||
|
||||
```bash
|
||||
skillshare pull --remote # Pull from git remote
|
||||
skillshare pull # Pull from git remote
|
||||
skillshare pull --dry-run # Preview
|
||||
```
|
||||
|
||||
**When to use**: You pushed changes from another machine and want to sync them here.
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ skillshare pull --remote │
|
||||
│ skillshare pull │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
@@ -253,7 +268,7 @@ skillshare push -m "Add pdf" # Custom message
|
||||
```
|
||||
|
||||
**Conflict handling:**
|
||||
- If remote is ahead, `push` fails → run `pull --remote` first
|
||||
- If remote is ahead, `push` fails → run `pull` first
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: skillshare
|
||||
version: 0.6.4
|
||||
description: Syncs skills across AI CLI tools from a single source of truth. Use when asked to "sync skills", "pull skills", "show status", "list skills", "install skill", "initialize skillshare", or manage skill targets.
|
||||
version: 0.8.0
|
||||
description: Syncs skills across AI CLI tools from a single source of truth. Use when asked to "sync skills", "collect skills", "pull from remote", "show status", "list skills", "install skill", "initialize skillshare", or manage skill targets.
|
||||
argument-hint: "[command] [target] [--dry-run]"
|
||||
---
|
||||
|
||||
@@ -19,7 +19,7 @@ Targets: ~/.claude/skills, ~/.cursor/skills, ... ← Symlinked from source
|
||||
skillshare status # Always run first
|
||||
skillshare sync # Push to all targets
|
||||
skillshare sync --dry-run # Preview changes
|
||||
skillshare pull claude # Import from target → source
|
||||
skillshare collect claude # Import from target → source
|
||||
skillshare list # Show skills and tracked repos
|
||||
```
|
||||
|
||||
@@ -30,7 +30,7 @@ skillshare list # Show skills and tracked repos
|
||||
| Sync skills | `skillshare sync` |
|
||||
| Preview first | `skillshare sync --dry-run` then `sync` |
|
||||
| Create new skill | `skillshare new <name>` then `sync` |
|
||||
| Pull from target | `skillshare pull <name>` then `sync` |
|
||||
| Collect from target | `skillshare collect <name>` then `sync` |
|
||||
| Install skill | `skillshare install <source>` then `sync` |
|
||||
| Install from repo (browse) | `skillshare install owner/repo` (discovery mode) |
|
||||
| Install team repo | `skillshare install <git-url> --track` then `sync` |
|
||||
@@ -39,7 +39,7 @@ skillshare list # Show skills and tracked repos
|
||||
| Remove skill | `skillshare uninstall <name>` then `sync` |
|
||||
| List skills | `skillshare list` or `list --verbose` |
|
||||
| Cross-machine push | `skillshare push -m "message"` |
|
||||
| Cross-machine pull | `skillshare pull --remote` |
|
||||
| Cross-machine pull | `skillshare pull` |
|
||||
| Backup/restore | `skillshare backup --list`, `restore <target>` |
|
||||
| Add custom target | `skillshare target add <name> <path>` |
|
||||
| Change sync mode | `skillshare target <name> --mode merge\|symlink` |
|
||||
|
||||
@@ -9,7 +9,7 @@ Common issues, solutions, and tips for AI assistants.
|
||||
| "config not found" | Config missing | Run `skillshare init` |
|
||||
| Target shows differences | Files out of sync | Run `skillshare sync` |
|
||||
| Lost source files | Deleted via symlink | `cd ~/.config/skillshare/skills && git checkout -- <skill>/` |
|
||||
| Target has local skills | Need to preserve | Ensure `merge` mode, then `skillshare pull` before sync |
|
||||
| Target has local skills | Need to preserve | Ensure `merge` mode, then `skillshare collect` before sync |
|
||||
| Skill not appearing | Not synced yet | Run `skillshare sync` after install |
|
||||
| Can't find installed skills | Wrong directory | Check `skillshare status` for source path |
|
||||
| "permission denied" | Symlink issues | Check file ownership and permissions |
|
||||
@@ -67,7 +67,7 @@ Always use `--dry-run` in these situations:
|
||||
|
||||
- User is cautious or new to skillshare
|
||||
- Before `sync` on first use
|
||||
- Before `pull --all` to see what will be imported
|
||||
- Before `collect --all` to see what will be imported
|
||||
- Before `install` from unknown sources
|
||||
- Before `restore` to preview what will change
|
||||
- Before `target remove` to understand impact
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
# Sync, Pull & Push Commands
|
||||
# Sync, Collect, Pull & Push Commands
|
||||
|
||||
## Command Overview
|
||||
|
||||
| 操作類型 | 命令 | 方向 |
|
||||
|----------|------|------|
|
||||
| **本地同步** | `sync` / `collect` | Source ↔ Targets |
|
||||
| **遠端同步** | `push` / `pull` | Source ↔ Git Remote |
|
||||
|
||||
## sync
|
||||
|
||||
@@ -9,14 +16,23 @@ skillshare sync # Execute sync
|
||||
skillshare sync --dry-run # Preview only
|
||||
```
|
||||
|
||||
## pull
|
||||
## collect
|
||||
|
||||
Brings skills from target(s) to source.
|
||||
|
||||
```bash
|
||||
skillshare pull claude # Pull from specific target
|
||||
skillshare pull --all # Pull from all targets
|
||||
skillshare pull --remote # Pull from git remote + sync all
|
||||
skillshare collect claude # Collect from specific target
|
||||
skillshare collect --all # Collect from all targets
|
||||
skillshare collect --dry-run # Preview only
|
||||
```
|
||||
|
||||
## pull
|
||||
|
||||
Pulls from git remote and syncs to all targets.
|
||||
|
||||
```bash
|
||||
skillshare pull # Pull from git remote + sync all
|
||||
skillshare pull --dry-run # Preview only
|
||||
```
|
||||
|
||||
## push
|
||||
@@ -33,9 +49,9 @@ skillshare push --dry-run # Preview only
|
||||
|
||||
**Local workflow:**
|
||||
1. Create skill in any target (e.g., `~/.claude/skills/my-skill/`)
|
||||
2. `skillshare pull claude` - bring to source
|
||||
2. `skillshare collect claude` - bring to source
|
||||
3. `skillshare sync` - distribute to all targets
|
||||
|
||||
**Cross-machine workflow:**
|
||||
1. Machine A: `skillshare push` - commit and push to remote
|
||||
2. Machine B: `skillshare pull --remote` - pull from remote + sync
|
||||
2. Machine B: `skillshare pull` - pull from remote + sync
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"skillshare/internal/testutil"
|
||||
)
|
||||
|
||||
func TestCollect_FindsLocalSkills(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
targetPath := sb.CreateTarget("claude")
|
||||
|
||||
// Create local skill in target (not a symlink)
|
||||
localSkillPath := filepath.Join(targetPath, "local-skill")
|
||||
os.MkdirAll(localSkillPath, 0755)
|
||||
os.WriteFile(filepath.Join(localSkillPath, "SKILL.md"), []byte("# Local Skill"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + targetPath + `
|
||||
`)
|
||||
|
||||
// Run with --dry-run to just see what would be collected
|
||||
result := sb.RunCLI("collect", "--dry-run")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "local-skill")
|
||||
}
|
||||
|
||||
func TestCollect_SpecificTarget_OnlyThat(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
claudePath := sb.CreateTarget("claude")
|
||||
codexPath := sb.CreateTarget("codex")
|
||||
|
||||
// Create local skills in both targets
|
||||
os.MkdirAll(filepath.Join(claudePath, "claude-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(claudePath, "claude-skill", "SKILL.md"), []byte("# Claude"), 0644)
|
||||
os.MkdirAll(filepath.Join(codexPath, "codex-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(codexPath, "codex-skill", "SKILL.md"), []byte("# Codex"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + claudePath + `
|
||||
codex:
|
||||
path: ` + codexPath + `
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("collect", "claude", "--dry-run")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "claude-skill")
|
||||
result.AssertOutputNotContains(t, "codex-skill")
|
||||
}
|
||||
|
||||
func TestCollect_All_FromAllTargets(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
claudePath := sb.CreateTarget("claude")
|
||||
codexPath := sb.CreateTarget("codex")
|
||||
|
||||
// Create local skills in both targets
|
||||
os.MkdirAll(filepath.Join(claudePath, "claude-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(claudePath, "claude-skill", "SKILL.md"), []byte("# Claude"), 0644)
|
||||
os.MkdirAll(filepath.Join(codexPath, "codex-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(codexPath, "codex-skill", "SKILL.md"), []byte("# Codex"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + claudePath + `
|
||||
codex:
|
||||
path: ` + codexPath + `
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("collect", "--all", "--dry-run")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "claude-skill")
|
||||
result.AssertOutputContains(t, "codex-skill")
|
||||
}
|
||||
|
||||
func TestCollect_NoLocalSkills_ShowsMessage(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
sb.CreateSkill("shared-skill", map[string]string{"SKILL.md": "# Shared"})
|
||||
targetPath := sb.CreateTarget("claude")
|
||||
|
||||
// Create only symlinked skill (not local)
|
||||
os.Symlink(filepath.Join(sb.SourcePath, "shared-skill"), filepath.Join(targetPath, "shared-skill"))
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + targetPath + `
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("collect")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "No local skills")
|
||||
}
|
||||
|
||||
func TestCollect_TargetNotFound_ReturnsError(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets: {}
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("collect", "nonexistent")
|
||||
|
||||
result.AssertFailure(t)
|
||||
result.AssertAnyOutputContains(t, "not found")
|
||||
}
|
||||
|
||||
func TestCollect_CopiesToSource(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
targetPath := sb.CreateTarget("claude")
|
||||
|
||||
// Create local skill
|
||||
localSkillPath := filepath.Join(targetPath, "new-skill")
|
||||
os.MkdirAll(localSkillPath, 0755)
|
||||
os.WriteFile(filepath.Join(localSkillPath, "SKILL.md"), []byte("# New Skill Content"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + targetPath + `
|
||||
`)
|
||||
|
||||
// Run with force to skip confirmation
|
||||
result := sb.RunCLIWithInput("y\n", "collect", "--force")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "copied to source")
|
||||
|
||||
// Verify skill was copied to source
|
||||
copiedSkillPath := filepath.Join(sb.SourcePath, "new-skill", "SKILL.md")
|
||||
if !sb.FileExists(copiedSkillPath) {
|
||||
t.Error("skill should be copied to source")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCollect_ExistsInSource_Skips(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
// Create skill in source first
|
||||
sb.CreateSkill("existing-skill", map[string]string{"SKILL.md": "# Source Version"})
|
||||
|
||||
targetPath := sb.CreateTarget("claude")
|
||||
|
||||
// Create same skill in target (local copy)
|
||||
localSkillPath := filepath.Join(targetPath, "existing-skill")
|
||||
os.MkdirAll(localSkillPath, 0755)
|
||||
os.WriteFile(filepath.Join(localSkillPath, "SKILL.md"), []byte("# Target Version"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + targetPath + `
|
||||
`)
|
||||
|
||||
result := sb.RunCLIWithInput("y\n", "collect")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "skipped")
|
||||
}
|
||||
|
||||
func TestCollect_MultipleTargets_RequiresAllOrName(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
claudePath := sb.CreateTarget("claude")
|
||||
codexPath := sb.CreateTarget("codex")
|
||||
|
||||
// Create local skills in both targets
|
||||
os.MkdirAll(filepath.Join(claudePath, "skill1"), 0755)
|
||||
os.WriteFile(filepath.Join(claudePath, "skill1", "SKILL.md"), []byte("# 1"), 0644)
|
||||
os.MkdirAll(filepath.Join(codexPath, "skill2"), 0755)
|
||||
os.WriteFile(filepath.Join(codexPath, "skill2", "SKILL.md"), []byte("# 2"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + claudePath + `
|
||||
codex:
|
||||
path: ` + codexPath + `
|
||||
`)
|
||||
|
||||
// Without specifying target or --all
|
||||
result := sb.RunCLI("collect")
|
||||
|
||||
// Should ask to specify target
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "Specify a target")
|
||||
}
|
||||
+12
-214
@@ -1,7 +1,6 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -9,109 +8,9 @@ import (
|
||||
"skillshare/internal/testutil"
|
||||
)
|
||||
|
||||
func TestPull_FindsLocalSkills(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
// Tests for pull command (git remote operations)
|
||||
|
||||
targetPath := sb.CreateTarget("claude")
|
||||
|
||||
// Create local skill in target (not a symlink)
|
||||
localSkillPath := filepath.Join(targetPath, "local-skill")
|
||||
os.MkdirAll(localSkillPath, 0755)
|
||||
os.WriteFile(filepath.Join(localSkillPath, "SKILL.md"), []byte("# Local Skill"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + targetPath + `
|
||||
`)
|
||||
|
||||
// Run with --dry-run to just see what would be pulled
|
||||
result := sb.RunCLI("pull", "--dry-run")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "local-skill")
|
||||
}
|
||||
|
||||
func TestPull_SpecificTarget_OnlyThat(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
claudePath := sb.CreateTarget("claude")
|
||||
codexPath := sb.CreateTarget("codex")
|
||||
|
||||
// Create local skills in both targets
|
||||
os.MkdirAll(filepath.Join(claudePath, "claude-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(claudePath, "claude-skill", "SKILL.md"), []byte("# Claude"), 0644)
|
||||
os.MkdirAll(filepath.Join(codexPath, "codex-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(codexPath, "codex-skill", "SKILL.md"), []byte("# Codex"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + claudePath + `
|
||||
codex:
|
||||
path: ` + codexPath + `
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("pull", "claude", "--dry-run")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "claude-skill")
|
||||
result.AssertOutputNotContains(t, "codex-skill")
|
||||
}
|
||||
|
||||
func TestPull_All_FromAllTargets(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
claudePath := sb.CreateTarget("claude")
|
||||
codexPath := sb.CreateTarget("codex")
|
||||
|
||||
// Create local skills in both targets
|
||||
os.MkdirAll(filepath.Join(claudePath, "claude-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(claudePath, "claude-skill", "SKILL.md"), []byte("# Claude"), 0644)
|
||||
os.MkdirAll(filepath.Join(codexPath, "codex-skill"), 0755)
|
||||
os.WriteFile(filepath.Join(codexPath, "codex-skill", "SKILL.md"), []byte("# Codex"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + claudePath + `
|
||||
codex:
|
||||
path: ` + codexPath + `
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("pull", "--all", "--dry-run")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "claude-skill")
|
||||
result.AssertOutputContains(t, "codex-skill")
|
||||
}
|
||||
|
||||
func TestPull_NoLocalSkills_ShowsMessage(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
sb.CreateSkill("shared-skill", map[string]string{"SKILL.md": "# Shared"})
|
||||
targetPath := sb.CreateTarget("claude")
|
||||
|
||||
// Create only symlinked skill (not local)
|
||||
os.Symlink(filepath.Join(sb.SourcePath, "shared-skill"), filepath.Join(targetPath, "shared-skill"))
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + targetPath + `
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("pull")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "No local skills")
|
||||
}
|
||||
|
||||
func TestPull_TargetNotFound_ReturnsError(t *testing.T) {
|
||||
func TestPull_NoGitRepo_ShowsError(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
@@ -119,114 +18,13 @@ func TestPull_TargetNotFound_ReturnsError(t *testing.T) {
|
||||
targets: {}
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("pull", "nonexistent")
|
||||
|
||||
result.AssertFailure(t)
|
||||
result.AssertAnyOutputContains(t, "not found")
|
||||
}
|
||||
|
||||
func TestPull_CopiesToSource(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
targetPath := sb.CreateTarget("claude")
|
||||
|
||||
// Create local skill
|
||||
localSkillPath := filepath.Join(targetPath, "new-skill")
|
||||
os.MkdirAll(localSkillPath, 0755)
|
||||
os.WriteFile(filepath.Join(localSkillPath, "SKILL.md"), []byte("# New Skill Content"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + targetPath + `
|
||||
`)
|
||||
|
||||
// Run with force to skip confirmation
|
||||
result := sb.RunCLIWithInput("y\n", "pull", "--force")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "copied to source")
|
||||
|
||||
// Verify skill was copied to source
|
||||
copiedSkillPath := filepath.Join(sb.SourcePath, "new-skill", "SKILL.md")
|
||||
if !sb.FileExists(copiedSkillPath) {
|
||||
t.Error("skill should be copied to source")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPull_ExistsInSource_Skips(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
// Create skill in source first
|
||||
sb.CreateSkill("existing-skill", map[string]string{"SKILL.md": "# Source Version"})
|
||||
|
||||
targetPath := sb.CreateTarget("claude")
|
||||
|
||||
// Create same skill in target (local copy)
|
||||
localSkillPath := filepath.Join(targetPath, "existing-skill")
|
||||
os.MkdirAll(localSkillPath, 0755)
|
||||
os.WriteFile(filepath.Join(localSkillPath, "SKILL.md"), []byte("# Target Version"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + targetPath + `
|
||||
`)
|
||||
|
||||
result := sb.RunCLIWithInput("y\n", "pull")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "skipped")
|
||||
}
|
||||
|
||||
func TestPull_MultipleTargets_RequiresAllOrName(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
claudePath := sb.CreateTarget("claude")
|
||||
codexPath := sb.CreateTarget("codex")
|
||||
|
||||
// Create local skills in both targets
|
||||
os.MkdirAll(filepath.Join(claudePath, "skill1"), 0755)
|
||||
os.WriteFile(filepath.Join(claudePath, "skill1", "SKILL.md"), []byte("# 1"), 0644)
|
||||
os.MkdirAll(filepath.Join(codexPath, "skill2"), 0755)
|
||||
os.WriteFile(filepath.Join(codexPath, "skill2", "SKILL.md"), []byte("# 2"), 0644)
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets:
|
||||
claude:
|
||||
path: ` + claudePath + `
|
||||
codex:
|
||||
path: ` + codexPath + `
|
||||
`)
|
||||
|
||||
// Without specifying target or --all
|
||||
result := sb.RunCLI("pull")
|
||||
|
||||
// Should ask to specify target
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "Specify a target")
|
||||
}
|
||||
|
||||
// Tests for --remote flag
|
||||
|
||||
func TestPull_Remote_NoGitRepo_ShowsError(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
sb.WriteConfig(`source: ` + sb.SourcePath + `
|
||||
targets: {}
|
||||
`)
|
||||
|
||||
result := sb.RunCLI("pull", "--remote")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "not a git repository")
|
||||
}
|
||||
|
||||
func TestPull_Remote_NoRemote_ShowsError(t *testing.T) {
|
||||
func TestPull_NoRemote_ShowsError(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
@@ -241,13 +39,13 @@ targets: {}
|
||||
t.Skip("git not available")
|
||||
}
|
||||
|
||||
result := sb.RunCLI("pull", "--remote")
|
||||
result := sb.RunCLI("pull")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "No git remote")
|
||||
}
|
||||
|
||||
func TestPull_Remote_UncommittedChanges_Refuses(t *testing.T) {
|
||||
func TestPull_UncommittedChanges_Refuses(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
@@ -289,13 +87,13 @@ targets: {}
|
||||
// Create uncommitted changes
|
||||
sb.CreateSkill("uncommitted-skill", map[string]string{"SKILL.md": "# Uncommitted"})
|
||||
|
||||
result := sb.RunCLI("pull", "--remote")
|
||||
result := sb.RunCLI("pull")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "Local changes detected")
|
||||
}
|
||||
|
||||
func TestPull_Remote_DryRun_ShowsActions(t *testing.T) {
|
||||
func TestPull_DryRun_ShowsActions(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
@@ -334,13 +132,13 @@ targets: {}
|
||||
cmd.Run()
|
||||
}
|
||||
|
||||
result := sb.RunCLI("pull", "--remote", "--dry-run")
|
||||
result := sb.RunCLI("pull", "--dry-run")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "dry-run")
|
||||
}
|
||||
|
||||
func TestPull_Remote_ActualPull_AndSyncs(t *testing.T) {
|
||||
func TestPull_ActualPull_AndSyncs(t *testing.T) {
|
||||
sb := testutil.NewSandbox(t)
|
||||
defer sb.Cleanup()
|
||||
|
||||
@@ -389,13 +187,13 @@ targets:
|
||||
cmd.Run()
|
||||
}
|
||||
|
||||
// Now run pull --remote (already up to date, but should sync)
|
||||
result := sb.RunCLI("pull", "--remote")
|
||||
// Now run pull (already up to date, but should sync)
|
||||
result := sb.RunCLI("pull")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
// Should sync to target
|
||||
if !sb.FileExists(filepath.Join(targetPath, "remote-skill", "SKILL.md")) {
|
||||
t.Error("skill should be synced to target after pull --remote")
|
||||
t.Error("skill should be synced to target after pull")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ targets: {}
|
||||
result := sb.RunCLI("push", "-m", "Test push")
|
||||
|
||||
result.AssertSuccess(t)
|
||||
result.AssertOutputContains(t, "Pushed to remote")
|
||||
result.AssertOutputContains(t, "Push complete")
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
|
||||
Reference in New Issue
Block a user