OpenSenseNova/SenseNova-Skills / skills/sn-search-code
sn-search-code
Verified用于查找代码示例、开源项目、GitHub Issue、技术问答、开发者讨论、HuggingFace 模型/数据集/Space。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.7 KB |
| requirements.txt | manifest | 12 B |
| scripts/github_search.py | script | 3.1 KB |
| scripts/hackernews_search.py | script | 2.8 KB |
| scripts/huggingface_search.py | script | 4.3 KB |
| scripts/search_utils.py | script | 4.3 KB |
| scripts/stackoverflow_search.py | script | 2.7 KB |
scripts/github_search.py
View on GitHub#!/usr/bin/env python3
"""GitHub 搜索:仓库、代码、Issue。通过 GitHub REST API。"""
import sys
from search_utils import build_parser, get_client, get_key, make_item, make_result, print_json
API_BASE = "https://api.github.com/search"
# 搜索类型 -> API 路径
SEARCH_TYPES = {
"repositories": "repositories",
"code": "code",
"issues": "issues",
"repo": "repositories", # 别名
"issue": "issues", # 别名
}
def search(query: str, limit: int, search_type: str = "repositories", token: str | None = None) -> list[dict]:
"""执行 GitHub 搜索。"""
endpoint = SEARCH_TYPES.get(search_type, "repositories")
url = f"{API_BASE}/{endpoint}"
headers = {"Accept": "application/vnd.github.v3+json"}
if token:
headers["Authorization"] = f"Bearer {token}"
params = {
"q": query,
"per_page": min(limit, 100),
"sort": "best match",
}
with get_client(headers=headers) as client:
resp = client.get(url, params=params)
resp.raise_for_status()
data = resp.json()
items = []
for item in data.get("items", [])[:limit]:
if endpoint == "repositories":
items.append(make_item(
title=item.get("full_name", ""),
url=item.get("html_url", ""),
snippet=item.get("description") or "",
stars=item.get("stargazers_count", 0),
language=item.get("language"),
updated_at=item.get("updated_at"),
))
elif endpoint == "code":
repo = item.get("repository", {})
items.append(make_item(
title=item.get("name", ""),
url=item.get("html_url", ""),
snippet=f"{repo.get('full_name', '')} - {item.get('path', '')}",
repo=repo.get("full_name"),
path=item.get("path"),
))
elif endpoint == "issues":
items.append(make_item(
title=item.get("title", ""),
url=item.get("html_url", ""),
snippet=_truncate(item.get("body") or "", 200),
state=item.get("state"),
comments=item.get("comments", 0),
created_at=item.get("created_at"),
))
return items
def _truncate(text: str, max_len: int) -> str:
return text[:max_len] + "..." if len(text) > max_len else text
def main():
parser = build_parser("搜索 GitHub 仓库、代码、Issue")
parser.add_argument("--type", "-t", default="repositories",
choices=list(SEARCH_TYPES.keys()),
help="搜索类型(默认 repositories)")
parser.add_argument("--token", help="GitHub Token(也可通过 GITHUB_TOKEN 环境变量设置)")
args = parser.parse_args()
token = get_key("GITHUB_TOKEN", args.token)
try:
items = search(args.query, args.limit, args.type, token)
print_json(make_result(True, args.query, "github", items))
except Exception as e:
print_json(make_result(False, args.query, "github", [], str(e)))
sys.exit(1)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |