gitnexus
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "gitnexus":https://skillpi.com/zh/skills/deepskill-5415cc615645247d10c6420599f968f581645e8890cbc4a076273a5d6cd8350d。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
构建带有图检索增强生成(Graph RAG)功能的客户端代码知识图谱,用于代码探索。适用于在浏览器中分析大型代码库、创建零服务器代码智能工具或开发交互式代码探索界面。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 实测状态
- 未测试
文件浏览
Frontmatter
name: gitnexus
description: >-
Build client-side code knowledge graphs with built-in Graph RAG for code exploration.
Use when: analyzing large codebases in the browser, building zero-server code intelligence
tools, creating interactive code exploration UIs.
license: MIT
compatibility: "Browser, TypeScript"
metadata:
author: terminal-skills
version: "1.0.0"
category: development
tags: [knowledge-graph, code-analysis, graph-rag, browser, visualization]
use-cases:
- "Build a browser-based code exploration tool from a GitHub repo URL"
- "Create an interactive knowledge graph of any codebase without a server"
- "Ask questions about code using Graph RAG in the browser"
agents: [claude-code, openai-codex, gemini-cli, cursor]GitNexus
Overview
Build client-side code knowledge graphs that run entirely in the browser — no server required. Parse code with tree-sitter WASM, construct a graph of files, functions, classes, and dependencies, visualize it with force-directed layouts, and query it with Graph RAG for natural-language code exploration.
Instructions
When a user asks to build a code knowledge graph, browser-based code explorer, or Graph RAG for code:
- Set up tree-sitter WASM — Load language grammars for the target languages
- Parse the codebase — Extract AST nodes (functions, classes, imports, exports)
- Build the graph — Create nodes and edges representing code relationships
- Visualize — Render with force-directed graph (D3 or force-graph library)
- Enable Graph RAG — Embed graph nodes, allow natural-language queries
Code Parsing with Tree-sitter WASM
import Parser from "web-tree-sitter";
interface CodeNode {
id: string;
type: "file" | "function" | "class" | "method" | "import" | "export";
name: string;
filePath: string;
startLine: number;
endLine: number;
code: string;
}
interface CodeEdge {
source: string;
target: string;
type: "contains" | "calls" | "imports" | "extends" | "implements";
}
async function initParser(language: string): Promise<Parser> {
await Parser.init();
const parser = new Parser();
const lang = await Parser.Language.load(`/tree-sitter-${language}.wasm`);
parser.setLanguage(lang);
return parser;
}
function extractNodes(tree: Parser.Tree, filePath: string): CodeNode[] {
const nodes: CodeNode[] = [];
nodes.push({ id: `file:${filePath}`, type: "file", name: filePath.split("/").pop()!, filePath, startLine: 0, endLine: tree.rootNode.endPosition.row, code: "" });
function walk(node: Parser.SyntaxNode) {
const nameNode = node.childForFieldName("name");
if ((node.type === "function_declaration" || node.type === "arrow_function") && nameNode) {
nodes.push({ id: `fn:${filePath}:${nameNode.text}`, type: "function", name: nameNode.text, filePath, startLine: node.startPosition.row, endLine: node.endPosition.row, code: node.text.slice(0, 500) });
}
if (node.type === "class_declaration" && nameNode) {
nodes.push({ id: `class:${filePath}:${nameNode.text}`, type: "class", name: nameNode.text, filePath, startLine: node.startPosition.row, endLine: node.endPosition.row, code: node.text.slice(0, 500) });
}
if (node.type === "import_statement") {
const source = node.descendantsOfType("string")[0];
if (source) nodes.push({ id: `import:${filePath}:${source.text}`, type: "import", name: source.text.replace(/['"]/g, ""), filePath, startLine: node.startPosition.row, endLine: node.endPosition.row, code: node.text });
}
for (const child of node.children) walk(child);
}
walk(tree.rootNode);
return nodes;
}
Graph Construction
function buildGraph(fileNodes: Map<string, CodeNode[]>): { nodes: CodeNode[]; edges: CodeEdge[] } {
const allNodes: CodeNode[] = [];
const edges: CodeEdge[] = [];
const functionIndex = new Map<string, string>();
for (const [, nodes] of fileNodes) {
allNodes.push(...nodes);
for (const node of nodes) {
if (node.type === "function" || node.type === "method") functionIndex.set(node.name, node.id);
}
}
for (const node of allNodes) {
const fileId = `file:${node.filePath}`;
if (node.type !== "file") edges.push({ source: fileId, target: node.id, type: "contains" });
if (node.type === "import") {
const targetFile = resolveImport(node.name, node.filePath);
if (targetFile) edges.push({ source: fileId, target: `file:${targetFile}`, type: "imports" });
}
if (node.type === "function" || node.type === "method") {
for (const [fnName, fnId] of functionIndex) {
if (fnId !== node.id && node.code.includes(fnName + "(")) edges.push({ source: node.id, target: fnId, type: "calls" });
}
}
}
return { nodes: allNodes, edges };
}
function resolveImport(importPath: string, fromFile: string): string | null {
if (importPath.startsWith(".")) {
return `${fromFile.split("/").slice(0, -1).join("/")}/${importPath.replace(/^\.\//, "")}.ts`;
}
return null;
}
Visualization with Force-Graph
import ForceGraph from "force-graph";
function renderGraph(container: HTMLElement, graph: { nodes: CodeNode[]; edges: CodeEdge[] }) {
const colorMap: Record<string, string> = { file: "#4a9eff", function: "#50c878", class: "#ff6b6b", method: "#ffa500", import: "#888888", export: "#dda0dd" };
ForceGraph()(container)
.graphData({
nodes: graph.nodes.map((n) => ({ id: n.id, name: n.name, type: n.type, val: n.type === "file" ? 8 : n.type === "class" ? 5 : 3 })),
links: graph.edges.map((e) => ({ source: e.source, target: e.target, type: e.type })),
})
.nodeColor((node: any) => colorMap[node.type] || "#999")
.nodeLabel((node: any) => `${node.type}: ${node.name}`)
.linkDirectionalArrowLength(4);
}
Graph RAG Query
import { pipeline } from "@xenova/transformers";
async function embedNodes(graph: { nodes: CodeNode[] }): Promise<Map<string, number[]>> {
const embeddings = new Map<string, number[]>();
const embedder = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2");
for (const node of graph.nodes) {
const text = `${node.type} "${node.name}" in ${node.filePath}: ${node.code.slice(0, 200)}`;
const result = await embedder(text, { pooling: "mean", normalize: true });
embeddings.set(node.id, Array.from(result.data));
}
return embeddings;
}
function searchGraph(query: number[], embeddings: Map<string, number[]>, topK = 10): string[] {
const scores: [string, number][] = [];
for (const [id, emb] of embeddings) {
let dot = 0, magA = 0, magB = 0;
for (let i = 0; i < query.length; i++) { dot += query[i] * emb[i]; magA += query[i] ** 2; magB += emb[i] ** 2; }
scores.push([id, dot / (Math.sqrt(magA) * Math.sqrt(magB))]);
}
return scores.sort((a, b) => b[1] - a[1]).slice(0, topK).map(([id]) => id);
}
Examples
Example 1: Build a Browser-Based Code Explorer for a React Project
npm create vite@latest code-nexus -- --template vanilla-ts
cd code-nexus
npm install web-tree-sitter force-graph @xenova/transformers
// main.ts — Parse a GitHub repo and render its knowledge graph
const parser = await initParser("typescript");
const files = await fetchRepoFiles("facebook/react", "packages/react/src");
const fileNodes = new Map<string, CodeNode[]>();
for (const file of files) {
const tree = parser.parse(file.content);
fileNodes.set(file.path, extractNodes(tree, file.path));
}
const graph = buildGraph(fileNodes);
renderGraph(document.getElementById("graph")!, graph);
// Result: interactive force-directed graph showing React's internal module structure
Example 2: Natural-Language Code Query with Graph RAG
// After building the graph, embed all nodes and query
const graph = buildGraph(fileNodes);
const embeddings = await embedNodes(graph);
// User asks a question about the codebase
const embedder = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2");
const qEmb = Array.from((await embedder("How does the authentication middleware work?", { pooling: "mean", normalize: true })).data);
const relevantIds = searchGraph(qEmb, embeddings, 5);
const context = relevantIds
.map((id) => graph.nodes.find((n) => n.id === id))
.filter(Boolean)
.map((n) => `[${n!.type}] ${n!.name} (${n!.filePath})\n${n!.code.slice(0, 300)}`)
.join("\n---\n");
// Pass context to LLM for a grounded answer about the codebase
const response = await fetch("/api/chat", {
method: "POST",
body: JSON.stringify({ messages: [
{ role: "system", content: `Answer using this code context:\n${context}` },
{ role: "user", content: "How does the authentication middleware work?" },
]}),
});
Guidelines
- Lazy-load grammars — Only load tree-sitter WASM grammars for languages present in the repo
- OPFS for large repos — Store cloned files in Origin Private File System for persistence
- Incremental parsing — Re-parse only changed files, not the entire repo
- Limit graph size — For repos with 1000+ files, allow filtering by directory or file type
- Web Workers — Run parsing and embedding in Web Workers to keep the UI responsive
- Cache embeddings — Store in IndexedDB so you don't re-embed on every page load
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供浏览器端代码知识图谱构建与 Graph RAG 查询功能,解决大型代码库分析的明确痛点
- 支持零服务器架构,适用于构建交互式代码探索工具,具有高频实用价值
待提升项
-
触发词覆盖 原报告严重程度:轻微
description 中已包含适用场景描述,但未使用显式的 When to Use 章节标题
改进建议:建议在文档中添加显式的 When to Use 章节,进一步提升触发精准度
亮点
- description 明确描述三大适用场景:分析大型代码库、构建零服务器代码智能工具、创建交互式代码探索 UI
亮点
- 文档结构完整,包含 Overview、Instructions、代码示例、Guidelines 等必要章节
- 提供端到端代码示例,步骤清晰,frontmatter 信息完整
亮点
- 工具来源明确(web-tree-sitter、force-graph、@xenova/transformers),参数使用合理
- 覆盖了主要异常处理场景,如 resolveImport 返回 null 处理
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 180 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。