feat: migrate advanced skills (github, coding-agent, context7) to clawgo

This commit is contained in:
DBT
2026-02-12 04:26:56 +00:00
parent 8bbefbe9ae
commit e2862d4478
6 changed files with 202 additions and 2 deletions

View File

@@ -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

1
skills/context7/.env Normal file
View File

@@ -0,0 +1 @@
CONTEXT7_API_KEY=ctx7sk-dfce3619-d4cf-4ce2-a1a1-9d0ba9d071ad

19
skills/context7/SKILL.md Normal file
View File

@@ -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 <owner/repo> <query>
```
Example:
```bash
npx tsx /root/.clawgo/skills/context7/query.ts context sipeed/clawgo "How does the skill system work?"
```

View File

@@ -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"
}
}

161
skills/context7/query.ts Normal file
View File

@@ -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 <repo_owner/repo_name> <search_query>
* Context: npx tsx query.ts context <repo_owner/repo_name> <search_query>
*
* 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 <command> <repo_owner/repo_name> <search_query>
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 <repo> <query>");
console.error(" Context: npx tsx query.ts context <repo> <query>");
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);
}

View File

@@ -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