kompass-sdk 0.5.0 → 0.7.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.
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * Skills Source Adapter
3
- * Searches skills.sh (Vercel) and ClawHub registries for agent skills
4
- * 13,700+ capabilities indexed across both registries
3
+ * Searches REAL APIs:
4
+ * - skills.sh (Vercel) /api/search?q=
5
+ * - ClawHub (OpenClaw) — /api/search?q= (vector search)
6
+ *
7
+ * No hardcoded seed lists. All real data.
5
8
  */
6
9
 
7
10
  import type { SourceAdapter, UnifiedAgent, SourceSearchOptions } from "./types.js";
8
11
 
9
- const SKILLS_SH_API = "https://skills.sh";
10
- const CLAWHUB_API = "https://clawhub.ai";
12
+ const SKILLS_SH_API = "https://skills.sh/api/search";
13
+ const CLAWHUB_API = "https://clawhub.ai/api/search";
11
14
 
12
15
  export const skillsAdapter: SourceAdapter = {
13
16
  name: "skills-registry",
@@ -19,143 +22,111 @@ export const skillsAdapter: SourceAdapter = {
19
22
  const results: UnifiedAgent[] = [];
20
23
 
21
24
  // Search skills.sh
22
- try {
23
- const skillsShResults = await searchSkillsSh(query, Math.ceil(limit / 2), timeout);
24
- results.push(...skillsShResults);
25
- } catch {
26
- // skills.sh might not have a public search API — fall back to known skills
27
- }
28
-
29
- // Search ClawHub
30
- try {
31
- const clawHubResults = await searchClawHub(query, Math.ceil(limit / 2), timeout);
32
- results.push(...clawHubResults);
33
- } catch {
34
- // ClawHub might be rate-limited
35
- }
25
+ const [skillsShResults, clawHubResults] = await Promise.allSettled([
26
+ searchSkillsSh(query, Math.ceil(limit / 2), timeout),
27
+ searchClawHub(query, Math.ceil(limit / 2), timeout),
28
+ ]);
36
29
 
37
- // If both APIs fail, return from seed list
38
- if (results.length === 0) {
39
- return searchSeedList(query, limit);
40
- }
30
+ if (skillsShResults.status === "fulfilled") results.push(...skillsShResults.value);
31
+ if (clawHubResults.status === "fulfilled") results.push(...clawHubResults.value);
41
32
 
42
33
  return results.slice(0, limit);
43
34
  },
44
35
 
45
36
  async ping(): Promise<boolean> {
46
37
  try {
47
- const res = await fetch(SKILLS_SH_API, { signal: AbortSignal.timeout(3000) });
38
+ const res = await fetch(`${SKILLS_SH_API}?q=test`, { signal: AbortSignal.timeout(3000) });
48
39
  return res.ok;
49
40
  } catch {
50
- return true; // Seed list always available
41
+ return false;
51
42
  }
52
43
  },
53
44
  };
54
45
 
