From 34641a36555d915e7dd0fd8cffc8abcd3deee6f5 Mon Sep 17 00:00:00 2001 From: DBT Date: Thu, 12 Feb 2026 04:26:56 +0000 Subject: [PATCH] feat: migrate advanced skills (github, coding-agent, context7) to clawgo --- skills/coding-agent/SKILL.md | 2 +- skills/context7/.env | 1 + skills/context7/SKILL.md | 19 +++++ skills/context7/package.json | 20 +++++ skills/context7/query.ts | 161 +++++++++++++++++++++++++++++++++++ skills/github/SKILL.md | 1 - 6 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 skills/context7/.env create mode 100644 skills/context7/SKILL.md create mode 100644 skills/context7/package.json create mode 100644 skills/context7/query.ts diff --git a/skills/coding-agent/SKILL.md b/skills/coding-agent/SKILL.md index 3acac32..84c12c2 100644 --- a/skills/coding-agent/SKILL.md +++ b/skills/coding-agent/SKILL.md @@ -271,4 +271,4 @@ command example 3. Timestamped prompt history 4. Session logs if using Codex/agent -**Example:** https://github.com/steipete/bird/pull/222 +**Example:** https://github.com/steipete/bird/pull/22 diff --git a/skills/context7/.env b/skills/context7/.env new file mode 100644 index 0000000..ce76b83 --- /dev/null +++ b/skills/context7/.env @@ -0,0 +1 @@ +CONTEXT7_API_KEY=ctx7sk-dfce3619-d4cf-4ce2-a1a1-9d0ba9d071ad diff --git a/skills/context7/SKILL.md b/skills/context7/SKILL.md new file mode 100644 index 0000000..e9a283e --- /dev/null +++ b/skills/context7/SKILL.md @@ -0,0 +1,19 @@ +--- +name: context7 +description: Intelligent documentation search and context using context7 service. +--- + +# Context7 + +Query documentation and repositories for intelligent context. + +## Usage + +```bash +npx tsx /root/.clawgo/skills/context7/query.ts context +``` + +Example: +```bash +npx tsx /root/.clawgo/skills/context7/query.ts context sipeed/clawgo "How does the skill system work?" +``` diff --git a/skills/context7/package.json b/skills/context7/package.json new file mode 100644 index 0000000..67310b2 --- /dev/null +++ b/skills/context7/package.json @@ -0,0 +1,20 @@ +{ + "name": "context7-cli", + "version": "1.0.0", + "description": "Context7 MCP CLI for querying documentation", + "type": "module", + "scripts": { + "query": "tsx query.ts", + "read": "tsx read.ts", + "explore": "tsx explore.ts" + }, + "dependencies": { + "mcp-client": "^1.13.1", + "zod": "^3.22.4" + }, + "devDependencies": { + "@types/node": "^20.10.0", + "tsx": "^4.6.0", + "typescript": "^5.3.0" + } +} diff --git a/skills/context7/query.ts b/skills/context7/query.ts new file mode 100644 index 0000000..f596d41 --- /dev/null +++ b/skills/context7/query.ts @@ -0,0 +1,161 @@ +#!/usr/bin/env tsx +/** + * Context7 Query CLI + * + * Query Context7 API to search documentation and repository code. + * + * Usage: + * Search: npx tsx query.ts search + * Context: npx tsx query.ts context + * + * Examples: + * npx tsx query.ts search "better-auth/better-auth" "signIn social redirect callback" + * npx tsx query.ts context "facebook/react" "useState hook" + */ + +import { readFileSync } from "fs"; +import { join, dirname } from "path"; +import { fileURLToPath } from "url"; + +// Load API key from .env file in the same directory as this script +const __dirname = dirname(fileURLToPath(import.meta.url)); +const envPath = join(__dirname, ".env"); +let API_KEY = process.env.CONTEXT7_API_KEY; + +// Try to load from .env file if not in environment +if (!API_KEY) { + try { + const envContent = readFileSync(envPath, "utf-8"); + const match = envContent.match(/CONTEXT7_API_KEY=(.+)/); + API_KEY = match?.[1]?.trim(); + } catch { + // .env file doesn't exist, continue with null + } +} + +if (!API_KEY) { + console.error("Error: CONTEXT7_API_KEY not found"); + console.error("Set it in environment or in .env file in this directory"); + process.exit(1); +} + +const command = process.argv[2]; +const repoName = process.argv[3]; +const query = process.argv[4]; + +// Help text +if (!command || command === "--help" || command === "-h") { + console.log(` +Context7 Query CLI + +Usage: + npx tsx query.ts + +Commands: + search Search for libraries by name with intelligent LLM-powered ranking + context Retrieve intelligent, LLM-reranked documentation context + +Examples: + npx tsx query.ts search "nextjs" "setup ssr" + npx tsx query.ts context "better-auth/better-auth" "signIn social redirect" + +For more info: https://context7.com/docs +`); + process.exit(0); +} + +if (!repoName || !query) { + console.error("Error: Missing arguments"); + console.error("Usage:"); + console.error(" Search: npx tsx query.ts search "); + console.error(" Context: npx tsx query.ts context "); + process.exit(1); +} + +// Ensure repo name starts with / +const libraryId = repoName.startsWith("/") ? repoName : `/${repoName}`; + +async function searchLibraries() { + try { + console.log(`Searching Context7 for libraries matching "${query}"...`); + + // Context7 Search API + const url = new URL("https://context7.com/api/v2/libs/search"); + url.searchParams.set("libraryName", libraryId.split("/")[1] || ""); + url.searchParams.set("query", query); + + const response = await fetch(url.toString(), { + headers: { + "Authorization": `Bearer ${API_KEY}`, + }, + }); + + if (!response.ok) { + const error = await response.text(); + console.error(`Context7 API error (${response.status}):`, error); + process.exit(1); + } + + const data = await response.json(); + + console.log("\n=== Search Results ===\n"); + + if (Array.isArray(data) && data.length > 0) { + data.forEach((lib: any, i: number) => { + console.log(`${i + 1}. ${lib.name || lib.id}`); + console.log(` Trust Score: ${lib.trustScore || "N/A"}`); + console.log(` Benchmark: ${lib.benchmarkScore || "N/A"}`); + if (lib.versions) { + console.log(` Versions: ${lib.versions.slice(0, 5).join(", ")}${lib.versions.length > 5 ? "..." : ""}`); + } + console.log(""); + }); + } else { + console.log("No results found."); + } + } catch (error: any) { + console.error("Error searching Context7:", error.message); + process.exit(1); + } +} + +async function getContext() { + try { + console.log(`Getting context for: "${query}" in ${libraryId}...`); + + // Context7 REST API + const url = new URL("https://context7.com/api/v2/context"); + url.searchParams.set("libraryId", libraryId); + url.searchParams.set("query", query); + url.searchParams.set("type", "txt"); + + const response = await fetch(url.toString(), { + headers: { + "Authorization": `Bearer ${API_KEY}`, + }, + }); + + if (!response.ok) { + const error = await response.text(); + console.error(`Context7 API error (${response.status}):`, error); + process.exit(1); + } + + const text = await response.text(); + console.log("\n=== Context Results ===\n"); + console.log(text); + } catch (error: any) { + console.error("Error querying Context7:", error.message); + process.exit(1); + } +} + +if (command === "search" || command === "s") { + searchLibraries(); +} else if (command === "context" || command === "c") { + getContext(); +} else { + console.error(`Unknown command: ${command}`); + console.error("Use 'search' or 'context'"); + process.exit(1); +} diff --git a/skills/github/SKILL.md b/skills/github/SKILL.md index 57d8127..03b2a00 100644 --- a/skills/github/SKILL.md +++ b/skills/github/SKILL.md @@ -1,7 +1,6 @@ --- name: github description: "Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries." -metadata: {"nanobot":{"emoji":"🐙","requires":{"bins":["gh"]},"install":[{"id":"brew","kind":"brew","formula":"gh","bins":["gh"],"label":"Install GitHub CLI (brew)"},{"id":"apt","kind":"apt","package":"gh","bins":["gh"],"label":"Install GitHub CLI (apt)"}]}} --- # GitHub Skill