giauphan/CodeAtlas

GitHub: giauphan/CodeAtlas

一款为多 IDE 提供持久化记忆与 MCP 工具链的 AI 代码分析平台,解决上下文丢失与代码理解成本高的问题。

Stars: 0 | Forks: 0

# 🗺️ CodeAtlas **为 VS Code、Cursor、Windsurf 提供的 AI 驱动代码分析与记忆工具** [![Version](https://img.shields.io/badge/version-1.6.0-blue)](https://github.com/giauphan/CodeAtlas/releases) [![VS Code](https://img.shields.io/badge/VS%20Code-v1.80%2B-blue?logo=visualstudiocode)](https://marketplace.visualstudio.com/) [![npm](https://img.shields.io/npm/v/@giauphan/codeatlas-mcp?label=MCP%20Server&logo=npm)](https://www.npmjs.com/package/@giauphan/codeatlas-mcp) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/giauphan/CodeAtlas/actions) [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) ## ✨ 为什么选择 CodeAtlas? | 问题 | CodeAtlas 解决方案 | |---|---| | AI 每次对话都会忘记你的项目结构 | 在 `.agents/memory/` 中提供**持久化记忆** | | AI 盲目地 grep 文件,忽略了代码间的关系 | 提供 **10 个 MCP 工具**实现即时代码智能 | | 无法查看功能是如何在代码中流转的 | 生成表示执行流程的 **Mermaid 图表** | | 难以上手新代码库 | **自动生成架构映射图** | | 不同的 AI IDE 需要不同的配置 | 为 Cursor、Claude、Windsurf、Gemini **自动生成规则** | ## 🚀 快速开始(2 分钟) ### 步骤 1:安装扩展 从 [Releases](https://github.com/giauphan/CodeAtlas/releases) 下载 `codeatlas-1.6.0.vsix`,然后执行: ``` VS Code: Extensions → ⋯ → Install from VSIX ``` ### 步骤 2:分析你的项目 ``` Ctrl+Shift+P → CodeAtlas: Analyze Project ``` 该操作将生成: - `.codeatlas/analysis.json` — 代码结构数据 - `.agents/memory/` — AI 可读的系统文档 - `.agents/rules/` — 面向 AI 的 MCP 指令 - 适用于 **Cursor** / **Claude** / **Windsurf** 的特定 IDE 规则(自动检测) ### 步骤 3:连接你的 AI 选择你的 AI IDE 并添加 MCP 配置:
🟢 Gemini / Antigravity.gemini/settings.json ``` { "mcpServers": { "codeatlas": { "command": "npx", "args": ["-y", "@giauphan/codeatlas-mcp"] } } } ```
Cursor.cursor/mcp.json ``` { "mcpServers": { "codeatlas": { "command": "npx", "args": ["-y", "@giauphan/codeatlas-mcp"] } } } ```
🔵 VS Code Copilot.vscode/settings.json ``` { "mcp": { "servers": { "codeatlas": { "command": "npx", "args": ["-y", "@giauphan/codeatlas-mcp"] } } } } ```
🟣 Claude Desktopclaude_desktop_config.json ``` { "mcpServers": { "codeatlas": { "command": "npx", "args": ["-y", "@giauphan/codeatlas-mcp"] } } } ```
🟣 Claude Code CLI ``` claude mcp add codeatlas -- npx -y @giauphan/codeatlas-mcp ```
🔴 Windsurf.windsurf/mcp.json ``` { "mcpServers": { "codeatlas": { "command": "npx", "args": ["-y", "@giauphan/codeatlas-mcp"] } } } ```
## 🛠️ MCP 工具(10 个工具) ### 代码分析 | 工具 | 功能 | |------|-------------| | `list_projects` | 列出所有已分析的项目(自动发现 `~/`) | | `get_project_structure` | 获取所有模块、类、函数、变量 | | `get_dependencies` | 获取 import / call / containment / implements 关系 | | `get_insights` | AI 生成的代码质量与安全洞察 | | `search_entities` | 按实体名称进行模糊搜索(比 grep 更快!) | | `get_file_entities` | 获取指定文件中定义的所有实体 | ### 架构可视化 | 工具 | 功能 | |------|-------------| | `generate_system_flow` | 自动生成 Mermaid **架构图**(模块导入) | | `generate_feature_flow_diagram` | 自动生成 Mermaid **执行流程图**(调用链) | ### AI 记忆 | 工具 | 功能 | |------|-------------| | `sync_system_memory` | 创建/更新 `.agents/memory/` — AI 的持久化长期记忆 | | `trace_feature_flow` | 在代码库中追踪某个功能,按依赖顺序返回相关文件 | ## 🧠 AI 记忆系统 AI 助手在对话之间会丢失上下文。CodeAtlas 解决了这个问题: ``` Conversation 1 → AI writes code → calls sync_system_memory │ .agents/memory/ ├── system-map.md ← Mermaid architecture ├── modules.json ← All modules & entities ├── conventions.md ← Code patterns & style ├── business-rules.json ← Domain logic ├── feature-flows.json ← Feature traces └── change-log.json ← What changed & when │ Conversation 2 → AI reads .agents/memory/ → knows full system flow instantly ``` ### 自动生成的 IDE 规则 在执行 `Analyze Project` 时,CodeAtlas 会自动创建规则文件,让你的 AI **开箱即用,知道如何使用 CodeAtlas**: | 生成的文件 | 适用于 | |---|---| | `.agents/rules/codeatlas-mcp.md` | 通用(所有 AI) | | `.agents/rules/auto-memory.md` | 记忆读取/同步指令 | | `.cursor/rules/codeatlas.mdc` | Cursor | | `CLAUDE.md` | Claude Code | | `.windsurfrules` | Windsurf | ## 🌐 VS Code 扩展功能 - **交互式力导向图** — 可视化代码架构与依赖关系 - **基于 AST 的分析** — 深度的语义理解,而不仅仅是文本匹配 - **AI Copilot Chat** — 询问有关代码库的架构问题 - **实体概览** — 清晰展示模块、类、函数和关系的数量 - **点击导航** — 从图节点跳转到源码 - **保存时自动重新分析** — 图表随你的代码编写实时更新 - **搜索与过滤** — 查找特定实体,按类型过滤 ## 🌍 支持的语言 | 语言 | 解析器 | 功能 | |----------|--------|----------| | TypeScript / JavaScript | `@typescript-eslint/typescript-estree` | 完整 AST:imports、classes、functions、variables、calls、implements | | Python | 基于正则表达式 | classes、functions、variables、imports、calls | | PHP | 基于正则表达式 | classes、interfaces、traits、enums、functions、properties、constants | | Blade Templates | 基于正则表达式 | `@extends`、`@include`、`@component`、`` | ## 🏗️ 架构 ``` graph LR A[VS Code Extension] -->|Analyze| B(AST Parser) B -->|Graph Data| C[.codeatlas/analysis.json] C -->|Read| D[MCP Server] D -->|10 Tools| E[AI Assistants] E -->|sync_system_memory| F[.agents/memory/] F -->|Read at start| E A -->|Auto-generate| G[IDE Rules] G -->|.cursor / CLAUDE.md / .windsurfrules| E A -->|Render| H[React Webview UI] H -->|Graph| I((react-force-graph-2d)) ``` ## 📦 技术栈 | 组件 | 技术 | |---|---| | 扩展宿主 | VS Code API、TypeScript | | AST 解析器 | `@typescript-eslint/typescript-estree`、Python 和 PHP 正则表达式 | | MCP Server | `@modelcontextprotocol/sdk`、Zod | | Webview UI | React、Vite | | 关系图 | `react-force-graph-2d` | | CI | GitHub Actions | | 构建 | `esbuild`、`tsc`、`vsce` | ## License [MIT](LICENSE) — 个人和商业用途均可免费使用。
标签:IDE插件, MCP服务器, SOC Prime, 上下文记忆, 人工智能, 代码分析, 代码生成图, 凭证管理, 开发工具, 用户模式Hook绕过, 自动化攻击