Skip to content

Commit 84558c6

Browse files
committed
init
1 parent d803572 commit 84558c6

19 files changed

+2385
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release
2+
permissions:
3+
contents: write
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
jobs:
9+
build:
10+
name: 构建Windows可执行文件
11+
runs-on: windows-latest
12+
steps:
13+
- name: 检出代码
14+
uses: actions/checkout@v4
15+
- name: 设置Python环境
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.9"
19+
cache: "pip"
20+
- name: 安装依赖
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install poetry
24+
poetry config virtualenvs.create false
25+
poetry install
26+
- name: 获取版本号
27+
id: get_version
28+
shell: bash
29+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
30+
31+
- name: 准备Release说明
32+
id: release_notes
33+
shell: pwsh
34+
run: |
35+
$version = "${{ env.VERSION }}"
36+
$header = "AI代码上下文助手 v$version 发布"
37+
$defaultNotes = "* 暂无此版本的详细更新说明"
38+
$footer = "## 下载`n* 点击下方附件下载应用程序"
39+
# 默认版本说明
40+
$versionNotes = $defaultNotes
41+
# 检查CHANGELOG.md是否存在
42+
if (Test-Path "CHANGELOG.md") {
43+
$content = Get-Content "CHANGELOG.md"
44+
$versionHeader = "## v${version}"
45+
$captureLines = $false
46+
$capturedContent = @()
47+
48+
# 逐行处理CHANGELOG
49+
foreach ($line in $content) {
50+
# 版本匹配开始
51+
if ($line -match "^$versionHeader($| -)") {
52+
$captureLines = $true
53+
continue
54+
}
55+
# 下一版本标记,停止捕获
56+
elseif ($line -match "^## v" -and $captureLines) {
57+
$captureLines = $false
58+
break
59+
}
60+
# 捕获当前版本内容
61+
elseif ($captureLines -and $line.Trim() -ne "") {
62+
# 转换破折号列表为星号列表
63+
if ($line -match "^- ") {
64+
$line = $line -replace "^- ", "* "
65+
}
66+
$capturedContent += $line
67+
}
68+
}
69+
70+
# 如果找到了版本内容,使用它
71+
if ($capturedContent.Count -gt 0) {
72+
$versionNotes = $capturedContent -join "`n"
73+
}
74+
}
75+
# 创建完整的Release说明
76+
$releaseContent = "$header`n## 更新内容`n$versionNotes`n$footer"
77+
# 保存到文件
78+
$releaseContent | Out-File -FilePath "RELEASE.md" -Encoding utf8
79+
- name: 构建可执行文件
80+
env:
81+
PYTHONIOENCODING: utf-8
82+
run: poetry run cxfreeze build
83+
- name: 创建ZIP压缩包
84+
run: |
85+
Compress-Archive -Path build/exe.win-*/* -DestinationPath AICodeContextHelper_v${{ env.VERSION }}.zip
86+
87+
- name: 创建Release
88+
uses: softprops/action-gh-release@v1
89+
with:
90+
tag_name: ${{ github.ref }}
91+
name: AI代码上下文助手 v${{ env.VERSION }}
92+
body_path: RELEASE.md
93+
draft: false
94+
prerelease: false
95+
files: |
96+
AICodeContextHelper_v${{ env.VERSION }}.zip
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build
2+
venv
3+
dist
4+
.vscode
5+
__pycache__
6+
poetry.lock

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# 更新日志
2+
3+
## v1.0.0 - 2025-05-07
4+
5+
### 初始版本发布
6+
- 用户友好的图形界面,基于Tkinter开发,支持Windows平台
7+
8+
### 实现基本功能
9+
- **目录树可视化**:直观展示项目结构,支持展开/折叠操作
10+
- **目录树导出**:可将树状结构导出为文本文件或复制到剪贴板
11+
- **文件筛选系统**
12+
- 支持正则表达式过滤文件名
13+
- 可控制是否显示隐藏文件/文件夹
14+
- 可设置目录树最大深度
15+
- **多种复制模式**
16+
- 复制文件路径(支持相对路径或绝对路径)
17+
- 复制文件代码内容
18+
- 复制文件名
19+
- 同时复制路径与代码内容
20+
- **内容格式化**:可自定义路径和代码的前缀/后缀
21+
- **智能编码检测**:自动识别和处理各种文本编码,尤其中文编码
22+
- **设置持久化**:自动保存用户偏好设置
23+
- **路径历史记录**:记住最近使用的目录路径
24+
25+
### 添加多语言支持
26+
- 支持简体中文和英文界面
27+
- 语言设置被保存并在重启应用后自动应用

README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<p align="center">English | <a href="README_zh.md">中文</a><p>
2+
3+
# AI Code Context Helper
4+
5+
## 📝 Introduction
6+
7+
AI Code Context Helper is a lightweight desktop application designed for developers collaborating with AI assistants. It provides a visual representation of project structures and enables quick, selective export of file paths and code content to the clipboard, streamlining code communication with ChatGPT, Claude, and other AI assistants.
8+
9+
As a supplementary tool, it doesn't aim to replace existing editors or IDEs but focuses specifically on solving the code context transfer challenge in AI programming collaboration. Compared to integrated AI code editors, it offers advantages in simplicity, low learning curve, independence from specific AI services, and minimal resource usage, integrating seamlessly with various development environments.
10+
11+
![Application Overview](./_images/app_overview.png)
12+
13+
<!-- 👆 Main interface screenshot -->
14+
15+
## ✨ Key Features
16+
17+
### Intelligent File Management
18+
- **Directory Tree Visualization**: Display project file structure in tree view
19+
- **File Type Recognition**: Automatically detect text file encodings and distinguish between text and binary files
20+
- **Advanced Filtering**: Support for regex filtering and directory depth limitation for handling large projects
21+
22+
### Flexible Selection and Export
23+
- **Multi-selection Support**: Select individual files, multiple files, or entire directories with subdirectories
24+
- **Batch Export**: Export paths, code, or both for selected content
25+
- **Context Menu**: Multiple copy options for different development scenarios
26+
27+
### Customization and Ease of Use
28+
- **Multilingual Support**: Switch between English and Chinese interfaces
29+
- **Output Format Customization**: Configure prefix and suffix formats for code and paths
30+
- **Lightweight Implementation**: Low resource consumption, quick startup, seamlessly integrates with existing development workflows
31+
32+
## 💡 Usage Tips
33+
34+
### Best Practice: Combining Project Structure with Code Content
35+
36+
For better AI comprehension of your project, follow these steps:
37+
38+
1. **First Share Project Structure**:
39+
- Select the root directory and use the "Copy Tree" function
40+
- Paste the directory tree to the AI to provide overall project architecture
41+
42+
2. **Then Share Key Files**:
43+
- Select relevant files based on your requirements (multiple files or directories)
44+
- Use "Copy Path and Code" to provide all necessary files at once
45+
46+
3. **Reference File Paths in Requirements**:
47+
- Example: "Please modify the `authenticate` method in `models/user.py` to add two-factor authentication"
48+
- Clear path references help AI locate relevant code accurately
49+
50+
### Module-Level Modifications
51+
52+
When modifying an entire functional module:
53+
54+
1. Select the module directory (e.g., `authentication/` folder)
55+
2. Right-click and choose "Copy Path and Code" to include all files in the directory
56+
3. Describe to the AI: "Please analyze this authentication module and suggest improvements"
57+
58+
> For codebases under 5,000 lines, you can copy all code directly to AI assistants like Claude or ChatGPT for code review and get complete modified code. This is essentially pair programming with AI - efficiency improves with your coding and requirements description skills.
59+
60+
## 📸 Screenshots
61+
62+
### Context Menu
63+
64+
![Right-click Menu](./_images/context_menu.png)
65+
66+
<!-- 👆 Right-click menu screenshot -->
67+
68+
## 🔧 Installation and Usage
69+
70+
### Download and Install
71+
72+
1. Download the latest version from the [Releases page](https://github.com/sansan0/ai-code-context-helper/releases)
73+
2. Extract the files to any location
74+
3. Run `AI Code Context Helper.exe` to launch the application
75+
76+
### How to Use
77+
78+
1. Click "Browse..." to select your project root directory
79+
2. Check the files or folders you want to share in the directory tree
80+
3. Right-click and select "Copy Path and Code" (or other copy options)
81+
4. Paste the copied content into your AI assistant (ChatGPT, Claude, etc.)
82+
5. Ask questions or request code modifications based on the provided context
83+
84+
## ⚙️ Configuration Options
85+
86+
### Interface Options
87+
88+
- **Show Hidden Files**: Toggle display of hidden files and folders
89+
- **Show Files/Show Folders**: Control what appears in the tree view
90+
- **Preserve Tree State**: Maintain expansion/collapse state when resetting
91+
- **Use Relative Path**: Use paths relative to the root directory instead of absolute paths
92+
- **Max Depth**: Limit the display depth of the directory tree
93+
- **File Filter**: Filter displayed files using regular expressions
94+
95+
## 🛠️ Building from Source
96+
97+
### Requirements
98+
99+
- Python 3.9+
100+
- Poetry package manager
101+
102+
### Install Dependencies
103+
104+
```bash
105+
git clone https://github.com/sansan0/ai-code-context-helper.git
106+
cd ai-code-context-helper
107+
poetry install
108+
```
109+
110+
### Build Executable
111+
112+
```bash
113+
poetry run python -m cx_Freeze build
114+
```
115+
116+
## 📄 License
117+
118+
This project is licensed under the GPL-3.0 License - see the [LICENSE](LICENSE) file for details.

README_zh.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<p align="center"><a href="README.md">English</a> | 中文<p>
2+
3+
# AI Code Context Helper (AI 代码上下文助手)
4+
5+
## 📝 简介
6+
7+
AI Code Context Helper 是一款轻量级桌面应用,专为开发者与 AI 助手协作设计。它提供可视化的项目结构展示,支持快速选择性导出文件路径和代码内容到剪贴板,使与 ChatGPT、Claude 等 AI 助手的代码交流更加高效。
8+
9+
作为一个辅助工具,它不尝试替代现有编辑器或 IDE,而是专注于解决 AI 编程协作中的代码上下文传递问题。与集成式 AI 代码编辑器相比,它具有界面简洁、学习门槛低、不依赖特定 AI 服务、资源占用少等优势,可无缝融入各种开发环境。
10+
11+
![应用概览截图](./_images/app_overview.png)
12+
13+
<!-- 👆 主界面截图 -->
14+
15+
## ✨ 主要特性
16+
17+
### 智能文件管理
18+
19+
- **目录树可视化**:树形视图显示项目文件结构
20+
- **文件类型识别**:自动检测文本文件编码,区分文本与二进制文件
21+
- **筛选功能**:支持正则表达式过滤与目录深度限制,便于处理大型项目
22+
23+
### 灵活选择与导出
24+
25+
- **多选支持**:可选择单个文件、多个文件或整个目录及其子目录
26+
- **批量导出**:支持导出选中内容的路径、代码或两者兼有
27+
- **上下文菜单**:提供多种复制选项,适用于不同开发场景
28+
29+
### 定制化与易用性
30+
31+
- **多语言支持**:支持中英文切换
32+
- **输出格式定制**:可配置代码和路径的前缀后缀格式
33+
- **轻量实现**:低资源占用,启动迅速,无缝融入现有开发工作流
34+
35+
## 💡 使用技巧
36+
37+
### 最佳实践:结合目录结构与代码内容
38+
39+
为了让 AI 更全面地理解您的项目,建议采用以下步骤:
40+
41+
1. **先提供项目结构**
42+
43+
- 选择根目录并使用"复制目录树"功能
44+
- 将目录树粘贴给 AI,帮助它了解整体项目架构
45+
46+
2. **再提供关键文件代码**
47+
48+
- 根据需求选择相关的文件(可多选,多目录和多文件都行)
49+
- 使用"复制路径与代码"功能一次性提供所有必要文件
50+
51+
3. **描述需求时参考文件路径**
52+
- 例如:"请修改`models/user.py`中的`authenticate`方法,增加双因素认证支持"
53+
- 清晰的路径引用使 AI 能更准确定位需要关注的代码
54+
55+
### 模块级修改
56+
57+
当需要对某个功能模块进行整体修改时:
58+
59+
1. 选择该模块所在的目录(如`authentication/`文件夹)
60+
2. 右键选择"复制路径与代码",自动包含该目录下所有文件
61+
3. 向 AI 描述:"请分析这个认证模块的代码,并提出改进建议"
62+
63+
> 如果代码在 5000 行以内,你可以直接复制所有代码交给 claude 或者 chatgpt等ai,让它帮助审查代码质量,并让ai完整提供修改后的代码即可。本质上是你在与ai进行结对编程,如果你擅长代码和描述需求,那么效率就高,如果都不擅长,那么全是ai判断,容易出现误判。
64+
65+
66+
67+
## 📸 应用截图
68+
69+
### 目录树菜单
70+
71+
![右键菜单](./_images/context_menu.png)
72+
73+
<!-- 👆 右键菜单操作截图 -->
74+
75+
## 🔧 安装与使用
76+
77+
### 下载安装
78+
79+
1.[Releases 页面](https://github.com/sansan0/ai-code-context-helper/releases)下载最新版本
80+
2. 解压缩下载的文件到任意位置
81+
3. 运行`AI Code Context Helper.exe`启动应用
82+
83+
### 使用方法
84+
85+
1. 点击"浏览..."按钮选择项目根目录
86+
2. 在目录树中勾选需要分享的文件或文件夹
87+
3. 右键点击选择"复制路径与代码"(或使用其他复制选项)
88+
4. 将复制的内容粘贴到 AI 助手(如 ChatGPT、Claude 等)对话中
89+
5. 根据复制的代码上下文,向 AI 提问或请求代码修改建议
90+
91+
## ⚙️ 配置选项
92+
93+
### 界面选项
94+
95+
- **显示隐藏文件**:是否显示隐藏文件和文件夹
96+
- **显示文件/显示文件夹**:控制树视图中的显示内容
97+
- **固定目录树**:重置时保留目录树的展开/收起状态
98+
- **使用相对路径**:复制时使用相对路径而非绝对路径
99+
- **最大深度**:限制目录树的显示深度
100+
- **文件过滤**:使用正则表达式过滤显示的文件
101+
102+
## 🛠️ 从源码构建
103+
104+
### 环境要求
105+
106+
- Python 3.9+
107+
- Poetry 包管理工具
108+
109+
### 安装依赖
110+
111+
```bash
112+
git clone https://github.com/sansan0/ai-code-context-helper.git
113+
cd ai-code-context-helper
114+
poetry install
115+
```
116+
117+
### 构建可执行文件
118+
119+
```bash
120+
poetry run python -m cx_Freeze build
121+
```
122+
123+
## 📄 许可证
124+
125+
本项目采用 GPL-3.0 许可证 - 详见 [LICENSE](LICENSE) 文件

_images/app_overview.png

104 KB
Loading

_images/context_menu.png

75.5 KB
Loading

ai_code_context_helper/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import tkinter as tk
2+
from ai_code_context_helper.version import __version__
3+
from ai_code_context_helper.code_context_generator import CodeContextGenerator
4+
5+
def main():
6+
"""应用程序入口点,创建主窗口并启动事件循环"""
7+
root = tk.Tk()
8+
app = CodeContextGenerator(root)
9+
root.mainloop()
10+
11+
if __name__ == "__main__":
12+
main()

0 commit comments

Comments
 (0)