skill-linker 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +29 -5
  2. package/link-skill.sh +100 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -41,10 +41,12 @@ Usage: link-skill.sh [OPTIONS] [SKILL_PATH]
41
41
 
42
42
  Options:
43
43
  --from <github_url> 從 GitHub Clone Skill 後再連結
44
+ --list 列出已 Clone 的 Repos 並選擇 Skills
44
45
  --help 顯示說明
45
46
 
46
47
  Examples:
47
48
  ./link-skill.sh # 互動式選擇
49
+ ./link-skill.sh --list # 瀏覽已 Clone 的 Repos
48
50
  ./link-skill.sh /path/to/skill # 指定本地 Skill
49
51
  ./link-skill.sh --from https://github.com/user/my-skill
50
52
  ./link-skill.sh --from https://github.com/anthropics/skills/tree/main/skills/pdf
@@ -57,6 +59,22 @@ Examples:
57
59
  2. 列出所有可用的 Skills 讓您選擇
58
60
  3. 或者您可以直接在 URL 中指定子路徑(如 `/tree/main/skills/pdf`)
59
61
 
62
+ ### 📋 List Mode - 瀏覽已 Clone 的 Repos
63
+
64
+ 使用 `--list` 參數可以瀏覽 Skill Library 中已 clone 的所有 repos:
65
+
66
+ ```bash
67
+ npx skill-linker --list
68
+ ```
69
+
70
+ 操作流程:
71
+ 1. 顯示所有已 clone 的 repos(以 `owner/repo` 格式)
72
+ 2. 選擇要使用的 repo
73
+ 3. 如果該 repo 包含多個 skills,會列出讓您選擇
74
+ 4. 選擇後繼續正常的 Agent 安裝流程
75
+
76
+ 這對於管理多個已下載的 skill repos 特別有用!
77
+
60
78
  ## 📦 推薦的 Public Skill Repos
61
79
 
62
80
  | Repo | 說明 |
@@ -74,13 +92,19 @@ npx skill-linker --from https://github.com/obra/superpowers
74
92
 
75
93
  ## 📂 Skill Library
76
94
 
77
- 建議將您的 Public Skills 統一存放在 `~/Documents/AgentSkills`:
95
+ 使用 `--from` 參數時,Skills 會自動存放到 `~/Documents/AgentSkills`,並以 **owner/repo** 結構分層:
78
96
 
79
- ```bash
80
- mkdir -p ~/Documents/AgentSkills
81
- cd ~/Documents/AgentSkills
82
- git clone https://github.com/anthropics/skills.git
83
97
  ```
98
+ ~/Documents/AgentSkills/
99
+ ├── anthropics/
100
+ │ └── skills/ # https://github.com/anthropics/skills
101
+ ├── obra/
102
+ │ └── superpowers/ # https://github.com/obra/superpowers
103
+ └── your-org/
104
+ └── your-skill/ # https://github.com/your-org/your-skill
105
+ ```
106
+
107
+ 這種命名空間結構可避免不同帳號擁有相同 repo 名稱時的衝突。
84
108
 
85
109
  腳本會自動偵測此目錄並列出可用的 Skills。
86
110
 
package/link-skill.sh CHANGED
@@ -5,6 +5,7 @@
5
5
  DEFAULT_LIB_PATH="$HOME/Documents/AgentSkills"
6
6
  SKILL_PATH=""
7
7
  FROM_URL=""
8
+ LIST_MODE=false
8
9
 
9
10
  # Helper function for colored output
10
11
  print_info() { echo -e "\033[1;34m[INFO]\033[0m $1"; }
@@ -18,6 +19,7 @@ show_help() {
18
19
  echo ""
19
20
  echo "Options:"
20
21
  echo " --from <github_url> Clone skill from GitHub URL first, then link"
22
+ echo " --list List cloned repos and select skills to link"
21
23
  echo " --help Show this help message"
22
24
  echo ""
23
25
  echo "Examples:"
@@ -33,6 +35,79 @@ show_help() {
33
35
  exit 0
34
36
  }
35
37
 
38
+ # List repos function
39
+ list_repos() {
40
+ if [ ! -d "$DEFAULT_LIB_PATH" ]; then
41
+ print_error "Skill Library not found: $DEFAULT_LIB_PATH"
42
+ print_info "Use --from <github_url> to clone skills first."
43
+ exit 1
44
+ fi
45
+
46
+ # Find all repos (owner/repo structure)
47
+ repos=()
48
+ repo_paths=()
49
+ for owner_dir in "$DEFAULT_LIB_PATH"/*/; do
50
+ [ -d "$owner_dir" ] || continue
51
+ owner=$(basename "$owner_dir")
52
+ for repo_dir in "$owner_dir"*/; do
53
+ [ -d "$repo_dir" ] || continue
54
+ repo=$(basename "$repo_dir")
55
+ repos+=("$owner/$repo")
56
+ repo_paths+=("$repo_dir")
57
+ done
58
+ done
59
+
60
+ if [ ${#repos[@]} -eq 0 ]; then
61
+ print_warning "No repos found in $DEFAULT_LIB_PATH"
62
+ print_info "Use --from <github_url> to clone skills first."
63
+ exit 0
64
+ fi
65
+
66
+ echo ""
67
+ print_info "Cloned Repos in Skill Library:"
68
+ echo ""
69
+ select repo_name in "${repos[@]}"; do
70
+ if [ -n "$repo_name" ]; then
71
+ idx=$((REPLY - 1))
72
+ selected_repo_path="${repo_paths[$idx]}"
73
+ break
74
+ else
75
+ echo "Invalid selection. Please try again."
76
+ fi
77
+ done
78
+
79
+ # Check for skills/ subdirectory
80
+ SKILLS_DIR="${selected_repo_path}skills"
81
+ if [ -d "$SKILLS_DIR" ]; then
82
+ print_info "Skills in $repo_name:"
83
+ sub_skills=("$SKILLS_DIR"/*/)
84
+ if [ ${#sub_skills[@]} -gt 0 ]; then
85
+ sub_skill_names=()
86
+ for s in "${sub_skills[@]}"; do
87
+ [ -d "$s" ] && sub_skill_names+=("$(basename "$s")")
88
+ done
89
+
90
+ echo ""
91
+ select sub_skill_name in "${sub_skill_names[@]}" "Link entire repo"; do
92
+ if [ -n "$sub_skill_name" ]; then
93
+ if [ "$sub_skill_name" == "Link entire repo" ]; then
94
+ SKILL_PATH="${selected_repo_path%/}"
95
+ else
96
+ SKILL_PATH="$SKILLS_DIR/$sub_skill_name"
97
+ fi
98
+ break
99
+ else
100
+ echo "Invalid selection. Please try again."
101
+ fi
102
+ done
103
+ else
104
+ SKILL_PATH="${selected_repo_path%/}"
105
+ fi
106
+ else
107
+ SKILL_PATH="${selected_repo_path%/}"
108
+ fi
109
+ }
110
+
36
111
  # Parse arguments
37
112
  while [[ $# -gt 0 ]]; do
38
113
  case $1 in
@@ -40,6 +115,10 @@ while [[ $# -gt 0 ]]; do
40
115
  FROM_URL="$2"
41
116
  shift 2
42
117
  ;;
118
+ --list|-l)
119
+ LIST_MODE=true
120
+ shift
121
+ ;;
43
122
  --help|-h)
44
123
  show_help
45
124
  ;;
@@ -50,6 +129,11 @@ while [[ $# -gt 0 ]]; do
50
129
  esac
51
130
  done
52
131
 
132
+ # Handle --list mode
133
+ if [ "$LIST_MODE" = true ]; then
134
+ list_repos
135
+ fi
136
+
53
137
  # 1. Handle --from flag: Clone from GitHub
54
138
  if [ -n "$FROM_URL" ]; then
55
139
  # Parse GitHub URL - check for /tree/branch/path format
@@ -65,9 +149,22 @@ if [ -n "$FROM_URL" ]; then
65
149
  print_info "Detected subpath: $SUBPATH (branch: $BRANCH)"
66
150
  fi
67
151
 
68
- # Extract repo name from URL
69
- REPO_NAME=$(basename "$CLEAN_URL" .git)
70
- TARGET_CLONE_PATH="$DEFAULT_LIB_PATH/$REPO_NAME"
152
+ # Extract owner/repo from URL for namespaced storage
153
+ # Supports: https://github.com/owner/repo or https://github.com/owner/repo.git
154
+ if [[ "$CLEAN_URL" =~ github\.com[/:]([^/]+)/([^/]+)(\.git)?$ ]]; then
155
+ REPO_OWNER="${BASH_REMATCH[1]}"
156
+ REPO_NAME="${BASH_REMATCH[2]%.git}"
157
+ else
158
+ # Fallback: just use basename
159
+ REPO_OWNER=""
160
+ REPO_NAME=$(basename "$CLEAN_URL" .git)
161
+ fi
162
+
163
+ if [ -n "$REPO_OWNER" ]; then
164
+ TARGET_CLONE_PATH="$DEFAULT_LIB_PATH/$REPO_OWNER/$REPO_NAME"
165
+ else
166
+ TARGET_CLONE_PATH="$DEFAULT_LIB_PATH/$REPO_NAME"
167
+ fi
71
168
 
72
169
  # Ensure library directory exists
73
170
  mkdir -p "$DEFAULT_LIB_PATH"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skill-linker",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "Interactive CLI to link AI Agent Skills to various agents (Claude, Copilot, Antigravity, Cursor, etc.)",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {