codegraph-gen 0.2.0__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/PKG-INFO +26 -28
  2. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/README.md +23 -26
  3. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/pyproject.toml +3 -3
  4. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/__main__.py +3 -3
  5. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/writer.py +3 -3
  6. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/__init__.py +0 -0
  7. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/ai.py +0 -0
  8. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/analyzer.py +0 -0
  9. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/builder.py +0 -0
  10. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/cluster.py +0 -0
  11. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/config.py +0 -0
  12. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/detect.py +0 -0
  13. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/engine.py +0 -0
  14. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/__init__.py +0 -0
  15. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/base.py +0 -0
  16. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/cpp.py +0 -0
  17. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/go.py +0 -0
  18. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/javascript.py +0 -0
  19. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/kotlin.py +0 -0
  20. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/python.py +0 -0
  21. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/rust.py +0 -0
  22. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/parser/swift.py +0 -0
  23. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/py.typed +0 -0
  24. {codegraph_gen-0.2.0 → codegraph_gen-1.0.0}/src/codegraph_gen/renderer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: codegraph-gen
3
- Version: 0.2.0
3
+ Version: 1.0.0
4
4
  Summary: AST-based codebase knowledge graph generator in Markdown
5
5
  Keywords: knowledge-graph,ast,codebase,markdown,tree-sitter,visualization,static-analysis,ai-agent,obsidian
6
6
  Author: twn39
@@ -10,6 +10,7 @@ Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Intended Audience :: Developers
11
11
  Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
13
14
  Classifier: Programming Language :: Python :: 3.12
14
15
  Classifier: Topic :: Software Development :: Code Generators
15
16
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -27,23 +28,30 @@ Requires-Dist: pydantic>=2.0.0
27
28
  Requires-Dist: tree-sitter-c>=0.24.2
28
29
  Requires-Dist: tree-sitter-cpp>=0.23.4
29
30
  Requires-Dist: tree-sitter-kotlin>=1.1.0
30
- Requires-Python: >=3.12
31
+ Requires-Python: >=3.11
31
32
  Project-URL: Homepage, https://github.com/twn39/codegraph
32
33
  Project-URL: Repository, https://github.com/twn39/codegraph
33
34
  Project-URL: Issues, https://github.com/twn39/codegraph/issues
34
35
  Description-Content-Type: text/markdown
35
36
 
36
- # codegraph
37
+ <h1 align="center">codegraph-gen</h1>
37
38
 
38
- `codegraph` 是一个面向 AI Agent(如 Antigravity、Codex、Claude Code 等)的静态代码知识图谱生成工具。它能够静态解析多语言 codebase,通过社区发现算法自动进行组件聚类,并导出为由标准 Markdown 文件组成的关联图谱库(Obsidian-like vault),极大地辅助 AI Agent 在本地进行精准的架构理解、逻辑导航与深度洞察分析。
39
+ <p align="center">
40
+ <a href="https://pypi.org/project/codegraph-gen/"><img src="https://img.shields.io/pypi/v/codegraph-gen.svg" alt="PyPI Version"></a>
41
+ <img src="https://img.shields.io/badge/python-3.11+-blue.svg" alt="Python Version">
42
+ <img src="https://img.shields.io/badge/code%20style-ruff-26b22f.svg" alt="Ruff">
43
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License">
44
+ </p>
39
45
 
40
- 与基于图形化 Canvas 渲染的知识图谱不同,`codegraph` 采用全 Markdown 的扁平结构存储。它专门为 LLM 设计,摒弃了昂贵且复杂的数据库依赖,让 AI Agent 可以通过标准文件读取与路径导航(Relative Links)轻松周游整个代码库。
46
+ `codegraph-gen` 是一个面向 AI Agent(如 Antigravity、Codex、Claude Code 等)的静态代码知识图谱生成工具。它能够静态解析多语言 codebase,通过社区发现算法自动进行组件聚类,并导出为由标准 Markdown 文件组成的关联图谱库(Obsidian-like vault),极大地辅助 AI Agent 在本地进行精准的架构理解、逻辑导航与深度洞察分析。
47
+
48
+ 与基于图形化 Canvas 渲染的知识图谱不同,`codegraph-gen` 采用全 Markdown 的扁平结构存储。它专门为 LLM 设计,摒弃了昂贵且复杂的数据库依赖,让 AI Agent 可以通过标准文件读取与路径导航(Relative Links)轻松周游整个代码库。
41
49
 
42
50
  ---
43
51
 
44
52
  ## 🚀 核心特性
45
53
 