55
46
  async function searchSkillsSh(query: string, limit: number, timeout: number): Promise<UnifiedAgent[]> {
56
- // skills.sh has a search page — try to query it
57
- const res = await fetch(`${SKILLS_SH_API}/api/search?q=${encodeURIComponent(query)}&limit=${limit}`, {
58
- signal: AbortSignal.timeout(timeout),
59
- });
60
-
61
- if (!res.ok) {
62
- // Try the leaderboard endpoint
63
- const lbRes = await fetch(`${SKILLS_SH_API}/api/leaderboard?limit=${limit}`, {
47
+ try {
48
+ const res = await fetch(`${SKILLS_SH_API}?q=${encodeURIComponent(query)}`, {
64
49
  signal: AbortSignal.timeout(timeout),
65
50
  });
66
- if (!lbRes.ok) return [];
67
- const data = await lbRes.json();
68
- const skills = Array.isArray(data) ? data : data.skills ?? data.data ?? [];
69
- return skills
70
- .filter((s: any) => matchesQuery(s, query))
71
- .map((s: any) => mapSkill(s, "skills-sh"));
72
- }
73
51
 
74
- const data = await res.json();
75
- const skills = Array.isArray(data) ? data : data.skills ?? data.results ?? [];
76
- return skills.map((s: any) => mapSkill(s, "skills-sh"));
52
+ if (!res.ok) return [];
53
+
54
+ const data = await res.json();
55
+ const skills = data.skills ?? [];
56
+
57
+ return skills.slice(0, limit).map((s: any) => ({
58
+ id: `skills-registry:skills-sh:${s.id ?? s.skillId}`,
59
+ nativeId: s.id ?? s.skillId,
60
+ name: s.name ?? s.skillId ?? "Unknown Skill",
61
+ description: s.description ?? "",
62
+ categories: extractSkillCategories(s.name ?? "", s.description ?? ""),
63
+ capabilities: [s.name, s.description].filter(Boolean),
64
+ source: "skills-registry" as const,
65
+ protocol: "skill" as const,
66
+ endpoints: {
67
+ http: `https://skills.sh/${s.source ?? s.id}`,
68
+ },
69
+ pricing: { model: "free" as const },
70
+ verified: (s.installs ?? 0) > 100,
71
+ reputation: s.installs ? {
72
+ score: Math.min(s.installs / 100, 100),
73
+ count: s.installs,
74
+ source: "skills-sh-installs",
75
+ } : undefined,
76
+ raw: { ...s, registry: "skills-sh" },
77
+ }));
78
+ } catch {
79
+ return [];
80
+ }
77
81
  }
78
82
 
79
83
  async function searchClawHub(query: string, limit: number, timeout: number): Promise<UnifiedAgent[]> {
80
- const res = await fetch(`${CLAWHUB_API}/api/skills/search?q=${encodeURIComponent(query)}&limit=${limit}`, {
81
- signal: AbortSignal.timeout(timeout),
82
- });
83
-
84
- if (!res.ok) return [];
85
-
86
- const data = await res.json();
87
- const skills = Array.isArray(data) ? data : data.skills ?? data.results ?? [];
88
- return skills.map((s: any) => mapSkill(s, "clawhub"));
89
- }
90
-
91
- function mapSkill(skill: any, registry: string): UnifiedAgent {
92
- const name = skill.name ?? skill.slug ?? skill.title ?? "Unknown Skill";
93
- const description = skill.description ?? "";
94
- const repo = skill.repo ?? skill.repository ?? skill.url ?? "";
95
- const installs = skill.installs ?? skill.downloads ?? 0;
96
-
97
- return {
98
- id: `skills-registry:${registry}:${name.toLowerCase().replace(/\s+/g, "-")}`,
99
- nativeId: skill.id ?? name,
100
- name,
101
- description,
102
- categories: extractSkillCategories(name, description),
103
- capabilities: [description, ...(skill.tags ?? [])],
104
- source: "skills-registry" as any,
105
- protocol: "skill" as any,
106
- endpoints: {
107
- http: repo || `https://skills.sh/${name}`,
108
- },
109
- pricing: { model: "free" as const },
110
- verified: installs > 100,
111
- lastSeen: Date.now(),
112
- raw: { ...skill, registry },
113
- };
114
- }
115
-
116
- // Seed list of well-known skills for when APIs are unavailable
117
- const KNOWN_SKILLS = [
118
- { name: "remotion-best-practices", description: "Video creation in React with Remotion", categories: ["media", "development"], registry: "skills-sh", installs: 145000 },
119
- { name: "web-design-guidelines", description: "UI/UX design best practices for web development", categories: ["design", "development"], registry: "skills-sh", installs: 89000 },
120
- { name: "react-best-practices", description: "React and Next.js performance optimization from Vercel", categories: ["development"], registry: "skills-sh", installs: 120000 },
121
- { name: "solana-dev", description: "End-to-end Solana development playbook", categories: ["development", "defi"], registry: "skills-sh", installs: 50000 },
122
- { name: "cairo-contracts", description: "Write Cairo smart contracts on Starknet", categories: ["development", "defi"], registry: "skills-sh", installs: 30000 },
123
- { name: "x402-skill", description: "x402 HTTP payment protocol for monetizing APIs", categories: ["payments", "development"], registry: "skills-sh", installs: 25000 },
124
- { name: "agent-browser", description: "Automate browser interactions, screenshots, form filling", categories: ["tools", "automation"], registry: "skills-sh", installs: 70000 },
125
- { name: "implement-design", description: "Translate Figma designs into production-ready code", categories: ["design", "development"], registry: "skills-sh", installs: 60000 },
126
- { name: "find-skills", description: "Discover and install new agent skills", categories: ["tools", "discovery"], registry: "skills-sh", installs: 200000 },
127
- { name: "tailwind-v4-shadcn", description: "Set up Tailwind v4 with shadcn/ui", categories: ["development", "design"], registry: "skills-sh", installs: 45000 },
128
- { name: "ethskills", description: "Learn Ethereum, Solidity, smart contracts, web3 development", categories: ["development", "defi"], registry: "skills-sh", installs: 8000 },
129
- { name: "soul-markets", description: "Agent skill marketplace — monetize agent capabilities", categories: ["marketplace", "commerce"], registry: "clawhub", installs: 5000 },
130
- { name: "a2a-market", description: "Buy and sell agent skills using USDC on Base via A2A", categories: ["marketplace", "commerce"], registry: "clawhub", installs: 3000 },
131
- { name: "skillzmarket", description: "Discover and install skills from community marketplace", categories: ["marketplace", "discovery"], registry: "clawhub", installs: 4000 },
132
- { name: "x402-agent-marketplace", description: "x402 agent marketplace for paid AI capabilities", categories: ["marketplace", "payments"], registry: "clawhub", installs: 2000 },
133
- ];
134
-
135
- function searchSeedList(query: string, limit: number): UnifiedAgent[] {
136
- const lower = query.toLowerCase();
137
- return KNOWN_SKILLS
138
- .filter((s) => matchesQuery(s, query))
139
- .slice(0, limit)
140
- .map((s) => mapSkill({ ...s, installs: s.installs }, s.registry));
141
- }
84
+ try {
85
+ const res = await fetch(`${CLAWHUB_API}?q=${encodeURIComponent(query)}`, {
86
+ signal: AbortSignal.timeout(timeout),
87
+ });
142
88
 
143
- function matchesQuery(skill: any, query: string): boolean {
144
- if (!query) return true;
145
- const lower = query.toLowerCase();
146
- const text = `${skill.name ?? ""} ${skill.description ?? ""} ${(skill.tags ?? []).join(" ")} ${(skill.categories ?? []).join(" ")}`.toLowerCase();
147
- return lower.split(/\s+/).some((term) => text.includes(term));
89
+ if (!res.ok) return [];
90
+
91
+ const data = await res.json();
92
+ const skills = data.results ?? [];
93
+
94
+ return skills.slice(0, limit).map((s: any) => ({
95
+ id: `skills-registry:clawhub:${s.slug}`,
96
+ nativeId: s.slug,
97
+ name: s.displayName ?? s.slug ?? "Unknown Skill",
98
+ description: s.summary ?? "",
99
+ categories: extractSkillCategories(s.displayName ?? "", s.summary ?? ""),
100
+ capabilities: [s.summary ?? s.displayName ?? ""],
101
+ source: "skills-registry" as const,
102
+ protocol: "skill" as const,
103
+ endpoints: {
104
+ http: `https://clawhub.ai/${s.slug}`,
105
+ },
106
+ pricing: { model: "free" as const },
107
+ verified: true,
108
+ reputation: s.score ? {
109
+ score: Math.round(s.score * 25),
110
+ count: 0,
111
+ source: "clawhub-relevance",
112
+ } : undefined,
113
+ raw: { ...s, registry: "clawhub" },
114
+ }));
115
+ } catch {
116
+ return [];
117
+ }
148
118
  }
149
119
 
150
120
  function extractSkillCategories(name: string, description: string): string[] {
151
121
  const text = `${name} ${description}`.toLowerCase();
152
122
  const cats: string[] = [];
153
123
  if (text.match(/react|next|vue|svelte|frontend|css|tailwind|design/)) cats.push("development");
154
- if (text.match(/defi|yield|swap|solidity|ethereum|solana|contract/)) cats.push("defi");
124
+ if (text.match(/defi|yield|swap|solidity|ethereum|solana|contract|crypto/)) cats.push("defi");
155
125
  if (text.match(/image|video|audio|media|remotion|figma/)) cats.push("media");
156
- if (text.match(/data|analytics|research|search/)) cats.push("data");
126
+ if (text.match(/data|analytics|research|search|scrape/)) cats.push("data");
157
127
  if (text.match(/browser|automat|tool|file/)) cats.push("tools");
158
128
  if (text.match(/market|commerce|pay|x402|monetiz/)) cats.push("commerce");
159
129
  if (text.match(/security|audit|test/)) cats.push("security");
130
+ if (text.match(/ai|llm|model|agent/)) cats.push("ai");
160
131
  return cats.length > 0 ? cats : ["general"];
161
132
  }