elbruno/graphify-dotnet

GitHub: elbruno/graphify-dotnet

一个将代码库自动转化为交互式知识图谱的 .NET CLI 工具,通过 AST 解析与可选 AI 语义分析揭示代码中的潜在结构与概念关系。

Stars: 88 | Forks: 13

# graphify-dotnet [![CI Build](https://static.pigsec.cn/wp-content/uploads/repos/cas/39/39f45000ced5988832c0d6562d09ca899eb32007638fd6ccd8cae52ad6645caf.svg)](https://github.com/elbruno/graphify-dotnet/actions/workflows/build.yml) [![Publish](https://static.pigsec.cn/wp-content/uploads/repos/cas/c7/c749dceae7d596bdcb5b4fb6e6727dec694b270cd48bb4448fe8d2a803c8b10f.svg)](https://github.com/elbruno/graphify-dotnet/actions/workflows/publish.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![GitHub stars](https://img.shields.io/github/stars/elbruno/graphify-dotnet?style=social)](https://github.com/elbruno/graphify-dotnet/stargazers) 🔍 **从任何代码库构建 AI 驱动的知识图谱。** 发现你未曾察觉的潜在结构。 graphify-dotnet 会读取你的文件(代码、文档、图像),通过 AST 解析和 AI 语义分析提取概念与关系,利用社区检测算法构建知识图谱,并导出交互式可视化结果。通过结构而非关键词搜索来浏览代码库。 ## 快速开始 ### 1. 安装 ``` dotnet tool install -g graphify-dotnet ``` ### 2. 配置 ``` graphify config ``` 这将启动一个交互式向导,包含三个选项: - **📋 查看当前配置** — 查看已设置的选项 - **🔧 设置 AI provider** — 选择 Azure OpenAI、Ollama、Copilot SDK 或 None(仅使用 AST) - **📂 设置要分析的文件夹** — 设置你的默认项目文件夹和导出格式 选择你的 AI provider(或者跳过这一步——仅使用 AST 的提取无需任何配置即可工作),然后设置要分析的文件夹。 ### 3. 运行 ``` graphify run ``` 大功告成。在浏览器中打开 `graphify-out/graph.html` 即可探索交互式图谱。 ## 支持的语言 graphify 可以检测并从以下文件类型中提取结构: | 类别 | 语言 | |----------|-----------| | **代码** | C#, Python, TypeScript, JavaScript, Go, Rust, Java, C, C++, Ruby, Kotlin, Scala, PHP, Swift, R, Lua, Shell, PowerShell | | **配置** | YAML, JSON, TOML, XML | | **文档** | Markdown, Plain Text, reStructuredText, AsciiDoc | | **媒体** | PDF, PNG, JPEG, WebP, GIF, SVG | **没有 AI provider?没问题。** 仅使用 AST 的提取无需配置即可工作,并能从代码中生成结构化的图谱——类、函数、导入及其关系。AI provider 可以添加语义提取(概念连接、推断出的关系),但它们完全是可选的。 ## 从源码构建 ``` git clone https://github.com/elbruno/graphify-dotnet.git cd graphify-dotnet dotnet build graphify-dotnet.slnx dotnet run --project src/Graphify.Cli -- run . ``` ## NuGet 包 | 包名 | 用途 | 版本 | 下载量 | |---------|---------|---------|-----------| | [`graphify-dotnet`](https://www.nuget.org/packages/graphify-dotnet) | .NET 全局工具(`graphify`) | [![NuGet](https://img.shields.io/nuget/v/graphify-dotnet.svg?style=flat-square)](https://www.nuget.org/packages/graphify-dotnet) | [![Downloads](https://img.shields.io/nuget/dt/graphify-dotnet.svg?style=flat-square)](https://www.nuget.org/packages/graphify-dotnet) | | [`graphify-dotnet-core`](https://www.nuget.org/packages/graphify-dotnet-core) | 核心图谱提取与 pipeline 库 | [![NuGet](https://img.shields.io/nuget/v/graphify-dotnet-core.svg?style=flat-square)](https://www.nuget.org/packages/graphify-dotnet-core) | [![Downloads](https://img.shields.io/nuget/dt/graphify-dotnet-core.svg?style=flat-square)](https://www.nuget.org/packages/graphify-dotnet-core) | | [`graphify-dotnet-sdk`](https://www.nuget.org/packages/graphify-dotnet-sdk) | Copilot/AI SDK 集成库 | [![NuGet](https://img.shields.io/nuget/v/graphify-dotnet-sdk.svg?style=flat-square)](https://www.nuget.org/packages/graphify-dotnet-sdk) | [![Downloads](https://img.shields.io/nuget/dt/graphify-dotnet-sdk.svg?style=flat-square)](https://www.nuget.org/packages/graphify-dotnet-sdk) | ## 文档 | 主题 | 链接 | |-------|------| | **入门指南** | [docs/getting-started.md](docs/getting-started.md) | | **架构** | [ARCHITECTURE.md](ARCHITECTURE.md) | | **配置** | [docs/configuration.md](docs/configuration.md) | | **CLI 参考** | [docs/cli-reference.md](docs/cli-reference.md) | | **实战示例** | [docs/worked-example.md](docs/worked-example.md) | | **故障排除** | [docs/troubleshooting.md](docs/troubleshooting.md) | | | | | **AI Provider** | | |   Azure OpenAI | [docs/setup-azure-openai.md](docs/setup-azure-openai.md) | |   Ollama | [docs/setup-ollama.md](docs/setup-ollama.md) | |   Copilot SDK | [docs/setup-copilot-sdk.md](docs/setup-copilot-sdk.md) | | | | | **导出格式** | [docs/export-formats.md](docs/export-formats.md) | |   HTML 交互式 | [docs/format-html.md](docs/format-html.md) | |   JSON | [docs/format-json.md](docs/format-json.md) | |   SVG | [docs/format-svg.md](docs/format-svg.md) | |   Neo4j Cypher | [docs/format-neo4j.md](docs/format-neo4j.md) | |   Ladybug | [docs/format-ladybug.md](docs/format-ladybug.md) | |   Obsidian Vault | [docs/format-obsidian.md](docs/format-obsidian.md) | |   Wiki | [docs/format-wiki.md](docs/format-wiki.md) | |   报告 | [docs/format-report.md](docs/format-report.md) | | | | | **其他** | | |   Watch 模式 | [docs/watch-mode.md](docs/watch-mode.md) | |   全局工具安装 | [docs/dotnet-tool-install.md](docs/dotnet-tool-install.md) | ## 许可证 本项目基于 MIT 许可证授权。详情请参阅 [LICENSE](LICENSE) 文件。 ## 鸣谢 - [Andrej Karpathy 的推文](https://x.com/karpathy/status/2039805659525644595),关于 LLM 驱动的个人知识库 —— 这是开启这一系列想法的最初灵感。 - @socialwithaayan 发布的 [这条推文](https://x.com/socialwithaayan/status/2041192946369007924),展示了由 @safishamsi 开发的 [graphify](https://github.com/safishamsi/graphify) —— 这直接启发了本 .NET 移植版本的诞生。 本项目是 [safishamsi/graphify](https://github.com/safishamsi/graphify) 的 .NET 10 移植版,结合了 C# 惯用法、.NET 10 特性以及 Microsoft.Extensions.AI 抽象层进行了重新设计。
标签:AI风险缓解, AST解析, 人工智能, 代码分析, 凭证管理, 用户模式Hook绕过