@workingpayload/agent-skills 1.0.1 → 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.
- package/APIForge/skill.md +165 -0
- package/AccessPlus/skill.md +136 -0
- package/AlgoMaster/skill.md +125 -0
- package/Architekt AI/skill.md +140 -0
- package/AuthCraft/skill.md +144 -0
- package/AutoScriptor/skill.md +137 -0
- package/BoilerCore/skill.md +136 -0
- package/BugHunter Pro/skill.md +133 -0
- package/ChangeScribe/skill.md +113 -0
- package/CodeSage/skill.md +163 -0
- package/CommitCraft/skill.md +113 -0
- package/CoverageMax/skill.md +161 -0
- package/CronGenius/skill.md +157 -0
- package/DataPolish/skill.md +142 -0
- package/DataWeaver/skill.md +151 -0
- package/DockMaster/skill.md +158 -0
- package/DocuGenie/skill.md +138 -0
- package/EdgeGuard/skill.md +160 -0
- package/EnvWizard/skill.md +156 -0
- package/ErrorMedic/skill.md +152 -0
- package/FeatureSmith/skill.md +139 -0
- package/FlexiLayout/skill.md +144 -0
- package/FlowTester/skill.md +154 -0
- package/FunctionForge/skill.md +136 -0
- package/InputShield/skill.md +144 -0
- package/IssueForge/skill.md +148 -0
- package/KubeCrafter/skill.md +149 -0
- package/LogicLens/skill.md +132 -0
- package/MockSmith/skill.md +146 -0
- package/ModelSensei/skill.md +138 -0
- package/PRMentor/skill.md +103 -0
- package/PerfDetective/skill.md +90 -0
- package/PipelinePro/skill.md +146 -0
- package/PolyglotShift/skill.md +94 -0
- package/PromptForge/skill.md +118 -0
- package/QueryPulse/skill.md +123 -0
- package/README.md +416 -329
- package/ReadMeCraft/skill.md +127 -0
- package/RefactorX/skill.md +84 -0
- package/RenderBoost/skill.md +148 -0
- package/SEOMancer/skill.md +156 -0
- package/ScrapeMaster/skill.md +157 -0
- package/SecretSniffer/skill.md +123 -0
- package/SecureScan/skill.md +130 -0
- package/ServiceSplitter/skill.md +153 -0
- package/SpeedSmith/skill.md +155 -0
- package/StackWise/skill.md +155 -0
- package/TaskOrchestrator/skill.md +135 -0
- package/TestCrafter/skill.md +158 -0
- package/TraceMind/skill.md +143 -0
- package/UISmith/skill.md +131 -0
- package/bin/cli.js +377 -0
- package/extension-extender/SKILL.md +122 -0
- package/fastapi-furious/SKILL.md +148 -0
- package/package.json +41 -32
- package/python-master/SKILL.md +108 -0
- package/react-ranger/SKILL.md +93 -0
- package/scripts/build_index.py +282 -0
- package/scripts/doctor.py +541 -0
- package/scripts/install.py +397 -0
- package/scripts/route.py +348 -0
- package/scripts/score.py +355 -0
- package/scripts/test_skill.py +473 -0
- package/scripts/validate.py +254 -0
- package/skills-routing.json +1131 -0
- package/skills.json +3261 -0
- package/cli.js +0 -181
- package/skills/APIForge/skill.md +0 -32
- package/skills/AccessPlus/skill.md +0 -32
- package/skills/AlgoMaster/skill.md +0 -32
- package/skills/Architekt AI/skill.md +0 -32
- package/skills/AuthCraft/skill.md +0 -32
- package/skills/AutoScriptor/skill.md +0 -32
- package/skills/BoilerCore/skill.md +0 -32
- package/skills/BugHunter Pro/skill.md +0 -32
- package/skills/ChangeScribe/skill.md +0 -32
- package/skills/CodeSage/skill.md +0 -32
- package/skills/CommitCraft/skill.md +0 -32
- package/skills/CoverageMax/skill.md +0 -32
- package/skills/CronGenius/skill.md +0 -32
- package/skills/DataPolish/skill.md +0 -32
- package/skills/DataWeaver/skill.md +0 -32
- package/skills/DockMaster/skill.md +0 -32
- package/skills/DocuGenie/skill.md +0 -32
- package/skills/EdgeGuard/skill.md +0 -32
- package/skills/EnvWizard/skill.md +0 -32
- package/skills/ErrorMedic/skill.md +0 -32
- package/skills/Extension-Extender/SKILL.md +0 -41
- package/skills/Extension-Extender/references/ui-guidelines.md +0 -26
- package/skills/Fastapi-Furious/README.md +0 -16
- package/skills/Fastapi-Furious/SKILL.md +0 -37
- package/skills/FeatureSmith/skill.md +0 -32
- package/skills/FlexiLayout/skill.md +0 -32
- package/skills/FlowTester/skill.md +0 -32
- package/skills/FunctionForge/skill.md +0 -32
- package/skills/InputShield/skill.md +0 -32
- package/skills/IssueForge/skill.md +0 -32
- package/skills/KubeCrafter/skill.md +0 -32
- package/skills/LogicLens/skill.md +0 -32
- package/skills/MockSmith/skill.md +0 -32
- package/skills/ModelSensei/skill.md +0 -32
- package/skills/PRMentor/skill.md +0 -32
- package/skills/PerfDetective/skill.md +0 -32
- package/skills/PipelinePro/skill.md +0 -32
- package/skills/PolyglotShift/skill.md +0 -32
- package/skills/PromptForge/skill.md +0 -32
- package/skills/Python-Master/README.md +0 -11
- package/skills/Python-Master/SKILL.md +0 -37
- package/skills/QueryPulse/skill.md +0 -32
- package/skills/React-Ranger/README.md +0 -17
- package/skills/React-Ranger/SKILL.md +0 -37
- package/skills/ReadMeCraft/skill.md +0 -32
- package/skills/RefactorX/skill.md +0 -32
- package/skills/RenderBoost/skill.md +0 -32
- package/skills/SEOMancer/skill.md +0 -32
- package/skills/ScrapeMaster/skill.md +0 -32
- package/skills/SecretSniffer/skill.md +0 -32
- package/skills/SecureScan/skill.md +0 -32
- package/skills/ServiceSplitter/skill.md +0 -32
- package/skills/SpeedSmith/skill.md +0 -32
- package/skills/StackWise/skill.md +0 -32
- package/skills/TaskOrchestrator/skill.md +0 -32
- package/skills/TestCrafter/skill.md +0 -32
- package/skills/TraceMind/skill.md +0 -32
- package/skills/UISmith/skill.md +0 -32
- /package/{skills/Extension-Extender → extension-extender}/assets/manifest.json +0 -0
- /package/{skills/Extension-Extender → extension-extender}/assets/popup.css +0 -0
- /package/{skills/Extension-Extender → extension-extender}/assets/popup.html +0 -0
- /package/{skills/Extension-Extender → extension-extender}/assets/popup.js +0 -0
package/scripts/route.py
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
route.py — Skill router for Agent-Skills repository.
|
|
4
|
+
|
|
5
|
+
Routes a user prompt to the best-matching skill using TF-IDF-like keyword
|
|
6
|
+
matching against skills-routing.json. No external dependencies required.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
python scripts/route.py "review my code"
|
|
10
|
+
python scripts/route.py "fix my Docker build" --top-n 5
|
|
11
|
+
python scripts/route.py "write unit tests" --json
|
|
12
|
+
python scripts/route.py --interactive
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import json
|
|
17
|
+
import os
|
|
18
|
+
import re
|
|
19
|
+
import sys
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from typing import Any
|
|
22
|
+
|
|
23
|
+
# ---------------------------------------------------------------------------
|
|
24
|
+
# Stop words — common English words that carry no signal for skill matching
|
|
25
|
+
# ---------------------------------------------------------------------------
|
|
26
|
+
STOP_WORDS = frozenset(
|
|
27
|
+
[
|
|
28
|
+
"a", "an", "the", "and", "or", "but", "in", "on", "at", "to", "for",
|
|
29
|
+
"of", "with", "by", "from", "is", "are", "was", "were", "be", "been",
|
|
30
|
+
"being", "have", "has", "had", "do", "does", "did", "will", "would",
|
|
31
|
+
"could", "should", "may", "might", "must", "shall", "can", "need",
|
|
32
|
+
"i", "me", "my", "we", "our", "you", "your", "it", "its", "they",
|
|
33
|
+
"them", "their", "this", "that", "these", "those", "what", "which",
|
|
34
|
+
"who", "how", "when", "where", "why", "not", "no", "so", "if",
|
|
35
|
+
"then", "than", "as", "up", "out", "about", "into", "through",
|
|
36
|
+
"help", "please", "want", "need", "like", "just", "some", "any",
|
|
37
|
+
"all", "new", "get", "make", "use", "using", "used",
|
|
38
|
+
]
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Minimum score to consider a match meaningful
|
|
42
|
+
SCORE_THRESHOLD = 1.0
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def tokenize(text: str) -> list[str]:
|
|
46
|
+
"""
|
|
47
|
+
Lowercase the text, split on non-alphanumeric characters (preserving
|
|
48
|
+
hyphens within words), and remove stop words.
|
|
49
|
+
"""
|
|
50
|
+
# Replace hyphens surrounded by word chars with a placeholder so
|
|
51
|
+
# "big-o" stays as one token, then split on remaining punctuation.
|
|
52
|
+
tokens = re.findall(r"[a-z0-9]+(?:-[a-z0-9]+)*", text.lower())
|
|
53
|
+
return [t for t in tokens if t not in STOP_WORDS]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def find_index(index_path: str | None) -> Path:
|
|
57
|
+
"""Locate skills-routing.json, falling back to the repo root."""
|
|
58
|
+
if index_path:
|
|
59
|
+
p = Path(index_path)
|
|
60
|
+
if not p.exists():
|
|
61
|
+
sys.exit(f"Error: index file not found: {index_path}")
|
|
62
|
+
return p
|
|
63
|
+
|
|
64
|
+
# Walk up from this script's location to find the repo root
|
|
65
|
+
here = Path(__file__).resolve().parent
|
|
66
|
+
candidates = [
|
|
67
|
+
here / "skills-routing.json",
|
|
68
|
+
here.parent / "skills-routing.json",
|
|
69
|
+
]
|
|
70
|
+
for c in candidates:
|
|
71
|
+
if c.exists():
|
|
72
|
+
return c
|
|
73
|
+
|
|
74
|
+
sys.exit(
|
|
75
|
+
"Error: could not find skills-routing.json. "
|
|
76
|
+
"Pass --index <path> to specify its location."
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def load_index(path: Path) -> list[dict[str, Any]]:
|
|
81
|
+
"""Load and return the list of skill entries from the index file."""
|
|
82
|
+
with open(path, encoding="utf-8") as fh:
|
|
83
|
+
data = json.load(fh)
|
|
84
|
+
skills = data.get("skills")
|
|
85
|
+
if not isinstance(skills, list):
|
|
86
|
+
sys.exit("Error: skills-routing.json must contain a top-level 'skills' list.")
|
|
87
|
+
return skills
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def score_skill(
|
|
91
|
+
prompt_tokens: list[str], skill: dict[str, Any]
|
|
92
|
+
) -> tuple[float, list[str]]:
|
|
93
|
+
"""
|
|
94
|
+
Compute a relevance score for one skill given the prompt tokens.
|
|
95
|
+
|
|
96
|
+
Weights:
|
|
97
|
+
trigger match → 4x per token
|
|
98
|
+
name match → 3x per token
|
|
99
|
+
category match → 2x per token
|
|
100
|
+
description match (exact word) → 2x per token
|
|
101
|
+
description match (substring) → 1x per token
|
|
102
|
+
|
|
103
|
+
Returns (score, matched_keywords).
|
|
104
|
+
"""
|
|
105
|
+
name: str = skill.get("name", "")
|
|
106
|
+
description: str = skill.get("description", "")
|
|
107
|
+
categories: list[str] = skill.get("categories", [])
|
|
108
|
+
triggers: list[str] = skill.get("triggers", [])
|
|
109
|
+
|
|
110
|
+
name_tokens = set(tokenize(name))
|
|
111
|
+
desc_tokens = set(tokenize(description))
|
|
112
|
+
# Flatten categories into a single token set
|
|
113
|
+
cat_tokens: set[str] = set()
|
|
114
|
+
for cat in categories:
|
|
115
|
+
cat_tokens.update(tokenize(cat))
|
|
116
|
+
trigger_tokens = set(triggers) # triggers are already lowercase words
|
|
117
|
+
|
|
118
|
+
desc_lower = description.lower()
|
|
119
|
+
|
|
120
|
+
score = 0.0
|
|
121
|
+
matched: list[str] = []
|
|
122
|
+
|
|
123
|
+
for token in set(prompt_tokens): # deduplicate prompt tokens for scoring
|
|
124
|
+
hit = False
|
|
125
|
+
|
|
126
|
+
# Trigger match (4x)
|
|
127
|
+
if token in trigger_tokens:
|
|
128
|
+
score += 4.0
|
|
129
|
+
matched.append(f"{token} (trigger)")
|
|
130
|
+
hit = True
|
|
131
|
+
|
|
132
|
+
# Name match (3x)
|
|
133
|
+
if token in name_tokens:
|
|
134
|
+
score += 3.0
|
|
135
|
+
if not hit:
|
|
136
|
+
matched.append(f"{token} (name)")
|
|
137
|
+
hit = True
|
|
138
|
+
|
|
139
|
+
# Category match (2x)
|
|
140
|
+
if token in cat_tokens:
|
|
141
|
+
score += 2.0
|
|
142
|
+
if not hit:
|
|
143
|
+
matched.append(f"{token} (category)")
|
|
144
|
+
hit = True
|
|
145
|
+
|
|
146
|
+
# Description exact-word match (2x)
|
|
147
|
+
if token in desc_tokens:
|
|
148
|
+
score += 2.0
|
|
149
|
+
if not hit:
|
|
150
|
+
matched.append(f"{token} (description)")
|
|
151
|
+
hit = True
|
|
152
|
+
|
|
153
|
+
# Description substring match (1x) — only if not already matched above
|
|
154
|
+
if not hit and token in desc_lower:
|
|
155
|
+
score += 1.0
|
|
156
|
+
matched.append(f"{token} (partial)")
|
|
157
|
+
|
|
158
|
+
return score, matched
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def route(
|
|
162
|
+
prompt: str,
|
|
163
|
+
skills: list[dict[str, Any]],
|
|
164
|
+
top_n: int,
|
|
165
|
+
) -> list[dict[str, Any]]:
|
|
166
|
+
"""
|
|
167
|
+
Score every skill against the prompt and return top-N results,
|
|
168
|
+
sorted by descending score.
|
|
169
|
+
|
|
170
|
+
Each result dict has keys: rank, name, score, matched_keywords.
|
|
171
|
+
"""
|
|
172
|
+
prompt_tokens = tokenize(prompt)
|
|
173
|
+
|
|
174
|
+
if not prompt_tokens:
|
|
175
|
+
return []
|
|
176
|
+
|
|
177
|
+
scored: list[tuple[float, list[str], dict[str, Any]]] = []
|
|
178
|
+
for skill in skills:
|
|
179
|
+
score, matched = score_skill(prompt_tokens, skill)
|
|
180
|
+
if score > 0:
|
|
181
|
+
scored.append((score, matched, skill))
|
|
182
|
+
|
|
183
|
+
scored.sort(key=lambda x: x[0], reverse=True)
|
|
184
|
+
|
|
185
|
+
results = []
|
|
186
|
+
for rank, (score, matched, skill) in enumerate(scored[:top_n], start=1):
|
|
187
|
+
results.append(
|
|
188
|
+
{
|
|
189
|
+
"rank": rank,
|
|
190
|
+
"name": skill.get("name", ""),
|
|
191
|
+
"score": round(score, 2),
|
|
192
|
+
"matched_keywords": matched,
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
return results
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def format_text(results: list[dict[str, Any]], prompt: str) -> str:
|
|
199
|
+
"""Render results as a human-readable ranked list."""
|
|
200
|
+
lines: list[str] = []
|
|
201
|
+
|
|
202
|
+
if not results:
|
|
203
|
+
lines.append(
|
|
204
|
+
"No matching skill found for your prompt.\n"
|
|
205
|
+
"Try describing your task more specifically — for example:\n"
|
|
206
|
+
' • "review my Python code for security issues"\n'
|
|
207
|
+
' • "write unit tests for my REST API"\n'
|
|
208
|
+
' • "fix a Docker build error"'
|
|
209
|
+
)
|
|
210
|
+
return "\n".join(lines)
|
|
211
|
+
|
|
212
|
+
top_score = results[0]["score"]
|
|
213
|
+
if top_score < SCORE_THRESHOLD:
|
|
214
|
+
lines.append(
|
|
215
|
+
f"No confident match found (best score: {top_score}). "
|
|
216
|
+
"Try describing your task differently, e.g.:\n"
|
|
217
|
+
' • "write unit tests" → testcrafter\n'
|
|
218
|
+
' • "review my code" → codesage\n'
|
|
219
|
+
' • "fix a Docker build" → dockmaster'
|
|
220
|
+
)
|
|
221
|
+
return "\n".join(lines)
|
|
222
|
+
|
|
223
|
+
lines.append(f'Routing: "{prompt}"\n')
|
|
224
|
+
lines.append(f"{'Rank':<5} {'Skill':<25} {'Score':<8} Why it matched")
|
|
225
|
+
lines.append("-" * 72)
|
|
226
|
+
for r in results:
|
|
227
|
+
keywords = ", ".join(r["matched_keywords"]) if r["matched_keywords"] else "—"
|
|
228
|
+
lines.append(
|
|
229
|
+
f"{r['rank']:<5} {r['name']:<25} {r['score']:<8.2f} {keywords}"
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
return "\n".join(lines)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def format_json(results: list[dict[str, Any]], prompt: str) -> str:
|
|
236
|
+
"""Render results as JSON."""
|
|
237
|
+
payload = {
|
|
238
|
+
"prompt": prompt,
|
|
239
|
+
"results": results,
|
|
240
|
+
"no_match": not results or results[0]["score"] < SCORE_THRESHOLD,
|
|
241
|
+
}
|
|
242
|
+
return json.dumps(payload, indent=2)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def run_once(
|
|
246
|
+
prompt: str,
|
|
247
|
+
skills: list[dict[str, Any]],
|
|
248
|
+
top_n: int,
|
|
249
|
+
as_json: bool,
|
|
250
|
+
) -> None:
|
|
251
|
+
results = route(prompt, skills, top_n)
|
|
252
|
+
if as_json:
|
|
253
|
+
print(format_json(results, prompt))
|
|
254
|
+
else:
|
|
255
|
+
print(format_text(results, prompt))
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def interactive_loop(
|
|
259
|
+
skills: list[dict[str, Any]],
|
|
260
|
+
top_n: int,
|
|
261
|
+
as_json: bool,
|
|
262
|
+
) -> None:
|
|
263
|
+
print("Agent-Skills Router — interactive mode (Ctrl-C or 'quit' to exit)\n")
|
|
264
|
+
while True:
|
|
265
|
+
try:
|
|
266
|
+
prompt = input("prompt> ").strip()
|
|
267
|
+
except (KeyboardInterrupt, EOFError):
|
|
268
|
+
print()
|
|
269
|
+
break
|
|
270
|
+
|
|
271
|
+
if prompt.lower() in {"quit", "exit", "q"}:
|
|
272
|
+
break
|
|
273
|
+
if not prompt:
|
|
274
|
+
continue
|
|
275
|
+
|
|
276
|
+
run_once(prompt, skills, top_n, as_json)
|
|
277
|
+
print()
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
281
|
+
parser = argparse.ArgumentParser(
|
|
282
|
+
prog="route.py",
|
|
283
|
+
description="Route a user prompt to the best-matching Agent-Skills skill.",
|
|
284
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
285
|
+
epilog="""
|
|
286
|
+
Examples:
|
|
287
|
+
python scripts/route.py "review my code"
|
|
288
|
+
python scripts/route.py "fix my Docker build" --top-n 5
|
|
289
|
+
python scripts/route.py "write unit tests" --json
|
|
290
|
+
python scripts/route.py "design a REST API" -n 3
|
|
291
|
+
python scripts/route.py --interactive
|
|
292
|
+
""",
|
|
293
|
+
)
|
|
294
|
+
parser.add_argument(
|
|
295
|
+
"prompt",
|
|
296
|
+
nargs="?",
|
|
297
|
+
default=None,
|
|
298
|
+
help="The user prompt/query to route (omit when using --interactive).",
|
|
299
|
+
)
|
|
300
|
+
parser.add_argument(
|
|
301
|
+
"--top-n", "-n",
|
|
302
|
+
type=int,
|
|
303
|
+
default=3,
|
|
304
|
+
dest="top_n",
|
|
305
|
+
metavar="N",
|
|
306
|
+
help="Number of top results to display (default: 3).",
|
|
307
|
+
)
|
|
308
|
+
parser.add_argument(
|
|
309
|
+
"--json",
|
|
310
|
+
action="store_true",
|
|
311
|
+
dest="as_json",
|
|
312
|
+
help="Output results as JSON.",
|
|
313
|
+
)
|
|
314
|
+
parser.add_argument(
|
|
315
|
+
"--index",
|
|
316
|
+
default=None,
|
|
317
|
+
metavar="PATH",
|
|
318
|
+
help="Path to skills-routing.json (default: auto-detect from repo root).",
|
|
319
|
+
)
|
|
320
|
+
parser.add_argument(
|
|
321
|
+
"--interactive",
|
|
322
|
+
action="store_true",
|
|
323
|
+
help="Start an interactive prompt loop.",
|
|
324
|
+
)
|
|
325
|
+
return parser
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def main() -> None:
|
|
329
|
+
parser = build_parser()
|
|
330
|
+
args = parser.parse_args()
|
|
331
|
+
|
|
332
|
+
if not args.interactive and args.prompt is None:
|
|
333
|
+
parser.error("A prompt argument is required unless --interactive is used.")
|
|
334
|
+
|
|
335
|
+
index_path = find_index(args.index)
|
|
336
|
+
skills = load_index(index_path)
|
|
337
|
+
|
|
338
|
+
if args.top_n < 1:
|
|
339
|
+
parser.error("--top-n must be at least 1.")
|
|
340
|
+
|
|
341
|
+
if args.interactive:
|
|
342
|
+
interactive_loop(skills, args.top_n, args.as_json)
|
|
343
|
+
else:
|
|
344
|
+
run_once(args.prompt, skills, args.top_n, args.as_json)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
if __name__ == "__main__":
|
|
348
|
+
main()
|
package/scripts/score.py
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"""
|
|
2
|
+
score.py - Auto-scores all skill files in the Agent-Skills repo.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
python scripts/score.py # Human-readable output
|
|
6
|
+
python scripts/score.py --json # JSON output
|
|
7
|
+
|
|
8
|
+
Criteria (each 0-5):
|
|
9
|
+
1. Tool Coverage - named tools/commands in backticks
|
|
10
|
+
2. Code Examples - fenced code blocks
|
|
11
|
+
3. Edge Cases - items in edge-case sections
|
|
12
|
+
4. Actionability - numbered/ordered workflow steps
|
|
13
|
+
5. Structure - presence of key sections
|
|
14
|
+
6. Conciseness - total line count
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import json
|
|
21
|
+
import re
|
|
22
|
+
import sys
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# ---------------------------------------------------------------------------
|
|
27
|
+
# Helpers
|
|
28
|
+
# ---------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
def find_skill_files(repo_root: Path) -> list[Path]:
|
|
31
|
+
"""Return all skill.md / SKILL.md files under repo_root."""
|
|
32
|
+
files: list[Path] = []
|
|
33
|
+
for p in sorted(repo_root.iterdir()):
|
|
34
|
+
if not p.is_dir():
|
|
35
|
+
continue
|
|
36
|
+
# skip hidden dirs and the scripts dir itself
|
|
37
|
+
if p.name.startswith(".") or p.name == "scripts":
|
|
38
|
+
continue
|
|
39
|
+
for name in ("skill.md", "SKILL.md"):
|
|
40
|
+
candidate = p / name
|
|
41
|
+
if candidate.exists():
|
|
42
|
+
files.append(candidate)
|
|
43
|
+
break
|
|
44
|
+
return files
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# ---------------------------------------------------------------------------
|
|
48
|
+
# Scoring functions
|
|
49
|
+
# ---------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
def score_tool_coverage(text: str) -> int:
|
|
52
|
+
"""Count distinct backtick-delimited tokens that look like tool/command names."""
|
|
53
|
+
# Match inline code spans: `something`
|
|
54
|
+
# Exclude purely numeric tokens, plain words with spaces (prose), or very long strings
|
|
55
|
+
raw = re.findall(r"`([^`\n]{1,80})`", text)
|
|
56
|
+
tools: set[str] = set()
|
|
57
|
+
for item in raw:
|
|
58
|
+
item = item.strip()
|
|
59
|
+
# Keep items that look like commands, flags, functions, or identifiers
|
|
60
|
+
# Exclude JSON keys/values (contain quotes or colons with spaces)
|
|
61
|
+
if re.search(r'[a-zA-Z]', item) and not re.search(r'^\s*["\'{]', item):
|
|
62
|
+
tools.add(item)
|
|
63
|
+
count = len(tools)
|
|
64
|
+
if count == 0:
|
|
65
|
+
return 0
|
|
66
|
+
elif count <= 2:
|
|
67
|
+
return 1
|
|
68
|
+
elif count <= 5:
|
|
69
|
+
return 2
|
|
70
|
+
elif count <= 10:
|
|
71
|
+
return 3
|
|
72
|
+
elif count <= 15:
|
|
73
|
+
return 4
|
|
74
|
+
else:
|
|
75
|
+
return 5
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def score_code_examples(text: str) -> int:
|
|
79
|
+
"""Count fenced code blocks (``` ... ```)."""
|
|
80
|
+
# Match opening fences with optional language tag
|
|
81
|
+
count = len(re.findall(r"^```", text, re.MULTILINE))
|
|
82
|
+
# Each block uses two fences; divide to get block count
|
|
83
|
+
blocks = count // 2
|
|
84
|
+
return min(blocks, 5)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _edge_case_section(text: str) -> str:
|
|
88
|
+
"""Extract text of edge-case section(s), or empty string if none."""
|
|
89
|
+
# Match sections whose heading contains 'edge case' (case-insensitive)
|
|
90
|
+
pattern = re.compile(
|
|
91
|
+
r"^#{1,4}\s+[^\n]*edge\s+case[s]?[^\n]*\n(.*?)(?=^#{1,4}\s|\Z)",
|
|
92
|
+
re.IGNORECASE | re.MULTILINE | re.DOTALL,
|
|
93
|
+
)
|
|
94
|
+
matches = pattern.findall(text)
|
|
95
|
+
return "\n".join(matches)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def score_edge_cases(text: str) -> int:
|
|
99
|
+
"""Score based on edge-case section depth and quality."""
|
|
100
|
+
section = _edge_case_section(text)
|
|
101
|
+
if not section:
|
|
102
|
+
return 0
|
|
103
|
+
|
|
104
|
+
# Count list items (bullet or numbered)
|
|
105
|
+
items = re.findall(r"^\s*[-*+\d]+[.)]\s+\S", section, re.MULTILINE)
|
|
106
|
+
base_count = len(items)
|
|
107
|
+
|
|
108
|
+
if base_count == 0:
|
|
109
|
+
base = 0
|
|
110
|
+
elif base_count == 1:
|
|
111
|
+
base = 1
|
|
112
|
+
elif base_count == 2:
|
|
113
|
+
base = 2
|
|
114
|
+
else:
|
|
115
|
+
base = 3
|
|
116
|
+
|
|
117
|
+
bonus = 0
|
|
118
|
+
# Bonus: edge-case section contains a code example
|
|
119
|
+
if re.search(r"```", section):
|
|
120
|
+
bonus += 1
|
|
121
|
+
# Bonus: names specific failure modes (error, fail, exception, timeout, invalid, corrupt, overflow, race)
|
|
122
|
+
if re.search(
|
|
123
|
+
r"\b(error|fail|exception|timeout|invalid|corrupt|overflow|race\s+condition|deadlock|nil|null|empty|missing)\b",
|
|
124
|
+
section,
|
|
125
|
+
re.IGNORECASE,
|
|
126
|
+
):
|
|
127
|
+
bonus += 1
|
|
128
|
+
|
|
129
|
+
return min(base + bonus, 5)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def score_actionability(text: str) -> int:
|
|
133
|
+
"""Count numbered/ordered workflow steps."""
|
|
134
|
+
# Match lines like '1.', '2)', '### 1.', '**1.**' etc.
|
|
135
|
+
# We look for explicit numbered list items at any indent level
|
|
136
|
+
steps = re.findall(r"^\s*(?:#{1,4}\s+)?\d+[.)]\s+\S", text, re.MULTILINE)
|
|
137
|
+
count = len(steps)
|
|
138
|
+
if count == 0:
|
|
139
|
+
return 0
|
|
140
|
+
elif count <= 2:
|
|
141
|
+
return 1
|
|
142
|
+
elif count <= 5:
|
|
143
|
+
return 2
|
|
144
|
+
elif count <= 8:
|
|
145
|
+
return 3
|
|
146
|
+
elif count <= 12:
|
|
147
|
+
return 4
|
|
148
|
+
else:
|
|
149
|
+
return 5
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def score_structure(text: str) -> int:
|
|
153
|
+
"""Score based on presence of key structural elements."""
|
|
154
|
+
score = 0
|
|
155
|
+
# Frontmatter: YAML block at top
|
|
156
|
+
if re.match(r"^\s*---\s*\n", text):
|
|
157
|
+
score += 1
|
|
158
|
+
# Overview / Domain Scope section
|
|
159
|
+
if re.search(r"^#{1,3}\s+(overview|domain\s+scope|about|introduction)", text, re.IGNORECASE | re.MULTILINE):
|
|
160
|
+
score += 1
|
|
161
|
+
# Workflow section
|
|
162
|
+
if re.search(r"^#{1,3}\s+workflow", text, re.IGNORECASE | re.MULTILINE):
|
|
163
|
+
score += 1
|
|
164
|
+
# Output format section
|
|
165
|
+
if re.search(r"^#{1,3}\s+.*(output|format|response\s+format|deliverable)", text, re.IGNORECASE | re.MULTILINE):
|
|
166
|
+
score += 1
|
|
167
|
+
# Edge cases section
|
|
168
|
+
if re.search(r"^#{1,4}\s+[^\n]*edge\s+case[s]?", text, re.IGNORECASE | re.MULTILINE):
|
|
169
|
+
score += 1
|
|
170
|
+
return score
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def score_conciseness(lines: list[str]) -> int:
|
|
174
|
+
"""Score based on total line count."""
|
|
175
|
+
count = len(lines)
|
|
176
|
+
if 80 <= count <= 120:
|
|
177
|
+
return 5
|
|
178
|
+
elif (60 <= count < 80) or (120 < count <= 150):
|
|
179
|
+
return 4
|
|
180
|
+
elif (50 <= count < 60) or (150 < count <= 170):
|
|
181
|
+
return 3
|
|
182
|
+
elif 170 < count <= 200:
|
|
183
|
+
return 2
|
|
184
|
+
else:
|
|
185
|
+
return 1
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
# ---------------------------------------------------------------------------
|
|
189
|
+
# Per-file scorer
|
|
190
|
+
# ---------------------------------------------------------------------------
|
|
191
|
+
|
|
192
|
+
CRITERIA = [
|
|
193
|
+
"tool_coverage",
|
|
194
|
+
"code_examples",
|
|
195
|
+
"edge_cases",
|
|
196
|
+
"actionability",
|
|
197
|
+
"structure",
|
|
198
|
+
"conciseness",
|
|
199
|
+
]
|
|
200
|
+
|
|
201
|
+
CRITERIA_LABELS = {
|
|
202
|
+
"tool_coverage": "Tool Coverage",
|
|
203
|
+
"code_examples": "Code Examples",
|
|
204
|
+
"edge_cases": "Edge Cases",
|
|
205
|
+
"actionability": "Actionability",
|
|
206
|
+
"structure": "Structure",
|
|
207
|
+
"conciseness": "Conciseness",
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def score_file(path: Path) -> dict:
|
|
212
|
+
text = path.read_text(encoding="utf-8", errors="replace")
|
|
213
|
+
lines = text.splitlines()
|
|
214
|
+
scores = {
|
|
215
|
+
"tool_coverage": score_tool_coverage(text),
|
|
216
|
+
"code_examples": score_code_examples(text),
|
|
217
|
+
"edge_cases": score_edge_cases(text),
|
|
218
|
+
"actionability": score_actionability(text),
|
|
219
|
+
"structure": score_structure(text),
|
|
220
|
+
"conciseness": score_conciseness(lines),
|
|
221
|
+
}
|
|
222
|
+
total = sum(scores.values())
|
|
223
|
+
return {
|
|
224
|
+
"skill": path.parent.name,
|
|
225
|
+
"file": str(path),
|
|
226
|
+
"line_count": len(lines),
|
|
227
|
+
"scores": scores,
|
|
228
|
+
"total": total,
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
# ---------------------------------------------------------------------------
|
|
233
|
+
# Formatting
|
|
234
|
+
# ---------------------------------------------------------------------------
|
|
235
|
+
|
|
236
|
+
COL_W = 14 # width for each criterion column
|
|
237
|
+
NAME_W = 22 # width for skill name
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def _fmt_header() -> str:
|
|
241
|
+
parts = [f"{'Skill':<{NAME_W}}"]
|
|
242
|
+
for c in CRITERIA:
|
|
243
|
+
label = CRITERIA_LABELS[c][:COL_W]
|
|
244
|
+
parts.append(f"{label:>{COL_W}}")
|
|
245
|
+
parts.append(f"{'Total':>{COL_W}}")
|
|
246
|
+
return " ".join(parts)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def _fmt_row(result: dict) -> str:
|
|
250
|
+
name = result["skill"][:NAME_W]
|
|
251
|
+
parts = [f"{name:<{NAME_W}}"]
|
|
252
|
+
for c in CRITERIA:
|
|
253
|
+
parts.append(f"{result['scores'][c]:>{COL_W}}")
|
|
254
|
+
parts.append(f"{result['total']:>{COL_W}}")
|
|
255
|
+
return " ".join(parts)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def _separator(char: str = "-") -> str:
|
|
259
|
+
total_width = NAME_W + (COL_W + 2) * (len(CRITERIA) + 1)
|
|
260
|
+
return char * total_width
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def print_histogram(results: list[dict]) -> None:
|
|
264
|
+
totals = [r["total"] for r in results]
|
|
265
|
+
max_total = 30
|
|
266
|
+
bin_size = 5
|
|
267
|
+
bins: dict[int, int] = {}
|
|
268
|
+
for t in totals:
|
|
269
|
+
b = (t // bin_size) * bin_size
|
|
270
|
+
bins[b] = bins.get(b, 0) + 1
|
|
271
|
+
|
|
272
|
+
print("\nScore Distribution:")
|
|
273
|
+
bar_max = max(bins.values()) if bins else 1
|
|
274
|
+
bar_scale = 30 # max bar width in chars
|
|
275
|
+
for b in range(0, max_total + 1, bin_size):
|
|
276
|
+
count = bins.get(b, 0)
|
|
277
|
+
bar_len = int(count / bar_max * bar_scale) if bar_max else 0
|
|
278
|
+
bar = "#" * bar_len
|
|
279
|
+
label = f"{b:2d}-{b+bin_size-1:2d}"
|
|
280
|
+
print(f" {label} | {bar:<{bar_scale}} {count}")
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def print_results(results: list[dict]) -> None:
|
|
284
|
+
sorted_results = sorted(results, key=lambda r: r["total"])
|
|
285
|
+
|
|
286
|
+
print(_separator("="))
|
|
287
|
+
print("Agent-Skills Scorer (max 30 points per skill)")
|
|
288
|
+
print(_separator("="))
|
|
289
|
+
print()
|
|
290
|
+
print(_fmt_header())
|
|
291
|
+
print(_separator())
|
|
292
|
+
|
|
293
|
+
for r in sorted_results:
|
|
294
|
+
print(_fmt_row(r))
|
|
295
|
+
|
|
296
|
+
print(_separator())
|
|
297
|
+
|
|
298
|
+
totals = [r["total"] for r in results]
|
|
299
|
+
avg = sum(totals) / len(totals) if totals else 0
|
|
300
|
+
mn = min(totals) if totals else 0
|
|
301
|
+
mx = max(totals) if totals else 0
|
|
302
|
+
|
|
303
|
+
print(f"\nSkills scored : {len(results)}")
|
|
304
|
+
print(f"Average score : {avg:.1f} / 30")
|
|
305
|
+
print(f"Min score : {mn} / 30 ({next(r['skill'] for r in results if r['total'] == mn)})")
|
|
306
|
+
print(f"Max score : {mx} / 30 ({next(r['skill'] for r in sorted_results[::-1] if r['total'] == mx)})")
|
|
307
|
+
|
|
308
|
+
print_histogram(sorted_results)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
# ---------------------------------------------------------------------------
|
|
312
|
+
# Entry point
|
|
313
|
+
# ---------------------------------------------------------------------------
|
|
314
|
+
|
|
315
|
+
def main() -> None:
|
|
316
|
+
parser = argparse.ArgumentParser(
|
|
317
|
+
description="Score all skill files in the Agent-Skills repo."
|
|
318
|
+
)
|
|
319
|
+
parser.add_argument(
|
|
320
|
+
"--json",
|
|
321
|
+
action="store_true",
|
|
322
|
+
help="Output results as JSON instead of a human-readable table.",
|
|
323
|
+
)
|
|
324
|
+
args = parser.parse_args()
|
|
325
|
+
|
|
326
|
+
# Resolve repo root: script lives at <repo>/scripts/score.py
|
|
327
|
+
script_dir = Path(__file__).resolve().parent
|
|
328
|
+
repo_root = script_dir.parent
|
|
329
|
+
|
|
330
|
+
skill_files = find_skill_files(repo_root)
|
|
331
|
+
if not skill_files:
|
|
332
|
+
print("No skill files found.", file=sys.stderr)
|
|
333
|
+
sys.exit(1)
|
|
334
|
+
|
|
335
|
+
results = [score_file(f) for f in skill_files]
|
|
336
|
+
|
|
337
|
+
if args.json:
|
|
338
|
+
totals = [r["total"] for r in results]
|
|
339
|
+
output = {
|
|
340
|
+
"repo": str(repo_root),
|
|
341
|
+
"skills_scored": len(results),
|
|
342
|
+
"summary": {
|
|
343
|
+
"average": round(sum(totals) / len(totals), 2) if totals else 0,
|
|
344
|
+
"min": min(totals) if totals else 0,
|
|
345
|
+
"max": max(totals) if totals else 0,
|
|
346
|
+
},
|
|
347
|
+
"results": sorted(results, key=lambda r: r["total"]),
|
|
348
|
+
}
|
|
349
|
+
print(json.dumps(output, indent=2))
|
|
350
|
+
else:
|
|
351
|
+
print_results(results)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
if __name__ == "__main__":
|
|
355
|
+
main()
|