Slambot01/CNI_ATLAS

GitHub: Slambot01/CNI_ATLAS

本地优先的代码库依赖分析工具,结合图计算与本地大模型让开发者用自然语言理解和探索大型代码库。

Stars: 0 | Forks: 0

# CNI — Codebase Neural Interface 像与一个鲜活的系统对话一样,与你的整个代码库进行交流。 ## 功能 | 命令 | 描述 | | -------------- | -------------------------------------------------------------- | | `cni analyze` | 扫描代码库,构建依赖关系图,并打印统计信息。 | | `cni graph` | 构建并展示代码库的依赖关系图。 | | `cni path` | 查找两个文件之间的最短依赖路径。 | | `cni explain` | 解释某个文件在依赖关系图中的作用。 | | `cni ask` | 用自然语言询问关于代码库的问题(通过 LLM)。 | ## 安装 ``` # 克隆 repo git clone https://github.com/Slambot01/CNI_ATLAS.git cd CNI_ATLAS # 以 editable mode 安装 pip install -e . ``` ### Ollama (`cni ask` 必需) CNI 使用 [Ollama](https://ollama.com/) 进行本地 LLM 推理。 ``` # 安装 Ollama (see https://ollama.com/download) # 启动 server ollama serve # Pull 默认 model ollama pull qwen2.5-coder:7b ``` ## 配置 ### 缓存 CNI 将扫描结果缓存在 `/.cni/cache.json` 中。 该缓存存储了已扫描的文件路径、依赖关系边以及文件 修改时间戳。 **要清除缓存**,只需删除该文件: ``` rm -rf .cni/ ``` 下一次运行 `cni analyze` 时将执行完整重新扫描。 ## 用法 ### Analyze ``` $ cni analyze . Analyzing repository... Files scanned: 12 Dependency graph built. Repository statistics ------------------------------ Files indexed : 12 Dependencies : 8 Isolated files : 3 Most imported : 4 dependents ``` ### Graph ``` $ cni graph . Building dependency graph... Files scanned: 12 Dependency graph built. Repository statistics ------------------------------ Files indexed : 12 Dependencies : 8 Isolated files : 3 Most imported : 4 dependents ``` ### Path ``` $ cni path cni/cli/main.py cni/graph/graph_builder.py Scanning repository... Building dependency graph... Searching dependency path... main.py → graph_builder.py ``` ### Explain ``` $ cni explain graph_builder.py Scanning repository... Building dependency graph... Analyzing file... File: graph_builder.py Imports: repo_scanner.py Imported by: main.py ``` ### Ask ``` $ cni ask "What does repo_scanner do?" Scanning repository... Building dependency graph... Retrieving relevant context... Querying LLM... repo_scanner.py recursively walks a directory tree and collects all Python (.py), JavaScript (.js), and TypeScript (.ts) source files, skipping common non-source directories like .git and node_modules. ``` ## 示例输出 生成一个演示依赖关系图: ``` python docs/generate_demo.py ``` ![依赖关系图](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/a604a7d550010720.png) ## 项目结构 ``` cni/ ├── __init__.py ├── cli/ │ ├── __init__.py │ └── main.py # Typer CLI entrypoint ├── analyzer/ │ ├── __init__.py │ └── repo_scanner.py # Repository file scanner ├── graph/ │ ├── __init__.py │ ├── graph_builder.py # Dependency graph builder │ └── export.py # Graphviz export with clustering ├── analysis/ │ ├── __init__.py │ ├── path_finder.py # Shortest dependency path │ └── explainer.py # File-level dependency explainer ├── retrieval/ │ ├── __init__.py │ ├── semantic_search.py # Sentence-transformer semantic search │ └── context_builder.py # LLM context builder ├── llm/ │ ├── __init__.py │ └── llm_client.py # Ollama LLM client └── storage/ ├── __init__.py └── cache.py # JSON-based scan cache docs/ └── generate_demo.py # Demo graph generation script pyproject.toml README.md ```
标签:AI风险缓解, ATLAS, CNI, DLL 劫持, Homebrew安装, LLM评估, Ollama, Python, SOC Prime, 云安全监控, 人工智能, 代码分析, 代码助手, 代码库理解, 代码搜索, 依赖图, 凭证管理, 图计算, 大语言模型, 开发工具, 开源, 数据管道, 无后门, 本地优先, 用户模式Hook绕过, 网络安全, 网络调试, 自动化, 自定义脚本, 自然语言查询, 软件工程, 逆向工具, 配置错误检测, 隐私保护, 零数据泄露, 静态分析