
AngelosZou/graphlint
42最近提交 2026年8月15日
graphlint DSH 插件
Graphlint 通过分析依赖图检测不可达的死代码。它支持 Python、Rust、C#、TypeScript/JavaScript,并具备语言特定的感知能力。提供 CLI、Python API 以及用于 AI 代理集成的 DSH 插件。
如何安装 graphlint DSH 插件
dsh plugin --profile web add dsh-graphlint复制不会执行命令。安装 graphlint DSH 插件前请核对仓库和版本。
graphlint DSH 插件数据来源
graphlint DSH 插件快照日期:2026年8月16日
discovered
graphlint DSH 插件能做什么
- 通过图遍历检测死代码
- 多语言支持(Python、Rust、C#、TypeScript/JavaScript)
- 35+ 内置入口点检测规则,支持自定义规则
- 11 种警告类型,包括循环引用、未使用导入、只写变量
- 增量更新,实现高效重新索引
graphlint DSH 插件适合哪些场景
- 清理AI生成代码库中的死代码,减少上下文窗口污染
- CI 流水线集成,通过 --fail-on 退出码实现自动化质量门禁
- AI 代理自我清理,自动分析并移除不可达代码
- 使用 --public-as-entry 进行库分析,将所有公共项视为入口点
graphlint DSH 插件适合谁
- 使用 LLM 编码代理的 AI 开发者
- 维护大型代码库的软件工程师,尤其是 AI 辅助代码生成场景
- 将代码质量检查集成到 CI/CD 流水线中的 DevOps 工程师
graphlint DSH 插件的限制
- 仅静态分析;无法检测运行时链接(如 getattr 或 importlib),可能导致误报
- Python 的动态导入机制在重度运行时驱动的代码库中可能产生误报,需自定义入口规则
graphlint DSH 插件的仓库 README 摘录
以下文字摘自 graphlint DSH 插件的上游仓库 AngelosZou/graphlint 的 README,版权归原作者,仅作引用。
**Dead code detection for AI-generated codebases.** AI agents generate code rapidly, leaving behind dead and redundant code that pollutes the LLM's context window and dilutes attention. Graphlint analyzes your codebase's dependency graph to identify entry points and **detect dead code** — components unreachable from any entry point — so agents can self-clean and keep the codebase lean. ## Supported Languages | Language | Status | Parser | Features | |----------|--------|--------|----------| | **Python** (`.py`) | Built-in | `ast` (stdlib) | Decorators, type annotations, dynamic imports, framework-aware entry detection | | **Rust** (`.rs`) | Built-in (opt-in deps) | `tree-sitter` | Attribute macros, traits, `pub` visibility, `macro_rules!` | | **C#** (`.cs`) | Built-in (opt-in deps) | `tree-sitter` | Partial classes, properties/indexers/events, attributes, `.csproj` awareness, test framework entries | | **TypeScript / JavaScript** (`.ts` `.tsx` `.js` `.jsx` `.mts` `.cts` `.mjs` `.cjs`) | Built-in (opt-in deps) | `tree-sitter` | JSX/React components, Next.js pages, NestJS decorators, Jest/Vitest tests, import/export analysis | Install optional language support: ```bash pip insta
阅读完整 README仓库许可: MIT
graphlint DSH 插件常见问题
如何安装 Graphlint 的 DSH 插件?
在终端中运行 `dsh plugin --profile web add dsh-graphlint`,然后重启 DSH web。你也可以克隆仓库,在 integrations/dsh 目录下执行 `npm install && npm run build`,然后使用 `dsh plugin --profile web add link:./integrations/dsh` 链接本地构建。
Graphlint 支持哪些语言?
Graphlint 支持 Python(内置,使用 stdlib ast)、Rust、C#、TypeScript 和 JavaScript。Rust、C# 和 TypeScript/JavaScript 需要安装可选的 tree-sitter 依赖:`pip install graphlint[rust]`、`graphlint[csharp]` 或 `graphlint[typescript]`。
如何检测项目中的死代码?
在项目目录中运行 `graphlint query --warn-types dead_code`。如需 JSON 输出,添加 `--json`。你也可以使用 Python API:`from graphlint.api import query; result = query(warn_types='dead_code', json_output=True)`。
能否为我的框架添加自定义入口点?
可以,Graphlint 支持可配置的入口模板。你可以在 `.graphlint/config.json` 中添加自定义规则,使用 `function_call:`、`function_def:`、`decorator:`、`file_match:` 等模式。详情请参阅文档。
Graphlint 有哪些限制?
Graphlint 仅进行静态分析,无法检测运行时链接(如 `getattr` 或 `importlib`),可能导致误报。Python 的动态导入尤其具有挑战性。此外,它对 Rust 的宏展开支持有限,并且可能遗漏 C# 中仅通过反射调用的成员。