commit 857cd7d01b3968cd655c1a7323083746a1a32221 Author: kang Date: Mon Apr 13 18:27:54 2026 +0800 chore: 立项 graphify-analysis Graphify v0.4.8 源码全面解析 + GitNexus 替换评估报告,单页深色主题。 - public/index.html: ~600 行报告(架构/流程/逐模块/GraphRAG 验证/GitNexus 对比/建议) - Dockerfile + nginx.conf: Coolify 静态部署 - .memory/analysis.md: 完整调研笔记 - graphify/ 源码快照不入库(作为只读参考) 结论: 不要替换 GitNexus, 可选抄 Graphify 7 个细节。 Co-Authored-By: Claude Opus 4.6 (1M context) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..da8f860 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.git +.gitignore +.github +.memory +.project.json +README.md +graphify +worklog.json +*.md +!public/** diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e15d5eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.DS_Store +*.log +*.tmp +node_modules/ +dist/ +build/ diff --git a/.memory/analysis.md b/.memory/analysis.md new file mode 100644 index 0000000..5786922 --- /dev/null +++ b/.memory/analysis.md @@ -0,0 +1,82 @@ +--- +name: graphify-analysis 调研笔记 +description: Graphify v0.4.8 源码解析 + GitNexus 替换评估的完整调研记录 +type: project +--- + +## 立项背景 + +2026-04-13 用户看到营销推文("Graphify 用 GraphRAG 技术……71.5 倍 Token 节省")后要求评估: +1. 这项目是不是噱头? +2. 要不要把工作看板的代码图谱(GitNexus)换成这个? + +## 关键判断 + +**Graphify 本质**: tree-sitter AST + networkx + Leiden + 10 种导出 + 9 种 AI 平台集成脚本。 +8,237 行 Python,**零 LLM 硬依赖**,"智能"部分委托给宿主 Agent(Claude Code / Codex / ...)。 + +**"GraphRAG" 营销**: 与微软原论文定义(LLM 抽实体+关系+写社区摘要)不符。Graphify 只做了社区检测这一步。 + +**"71.5× token 节省"**: = 整个语料 token 数 / 单次 BFS 子图 token 数。不含首次建图的 subagent token 成本。固定 5 个英文问题 + 子串匹配选起点。**数字成立但有水分**。 + +## GitNexus vs Graphify 对比结论 + +| 维度 | GitNexus | Graphify | +|---|---|---| +| 规模 | 31,367 行 TS | 8,237 行 Py | +| 类型系统 | symbol-table + type-env + type-extractors | 无 | +| Python MRO | 有 (`mro-processor.ts`) | 无 | +| 框架识别 | 有 (`framework-detection.ts`) | 无 | +| 入口打分 | 有 (`entry-point-scoring.ts`) | 无 | +| 跨文件 resolver | 完整 `resolvers/` 子系统 | 只 Python 130 行 | +| 多项目 UI | Web @ 4090 | 每项目一目录 | +| 诚信度标签 | 未知 | EXTRACTED/INFERRED/AMBIGUOUS | + +**GitNexus 在代码静态分析维度领先一个量级。不要替换。** + +## 可从 Graphify 借鉴给 GitNexus 的 7 个点 + +1. 三档置信度标签 + `confidence_score`(Graphify `extract.py` / `report.py`) +2. Markdown 剥 YAML frontmatter 再哈希(`cache.py:10-17`)—— metadata 变更不触发重抽取 +3. 论文启发式识别 `_looks_like_paper`(`detect.py:68`,13 条正则) +4. 敏感文件过滤 `_SENSITIVE_PATTERNS`(`detect.py:33-40`) +5. SSRF 防护整套(`security.py:14-90`) +6. 大社区 25% 自动拆分(`cluster.py:93`) +7. URL 分类抓取(`ingest.py`,297 行,twitter/arxiv/github/youtube/pdf/image/web) + +## 技术亮点(Graphify 值得一看的 8 件事) + +1. `LanguageConfig` dataclass 模式(`extract.py:24`)—— 13 语言共用 200 行通用 walker +2. SHA256 内容缓存 + Markdown frontmatter 剥离(`cache.py`) +3. Python 跨文件 `_resolve_cross_file_imports`(`extract.py:2110-2240`)—— 整个项目唯一真正跨文件推理 +4. 单 HTML 交互图(`export.py:329`,内嵌 vis.js) +5. 9 平台集成脚本(`__main__.py:49-105`) +6. SSRF 防护默认开启 +7. 大社区自动拆分(防 Leiden 退化) +8. 置信度三档 + 分数 + +## 技术短板(9 条) + +1. 22 语言"支持"不均匀 —— 只有 Python 做了跨文件 uses 推断 +2. `_extract_python_rationale`(`extract.py:1011`)基于 docstring 的 heuristics 脆 +3. 查询不是语义搜索,是子串 +1/+0.5 打分 +4. `_make_id` 用 `[^a-zA-Z0-9]+` 正则 —— 中文标识符直接 collapse 成空串 +5. 静态 AST 解析,看不穿 C++ 模板 / Python metaclass / JS Proxy +6. benchmark 71.5× 固定 5 个英文问题 +7. 无类型系统 / 无 symbol table / 无 MRO +8. `_is_file_node` 启发式在非 Python 语言误伤 +9. PyPI 名 `graphifyy`(两个 y,赶时间) + +## 产出 + +- `public/index.html` — 单页深色主题报告(~600 行 HTML) +- 本地快照: `graphify/` 子目录(v0.4.8, commit `04e2960`) +- 部署目标: `https://graphify-analysis.kang-kang.com`(Coolify 静态) + +## 用户决策记录 + +- **不换 GitNexus**(用户确认) +- **立项并部署网页**(用户 2026-04-13 指示) +- **子域名**: `graphify-analysis.kang-kang.com` +- **可见性**: public(无密钥) +- **部署方式**: Coolify + Dockerfile(nginx:alpine) diff --git a/.project.json b/.project.json new file mode 100644 index 0000000..c3a1413 --- /dev/null +++ b/.project.json @@ -0,0 +1,27 @@ +{ + "name": "graphify-analysis", + "description": "Graphify 源码全面解析 + GitNexus 替换评估的单页报告", + "status": "active", + "category": "research", + "created": "2026-04-13", + "ports": [ + { + "port": 4410, + "label": "web", + "fixed": false + } + ], + "stack": [ + "HTML", + "nginx", + "Coolify", + "Docker" + ], + "deployment": { + "target": "coolify", + "domain": "graphify-analysis.kang-kang.com", + "type": "static", + "stateful": false + }, + "url": "https://git.kang-kang.com/kangwang/graphify-analysis" +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e6581b3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM nginx:1.27-alpine + +COPY nginx.conf /etc/nginx/conf.d/default.conf +COPY public/ /usr/share/nginx/html/ + +EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD wget -qO- http://127.0.0.1/ >/dev/null 2>&1 || exit 1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..c4e0c5d --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# graphify-analysis + +**Graphify 源码全面解析 + GitNexus 替换评估** 的单页报告,2026-04-13。 + +- 源项目: [safishamsi/graphify](https://github.com/safishamsi/graphify) v0.4.8 +- 对照项目: `~/Projects/code/20260319-gitnexus/`(浏览器 WASM 代码知识图谱) +- 部署: `https://graphify-analysis.kang-kang.com`(Coolify 静态站) + +## 本地预览 + +```bash +# 方式 1: 直接开浏览器 +open public/index.html + +# 方式 2: docker 跑 +docker build -t graphify-analysis . +docker run --rm -p 4410:80 graphify-analysis +# → http://localhost:4410 +``` + +## 目录结构 + +``` +. +├── .project.json 项目元数据 / 端口 / 部署信息 +├── .memory/ 调研笔记 +├── public/ +│ └── index.html 报告单页(深色主题,自包含) +├── Dockerfile nginx:alpine 静态托管 +├── nginx.conf gzip + 安全头 + /healthz +└── graphify/ 源码快照(Graphify v0.4.8,用于解析,部署时排除) +``` + +## 报告章节 + +1. Graphify 架构速览(文件/行数/依赖) +2. 执行流程(skill.md 驱动的 pipeline) +3. 核心模块逐个解剖(带文件+行号) +4. "GraphRAG" 噱头验证 +5. "71.5× token 节省" 真相拆解 +6. 设计亮点(8 个可抄点) +7. 技术短板(9 条) +8. **GitNexus vs Graphify 19 维对比表** +9. 最终建议 + +## 结论 + +Graphify 不是噱头,是一个**被过度营销的实用单项目 AST 索引工具**;"GraphRAG / 多模态 AI 架构助理" 是包装话术。 +**不要替换工作看板的 GitNexus** —— GitNexus 在代码静态分析维度比 Graphify 领先一个量级。 +可以从 Graphify 选抄 7 个细节(置信度标签 / SSRF 防护 / 论文识别等)增强 GitNexus。 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..9466523 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,43 @@ +server { + listen 80 default_server; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + charset utf-8; + + gzip on; + gzip_vary on; + gzip_min_length 1024; + gzip_comp_level 6; + gzip_types + text/plain + text/css + text/javascript + text/xml + application/javascript + application/json + application/xml + image/svg+xml; + + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + + location = /healthz { + access_log off; + add_header Content-Type text/plain; + return 200 "ok\n"; + } + + location / { + try_files $uri $uri/ /index.html; + add_header Cache-Control "public, max-age=300"; + } + + location ~* \.(css|js|svg|woff2?|ttf|otf|eot|png|jpe?g|gif|webp|ico)$ { + expires 7d; + add_header Cache-Control "public, max-age=604800, immutable"; + } +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..cf3dcd1 --- /dev/null +++ b/public/index.html @@ -0,0 +1,544 @@ + + + + + +Graphify 源码解析 & GitNexus 对比 · 2026-04-13 + + + +
+ +
+
源码评估报告
+

Graphify 全面解析 & GitNexus 替换评估

+
"看下这个项目是不是噱头 · 需不需要把工作看板的代码图谱换成这个"
+
+ 日期 2026-04-13 + Graphify v0.4.8 · 8,237 LOC · Python + GitNexus · 31,367 LOC · TypeScript + 仓库快照 ~/Projects/research/20260413-graphify-analysis/ +
+
+ +
+
结论
+
+ Graphify 不是噱头,是一个被过度营销的实用单项目 AST 索引工具,"GraphRAG / 多模态 AI 架构助理" 是包装话术。 + 但不要替换工作看板的 GitNexus —— GitNexus 在代码静态分析这一维度比 Graphify 领先一个量级。 +
+
+ + + +

一、Graphify 架构速览

+ +

一句话:tree-sitter AST 提取器 + networkx 图 + Leiden 社区检测 + 10 种导出格式 + 9 种 Agent 平台集成脚本。 +零 LLM 依赖,"智能"部分全部外包给宿主 Agent(Claude Code / Codex / OpenCode / ...)。

+ + + + + + + + + + + + + + + + + + + + + + + +
文件行数作用
extract.py2804tree-sitter AST 提取(22 语言)—— 真正的发动机
export.py1001HTML / SVG / GraphML / Cypher / Obsidian 导出
__main__.py972CLI + 9 种 AI 平台 install/uninstall 脚本
analyze.py537god nodes(度数排序)+ surprising connections(跨社区边)
detect.py502文件扫描 + 类型识别(含论文启发式)+ .graphifyignore
serve.py364MCP stdio server(7 个工具)
ingest.py297URL 抓取:twitter/arxiv/github/youtube/pdf/image/web
hooks.py198git post-commit/checkout 自动重建(纯 AST)
security.py197SSRF 防护 + URL 校验 + redirect 再验证
watch.py183文件监听,代码变更增量重建
transcribe.py182whisper 视频/音频转写(可选)
report.py175GRAPH_REPORT.md 生成
cache.py154SHA256 文件级缓存(markdown 剥 YAML frontmatter)
cluster.py137Leiden / Louvain 社区检测 + 大社区拆分
benchmark.py129token reduction 计算 —— 71.5× 来源
build.py87dict → networkx.Graph 组装
(其余小文件:validate / wiki / __init__ / manifest · 共 ~130 行)
合计8,23720 个 .py 文件 · MIT License · PyPI: graphifyy
+ +

依赖(全部本地库,无 LLM SDK)

+
# 核心
+networkx
+tree-sitter >= 0.23.0
+tree-sitter-{python,javascript,typescript,go,rust,java,c,cpp,ruby,
+             c-sharp,kotlin,scala,php,swift,lua,zig,powershell,
+             elixir,objc,julia}  # 22 种语言
+
+# 可选 extras
+mcp            # MCP server
+neo4j          # 直推图数据库
+pypdf          # PDF 文本提取
+graspologic    # Leiden(否则回落 Louvain)
+python-docx    # Office
+faster-whisper # 视频转写
+yt-dlp         # YouTube 下载
+ +

二、执行流程 & 关键发现

+ +
+

关键发现:完整 pipeline 不在 CLI 里

+

__main__.pymain() 只有 install / query / benchmark / save-result / hook 等子命令 + (__main__.py:780-968)—— 根本没有 "build graph" 子命令

+

完整 pipeline 是被 skill.md 驱动的:宿主 Agent 按 skill.md 的 step 1..N,用内联 + python3 -c "from graphify.X import Y" 挨个调各模块。这种"skill 脚本驱动"设计 + 把 LLM 部分合法地外包给宿主 Agent,Python 包就完全 offline。

+
+ +
# 实际执行顺序(由 skill.md 协调)
+detect.detect(root)                        # detect.py:329  扫描+分类
+  ↓ 并行
+  ├── extract.extract(code_paths)          # extract.py:2639  tree-sitter AST
+  └── [宿主 Agent subagent 读 PDF / 图 / markdown] → JSON
+cache.save_semantic_cache(...)             # cache.py:119
+build.build([ast_result, semantic_result]) # build.py:84
+cluster.cluster(G)                         # cluster.py:59  Leiden/Louvain
+analyze.god_nodes + surprising_connections # analyze.py:42/61
+report.generate(...)                       # report.py:14
+export.to_html / to_json / to_obsidian     # export.py:329/285/447
+ +

三、核心模块逐个解剖

+ +

3.1 extract.py(2804 行) —— 真正的发动机

+ +

架构模式:LanguageConfig dataclass(extract.py:24-60)+ 通用 +_extract_generic()(extract.py:645-1010)+ 每种语言一个配置实例 + 少数语言特有的 walker。

+ +
class LanguageConfig:
+    class_types        # 哪些 tree-sitter 节点类型算"类"
+    function_types     # 哪些算"函数"
+    import_types
+    call_types
+    name_field         # 默认从哪个 field 拿名字
+    body_field
+    function_boundary_types  # 递归到这里停
+    import_handler     # 每种语言 import 语法不一样,单独回调
+    resolve_function_name_fn # C/C++ 用 declarator 解包
+    extra_walk_fn      # JS 箭头、C# namespace 等特殊分支
+ +

13 种语言走通用路径(extract.py:419-627),7 种独立手写(因为 tree-sitter 节点命名差太大): +extract_go(190 行)extract_rust(168 行)extract_zig、 +extract_powershellextract_objcextract_elixirextract_julia

+ +

两遍 walk:

+
    +
  1. 结构 walk(extract.py:703-866):进 class 建节点 + contains/method/inherits 边;进 function 记下 body 挂到 function_bodies 列表
  2. +
  3. 调用图 walk(extract.py:877+):对每个 function body 再 walk,找 callee 名字,查 label_to_nidcalls
  4. +
+ +
+

亮点: Python 独有的 _resolve_cross_file_imports

+

extract.py:2110-2240,130 行 —— 整个项目 唯一真正跨文件推理的地方。

+

Pass 1:扫所有 Python 文件的 AST 节点,建 stem_to_entities[stem][ClassName] = nid 全局映射表。
+ Pass 2:对每个文件找 from .models import Response,在映射表里查到 Response 的 nid,然后对当前文件里的每个 class,添加 DigestAuth --uses--> Response 的 INFERRED 边。

+

这是"god nodes / surprising connections"最后能出东西的关键 —— 没这步,Python 项目全是 contains 边的垃圾。其他 21 种语言都没做这个,只有结构 + 同文件 calls。

+
+ +

3.2 detect.py(502 行) —— 文件扫描

+
    +
  • _looks_like_paper()(detect.py:68)用 13 条正则(arxiv / doi / \cite{} / \d{4}\.\d{4,5})判断一个 .md 是不是学术论文转出来的 —— 命中 ≥3 条升级为 PAPER
  • +
  • _SENSITIVE_PATTERNS(detect.py:33-40)过滤 .env / .pem / id_rsa / aws_credentials —— 默认不读密钥文件
  • +
  • _SKIP_DIRS(detect.py:238)自动跳 venv / node_modules / .git / dist / build
  • +
  • .graphifyignore 支持向上查找到 .git 目录为止(detect.py:266)
  • +
  • convert_office_file(detect.py:194)把 .docx / .xlsx 转 markdown sidecar,哈希命名避冲突
  • +
+ +

3.3 cache.py(154 行) —— SHA256 内容缓存

+
    +
  • file_hash = SHA256(content) ⊕ SHA256(resolved_path)(cache.py:20)—— 路径加进哈希防同内容碰撞
  • +
  • 贴心细节:Markdown 的 YAML frontmatter 会先剥离再哈希(cache.py:10-17),metadata 变更(reviewed/status/tags)不触发重抽取
  • +
  • 存成 graphify-out/cache/{hash}.json,os.replace 原子写
  • +
+ +

3.4 cluster.py(137 行) —— Leiden / Louvain

+
    +
  • 先试 graspologic.partition.leiden,失败 fallback 到 networkx.community.louvain_communities(cluster.py:22-52)
  • +
  • 孤立点(degree 0)Leiden 会 warning,单独抠出来每个自成一个社区(cluster.py:77-91)
  • +
  • 大社区限制 _MAX_COMMUNITY_FRACTION = 0.25:超过总节点 25% 的社区二次 Leiden 拆分(cluster.py:93)
  • +
  • 最后按 size 降序重编号 —— 社区 0 永远是最大的(可复现)
  • +
  • PowerShell 5.1 缓冲污染 workaround:graspologic 会吐 ANSI 转义,专门包了 redirect_stdout(cluster.py:11-20,issue #19)
  • +
+ +

3.5 analyze.py(537 行) —— "智能"层

+ +

其实都是 networkx 一行题

+ +

god_nodes(analyze.py:42)= dict(G.degree()) 排序,过滤掉文件节点 + concept 节点,取 top_n。 +所谓"god nodes" = 度数最高的真实实体。_is_file_node(analyze.py:11-38)过滤三类伪节点:文件级 hub、.method() 方法桩、孤立 func()

+ +

_surprise_score()(analyze.py:131-184)是一个朴素加权:

+
    +
  • 置信度加成:AMBIGUOUS +3 / INFERRED +2 / EXTRACTED +1
  • +
  • 跨文件类型(code↔paper/image)+2
  • +
  • 跨 repo(顶级目录不同)+2
  • +
  • 跨社区(Leiden 说结构上远)+1
  • +
  • semantically_similar_to 关系 ×1.5
  • +
  • 低度节点(≤2)连到高度节点(≥5)+1,生成 "peripheral → hub" 叙述
  • +
+ +

3.6 serve.py(364 行) —— MCP 服务器

+

暴露 7 个 MCP 工具:query_graphget_nodeget_neighborsget_communitygod_nodesgraph_statsshortest_path(serve.py:156-226)。

+ +
+

注意:"查询"不是语义搜索

+

_score_nodes(serve.py:42)就是把问题 split 成 >2 字符的词, + 在 label 里子串匹配 +1 / source_file +0.5,排序取 top3 当 BFS 起点。 + 没有 embedding、没有 BM25、甚至没有 stemming。对中英混合语料很不友好。

+
+ +

3.7 export.py(1001 行) —— 十种输出

+
    +
  • to_json / to_cypher / to_html(交互 vis.js 单文件)/ to_obsidian(每节点一 md,每社区一 hub,带 wikilinks)
  • +
  • to_canvas(Obsidian Canvas)/ push_to_neo4j(bolt 协议直推)/ to_graphml(Gephi/yEd)/ to_svg
  • +
  • MAX_NODES_FOR_VIZ = 5_000(export.py:19)—— 超过就不出 HTML
  • +
+ +

3.8 security.py(197 行) —— SSRF 防护

+

validate_url 解析 hostname → getaddrinfo → 拒绝 +is_private / is_reserved / is_loopback / is_link_local,加黑名单 metadata.google.internal +(security.py:14-64)。_NoFileRedirectHandler 重写 HTTPRedirectHandler, +每次 redirect 都重新校验一遍 —— 防 open-redirect SSRF。写一个抓取模块就自带这种层次的防护,不常见。

+ +

四、"GraphRAG" 噱头验证

+ +

"GraphRAG" 按微软原论文定义:LLM 抽实体 + LLM 抽关系 + LLM 写社区摘要 + 分层答案合成。Graphify 对齐情况:

+ + + + + + + + + + +
GraphRAG 环节Graphify 做法状态
LLM 抽实体tree-sitter AST(代码)/ 宿主 Agent subagent(非代码)
LLM 抽关系AST + 字符串 heuristics
社区检测Leiden / Louvain
LLM 写社区摘要只有 label 模板,宿主 Agent 可能帮忙写
分层答案合成BFS + term-frequency 子串匹配
+ +

结论:这不是 GraphRAG,是"一个有置信度标签的 tree-sitter 代码图谱工具 + Obsidian 导出器 + 9 个 Agent 平台的 SKILL.md 胶水"。 +技术本身合格(8k LOC 大部分在 extract.py 真的干活),但把它叫 "GraphRAG AI 架构助理" 是营销话术。

+ +

五、"71.5× token 节省" 真相

+ +

拆开 benchmark.py 看(benchmark.py:1-130):

+ +
_CHARS_PER_TOKEN = 4
+corpus_tokens   = corpus_words * 100 // 75   # 1 词 ≈ 1.33 token
+query_tokens    = BFS 子图渲染文本长度 // 4
+reduction_ratio = corpus_tokens / avg(query_tokens of 5 个固定英文问题)
+
+# 5 个固定问题(benchmark.py:55-61)
+"how does authentication work"
+"what is the main entry point"
+"how are errors handled"
+"what connects the data layer to the api"
+"what are the core abstractions"
+ +
+

71.5× 是怎么来的

+

= "整个语料的 token 数" 除以 "单次 BFS 子图的 token 数"。不包含建图时烧掉的 subagent token

+

代码库很好看(AST 零 token + 后续查询便宜),对论文/截图混合语料有水分 —— 首次建图那一次 PDF subagent 读取的 token 会把 ratio 稀释。

+

而且固定 5 个英文问题 + 子串匹配选起点 —— 换一个中文项目可能选不到起点直接返回 0。

+
+ +

六、设计亮点(这些可以抄)

+ +
+
+

1. LanguageConfig 模式

+

extract.py:24。通用 walker + 每语言差异填配置。13 种语言共用 200 行通用代码。

+
+
+

2. SHA256 内容缓存 + Markdown 剥 frontmatter

+

cache.py:20。"改 metadata 不触发重抽取"这种细节。

+
+
+

3. 三档置信度 + score

+

每条边打 EXTRACTED/INFERRED/AMBIGUOUS,INFERRED 再带 0.6-0.95 的 confidence_score,报告里直接出现 "avg confidence: 0.78",诚实度拉满

+
+
+

4. Python 跨文件 class 级 uses 边

+

extract.py:2110。让 god nodes 变得有意义的关键。

+
+
+

5. 单 HTML 交互图

+

export.py:329。内嵌 vis.js,无需服务器,发一个文件给客户直接看。

+
+
+

6. 9 平台集成脚本

+

__main__.py:49-105。Claude/Codex/Cursor/OpenCode/Aider/Copilot/OpenClaw/Factory/Trae/Antigravity/Gemini。

+
+
+

7. SSRF 防护默认打开

+

security.py:14-64。默认写一个 URL 抓取模块就有这种层次的防护,业界少见。

+
+
+

8. 大社区自动拆分

+

cluster.py:93。>25% 超大社区二次 Leiden 拆,防退化。

+
+
+ +

七、技术短板

+ +
    +
  1. 22 语言"支持"很不均匀:只有 Python 做了跨文件 uses 推断,其他 21 种只有"同文件级 calls + imports"。多语言 polyglot 项目图质量会肉眼可见不如 Python。
  2. +
  3. _extract_python_rationale(extract.py:1011)基于 docstring 的 "X because Y" heuristics 脆得很。
  4. +
  5. 查询不是语义搜索,是子串 +1/+0.5 打分,没有 embedding/BM25/stemming。中英混合语料不友好。
  6. +
  7. _make_idre.sub(r"[^a-zA-Z0-9]+", "_", combined)(extract.py:14)—— 对中文/非 ASCII 标识符直接 collapse 成空串,中文代码库识别不了
  8. +
  9. C++ 模板/宏、Python metaclass/装饰器动态类、JS Proxy/Reflect 这类 AST 看不穿的东西通通识别不出来 —— 本质上是静态结构提取。
  10. +
  11. benchmark 的 71.5×:固定 5 个英文问题 + 子串匹配选起点。
  12. +
  13. 无类型系统:没有 symbol table、没有 type env、没有方法解析顺序(MRO)。
  14. +
  15. _is_file_node 启发式(analyze.py:11-38)在非 Python 语言下容易误伤 —— Go/Rust 函数都是 () 结尾,又按 degree 判断……补丁摞补丁。
  16. +
  17. PyPI 包名 graphifyy(两个 y,因为 graphify 被占),看得出作者赶时间。
  18. +
+ +

八、GitNexus vs Graphify 对比

+ +

你的工作看板现在用的是 ~/Projects/code/20260319-gitnexus/(来源 abhigyanpatwari/GitNexus,17.8k stars,浏览器端 WASM 方案)。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
维度GitNexus(你已有)Graphify
代码规模31,367 行 TypeScript8,237 行 Python
架构浏览器 WASM 零服务器
Tree-sitterLadybugDBSigma.js
Python CLI + networkx 内存图
图数据库LadybugDB(Cypher 查询)JSON 文件
类型系统symbol-table.ts + type-env.ts + type-extractors/ —— 真的做类型推导
Python MROmro-processor.ts —— 方法解析顺序
框架识别framework-detection.ts
入口打分entry-point-scoring.ts
跨文件 resolverresolvers/ + resolution-context.ts + named-binding-extraction.ts只有 Python 做了 130 行
社区检测Leiden + cluster-enricher.tsLeiden/Louvain
可视化Sigma.js Web UI @ 4090单 HTML + vis.js
多项目面板Web UI 常驻每项目一目录,一次性
MCP Servergitnexus/src/mcp/serve.py(7 工具)
非代码输入(PDF/图/视频)支持(外包给 subagent)
Obsidian 导出有(每节点一 md + 社区 hub)
Agent 平台集成Claude plugin + Cursor integration9 种平台
诚信度标签未知EXTRACTED/INFERRED/AMBIGUOUS 三档
LLM 依赖LangChain + 多家 LLM(可选增强)无硬依赖(委托宿主 Agent)
+ +
+

GitNexus 的 gitnexus/src/core/ingestion/ 目录(一瞥)

+
ast-cache.ts           call-processor.ts         call-routing.ts
+cluster-enricher.ts    community-processor.ts    entry-point-scoring.ts
+export-detection.ts    filesystem-walker.ts      framework-detection.ts
+heritage-processor.ts  import-processor.ts       language-config.ts
+mro-processor.ts       named-binding-extraction.ts
+parsing-processor.ts   pipeline.ts               process-processor.ts
+resolution-context.ts  structure-processor.ts    symbol-table.ts
+tree-sitter-queries.ts type-env.ts               type-extractors/
+resolvers/             workers/
+

光是 ingestion 里就有 20+ 个处理器。在代码静态分析这件事上 GitNexus 已经把 Graphify 吊打了

+
+ +

九、最终建议

+ +
+

不要替换

+

GitNexus 在代码静态分析维度领先 Graphify 一个量级:真类型系统、MRO、框架识别、入口打分、完整 resolver —— 这些 Graphify 全都没有。 + 替换过去你会失去跨项目 Web UI、看板集成、浏览器 WASM 零服务器架构,换来的只是一套更弱的单项目 AST 抽取和几个你不需要的 Obsidian 模板。

+
+ +
+

保持现状,按需并用

+

GitNexus 继续作为工作看板代码图谱主干,Graphify 作为偶尔跑一次的单项目深度报告工具(需要 Karpathy 式 /raw 混合语料场景时)。两者并不冲突。

+
+ +
+

可以从 Graphify 借鉴的东西(选抄)

+
    +
  1. 三档置信度 EXTRACTED/INFERRED/AMBIGUOUS + confidence_score —— 给 GitNexus 的边也加上,报告诚实度立即拉满
  2. +
  3. Markdown 剥 YAML frontmatter 再哈希(cache.py:10-17)—— 细节体验
  4. +
  5. 论文启发式识别 _looks_like_paper(detect.py:68)—— 13 条正则,简单有效
  6. +
  7. 敏感文件过滤 _SENSITIVE_PATTERNS(detect.py:33-40)—— 安全默认值
  8. +
  9. SSRF 防护整套(security.py:14-90)—— 如果 GitNexus 要加 URL 抓取功能直接移植
  10. +
  11. 大社区 25% 拆分规则(cluster.py:93)—— 防 Leiden 出一个超大社区
  12. +
  13. ingest.py 的 URL 分类抓取(297 行:twitter/arxiv/github/youtube/pdf/image/web)—— 给 GitNexus 补非代码输入时有现成逻辑
  14. +
+
+ +
+

下一步(如果你感兴趣)

+

我可以继续深入看 GitNexus 的 gitnexus/src/core/ingestion/pipeline.ts 和 + type-extractors/,给你出一份 "GitNexus 现状 + 可增强点" 的专门评估 —— 这份评估完成后, + 决定要不要把上述 Graphify 的借鉴项真正落到 GitNexus 里。

+
+ + + +
+ +