46
- - **多语言 AST 解析**:基于 `tree-sitter`,原生支持 **Python, JavaScript, TypeScript, Go, Rust, Swift**。
54
+ - **多语言 AST 解析**:基于 `tree-sitter`,原生支持 **Python, JavaScript, TypeScript, Kotlin, Go, Rust, Swift**。
47
55
  - **语义边解析与绑定**:静态解析跨文件的函数/方法调用(`calls`)、类型继承/接口实现(`inherits`/`implements`)以及文件导入关系(`imports`)。
48
56
  - **逻辑组件自动聚类**:利用贪心模块度社区发现算法(Louvain Modularity Clustering)将紧密耦合的文件和符号自动聚类为 **Component(逻辑组件)**,并根据组件核心节点智能命名。
49
57
  - **架构脆弱性分析**:自动识别 **God Nodes(度数最高的核心抽象)**,并静态检测文件级别的 **循环导入依赖(Circular Imports)**。
@@ -53,39 +61,29 @@ Description-Content-Type: text/markdown
53
61
 
54
62
  ## 📦 架构概览
55
63
 
56
- ```mermaid
57
- graph TD
58
- A[工作区源码 Workspace] --> B[detect: 语言识别与过滤]
59
- B --> C[parser: Tree-Sitter AST 符号提取]
60
- C --> D[builder: NetworkX 语义图组装与绑定]
61
- D --> E[cluster: 社区模块度聚类命名]
62
- E --> F[analyze: 上帝节点与循环导入分析]
63
- F --> G[export: 导出至 .codegraph/]
64
- G --> H[AGENT_PROMPT.md / AGENTS.md / README.md / nodes / components]
65
- ```
64
+ - **工作区源码 Workspace** -> **detect: 语言识别与过滤** -> **parser: Tree-Sitter AST 符号提取** -> **builder: NetworkX 语义图组装与绑定** -> **cluster: 社区模块度聚类命名** -> **analyze: 上帝节点与循环导入分析** -> **export: 导出至 .codegraph/** -> **生成 AGENT_PROMPT.md / AGENTS.md / README.md / nodes / components**
66
65
 
67
66
  ---
68
67
 
69
68
  ## 🛠️ 安装指南
70
69
 
71
- 推荐使用 [uv](https://github.com/astral-sh/uv) 管理项目依赖与虚拟环境:
70
+ 推荐使用 [uv](https://github.com/astral-sh/uv) 直接安装工具:
72
71
 
73
72
  ```bash
74
- # 克隆仓库
75
- git clone <repository-url>
76
- cd codegraph
73
+ # 全局安装 (推荐)
74
+ uv tool install codegraph-gen
75
+ ```
77
76
 
78
- # 同步依赖并激活虚拟环境
79
- uv sync
80
- source .venv/bin/activate
77
+ 如果需要在当前虚拟环境中作为库依赖安装:
81
78
 
82
- # 全局安装 (推荐)
83
- uv tool install --force --no-cache .
79
+ ```bash
80
+ # 安装至当前项目/环境
81
+ uv pip install codegraph-gen
84
82
  ```
85
83
 
86
- ### 2. 注入 AI Agent 斜杠命令集成
84
+ ### 注册 AI Agent 斜杠命令
87
85
 
88
- `codegraph` 支持一键将 `/codegraph` 自定义斜杠命令注册到您的 AI Agent(如 Codex 或 Antigravity)的全局配置中:
86
+ `codegraph-gen` 支持一键将 `/codegraph` 自定义斜杠命令注册到您的 AI Agent(如 Codex 或 Antigravity)的全局配置中:
89
87
 
90
88
  ```bash
91
89
  # 为 Codex / Antigravity 注入 /codegraph 全局斜杠命令
@@ -130,7 +128,7 @@ codegraph build . --exclude extra_folder/ --exclude docs/
130
128
 
131
129
  ## 🤖 与 AI Agent(Codex / Antigravity / Claude Code)协同分析
132
130
 
133
- `codegraph` 的核心设计思想是**离线构建,Agent 分析**。这避免了在 CLI 中直接硬编码大模型 API,降低了使用成本,并充分利用了你当前对话中功能更强、带有上下文读取能力的外部 Agent。
131
+ `codegraph-gen` 的核心设计思想是**离线构建,Agent 分析**。这避免了在 CLI 中直接硬编码大模型 API,降低了使用成本,并充分利用了你当前对话中功能更强、带有上下文读取能力的外部 Agent。
134
132
 
135
133
  ### 步骤 1:生成本地图谱
136
134
 
@@ -1,14 +1,21 @@
1
- # codegraph
1
+ <h1 align="center">codegraph-gen</h1>
2
2
 
3
- `codegraph` 是一个面向 AI Agent(如 Antigravity、Codex、Claude Code 等)的静态代码知识图谱生成工具。它能够静态解析多语言 codebase,通过社区发现算法自动进行组件聚类,并导出为由标准 Markdown 文件组成的关联图谱库(Obsidian-like vault),极大地辅助 AI Agent 在本地进行精准的架构理解、逻辑导航与深度洞察分析。
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/codegraph-gen/"><img src="https://img.shields.io/pypi/v/codegraph-gen.svg" alt="PyPI Version"></a>
5
+ <img src="https://img.shields.io/badge/python-3.11+-blue.svg" alt="Python Version">
6
+ <img src="https://img.shields.io/badge/code%20style-ruff-26b22f.svg" alt="Ruff">
7
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License">
8
+ </p>
4
9
 
5
- 与基于图形化 Canvas 渲染的知识图谱不同,`codegraph` 采用全 Markdown 的扁平结构存储。它专门为 LLM 设计,摒弃了昂贵且复杂的数据库依赖,让 AI Agent 可以通过标准文件读取与路径导航(Relative Links)轻松周游整个代码库。
10
+ `codegraph-gen` 是一个面向 AI Agent(如 Antigravity、Codex、Claude Code 等)的静态代码知识图谱生成工具。它能够静态解析多语言 codebase,通过社区发现算法自动进行组件聚类,并导出为由标准 Markdown 文件组成的关联图谱库(Obsidian-like vault),极大地辅助 AI Agent 在本地进行精准的架构理解、逻辑导航与深度洞察分析。
11
+
12
+ 与基于图形化 Canvas 渲染的知识图谱不同,`codegraph-gen` 采用全 Markdown 的扁平结构存储。它专门为 LLM 设计,摒弃了昂贵且复杂的数据库依赖,让 AI Agent 可以通过标准文件读取与路径导航(Relative Links)轻松周游整个代码库。
6
13
 
7
14
  ---
8
15
 
9
16
  ## 🚀 核心特性
10
17
 
11
- - **多语言 AST 解析**:基于 `tree-sitter`,原生支持 **Python, JavaScript, TypeScript, Go, Rust, Swift**。
18
+ - **多语言 AST 解析**:基于 `tree-sitter`,原生支持 **Python, JavaScript, TypeScript, Kotlin, Go, Rust, Swift**。
12
19
  - **语义边解析与绑定**:静态解析跨文件的函数/方法调用(`calls`)、类型继承/接口实现(`inherits`/`implements`)以及文件导入关系(`imports`)。
13
20
  - **逻辑组件自动聚类**:利用贪心模块度社区发现算法(Louvain Modularity Clustering)将紧密耦合的文件和符号自动聚类为 **Component(逻辑组件)**,并根据组件核心节点智能命名。
14
21
  - **架构脆弱性分析**:自动识别 **God Nodes(度数最高的核心抽象)**,并静态检测文件级别的 **循环导入依赖(Circular Imports)**。
@@ -18,39 +25,29 @@
18
25
 
19
26
  ## 📦 架构概览
20
27
 
21
- ```mermaid
22
- graph TD
23
- A[工作区源码 Workspace] --> B[detect: 语言识别与过滤]
24
- B --> C[parser: Tree-Sitter AST 符号提取]
25
- C --> D[builder: NetworkX 语义图组装与绑定]
26
- D --> E[cluster: 社区模块度聚类命名]
27
- E --> F[analyze: 上帝节点与循环导入分析]
28
- F --> G[export: 导出至 .codegraph/]
29
- G --> H[AGENT_PROMPT.md / AGENTS.md / README.md / nodes / components]
30
- ```
28
+ - **工作区源码 Workspace** -> **detect: 语言识别与过滤** -> **parser: Tree-Sitter AST 符号提取** -> **builder: NetworkX 语义图组装与绑定** -> **cluster: 社区模块度聚类命名** -> **analyze: 上帝节点与循环导入分析** -> **export: 导出至 .codegraph/** -> **生成 AGENT_PROMPT.md / AGENTS.md / README.md / nodes / components**
31
29
 
32
30
  ---
33
31
 
34
32
  ## 🛠️ 安装指南
35
33
 
36
- 推荐使用 [uv](https://github.com/astral-sh/uv) 管理项目依赖与虚拟环境:
34
+ 推荐使用 [uv](https://github.com/astral-sh/uv) 直接安装工具:
37
35
 
38
36
  ```bash
39
- # 克隆仓库
40
- git clone <repository-url>
41
- cd codegraph
37
+ # 全局安装 (推荐)
38
+ uv tool install codegraph-gen
39
+ ```
42
40
 
43
- # 同步依赖并激活虚拟环境
44
- uv sync
45
- source .venv/bin/activate
41
+ 如果需要在当前虚拟环境中作为库依赖安装:
46
42
 
47
- # 全局安装 (推荐)
48
- uv tool install --force --no-cache .
43
+ ```bash
44
+ # 安装至当前项目/环境
45
+ uv pip install codegraph-gen
49
46
  ```
50
47
 
51
- ### 2. 注入 AI Agent 斜杠命令集成
48
+ ### 注册 AI Agent 斜杠命令
52
49
 
53
- `codegraph` 支持一键将 `/codegraph` 自定义斜杠命令注册到您的 AI Agent(如 Codex 或 Antigravity)的全局配置中:
50
+ `codegraph-gen` 支持一键将 `/codegraph` 自定义斜杠命令注册到您的 AI Agent(如 Codex 或 Antigravity)的全局配置中:
54
51
 
55
52
  ```bash
56
53
  # 为 Codex / Antigravity 注入 /codegraph 全局斜杠命令
@@ -95,7 +92,7 @@ codegraph build . --exclude extra_folder/ --exclude docs/
95
92
 
96
93
  ## 🤖 与 AI Agent(Codex / Antigravity / Claude Code)协同分析
97
94
 
98
- `codegraph` 的核心设计思想是**离线构建,Agent 分析**。这避免了在 CLI 中直接硬编码大模型 API,降低了使用成本,并充分利用了你当前对话中功能更强、带有上下文读取能力的外部 Agent。
95
+ `codegraph-gen` 的核心设计思想是**离线构建,Agent 分析**。这避免了在 CLI 中直接硬编码大模型 API,降低了使用成本,并充分利用了你当前对话中功能更强、带有上下文读取能力的外部 Agent。
99
96
 
100
97
  ### 步骤 1:生成本地图谱
101
98
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codegraph-gen"
3
- version = "0.2.0"
3
+ version = "1.0.0"
4
4
  description = "AST-based codebase knowledge graph generator in Markdown"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -23,11 +23,12 @@ classifiers = [
23
23
  "Intended Audience :: Developers",
24
24
  "License :: OSI Approved :: MIT License",
25
25
  "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.11",
26
27
  "Programming Language :: Python :: 3.12",
27
28
  "Topic :: Software Development :: Code Generators",
28
29
  "Topic :: Software Development :: Libraries :: Python Modules",
29
30
  ]
30
- requires-python = ">=3.12"
31
+ requires-python = ">=3.11"
31
32
  dependencies = [
32
33
  "networkx>=3.0",
33
34
  "tree-sitter>=0.23.0",
@@ -59,7 +60,6 @@ Issues = "https://github.com/twn39/codegraph/issues"
59
60
 
60
61
  [project.scripts]
61
62
  codegraph = "codegraph_gen.__main__:main"
62
- codegraph-gen = "codegraph_gen.__main__:main"
63
63
 
64
64
  [build-system]
65
65
  requires = ["uv_build>=0.9.26,<0.10.0"]
@@ -294,12 +294,12 @@ def info():
294
294
  try:
295
295
  from importlib.metadata import version
296
296
 
297
- ver = version("codegraph")
297
+ ver = version("codegraph-gen")
298
298
  except Exception:
299
- ver = "0.2.0"
299
+ ver = "1.0.0"
300
300
  console.print(f"[bold]codegraph v{ver}[/bold]")
301
301
  console.print(
302
- "Supported languages: Python, JavaScript, TypeScript, Go, Rust, Swift"
302
+ "Supported languages: Python, JavaScript, TypeScript, Kotlin, Go, Rust, Swift"
303
303
  )
304
304
 
305
305
 
@@ -57,7 +57,7 @@ class VaultWriter:
57
57
  project_root = output_dir.parent
58
58
  agents_file = project_root / "AGENTS.md"
59
59
 
60
- agents_rule_body = """## codegraph
60
+ agents_rule_body = """## codegraph-gen
61
61
 
62
62
  This project maintains a codebase knowledge graph at `.codegraph/`.
63
63
 
@@ -81,11 +81,11 @@ You MUST follow these rules when working in this codebase:
81
81
  if agents_file.exists():
82
82
  try:
83
83
  content = agents_file.read_text(encoding="utf-8")
84
- if "## codegraph" not in content:
84
+ if "## codegraph-gen" not in content:
85
85
  new_content = content.rstrip() + "\n\n" + agents_rule_body
86
86
  self.write_file(agents_file, new_content)
87
87
  logger.info(
88
- "Appended codegraph rules to existing AGENTS.md at root"
88
+ "Appended codegraph-gen rules to existing AGENTS.md at root"
89
89
  )
90
90
  except Exception as e:
91
91
  logger.warning(f"Could not read or append to existing AGENTS.md: {e}")