Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0dccfec
- add: Working on the documentation required for LLM coding
Mar 10, 2025
849e555
- add: md file in en
Mar 10, 2025
3fac809
- add: TODO.md in en
Mar 10, 2025
ac5d816
feat: Separate utility functions into utils.py modules
Mar 10, 2025
3522481
feat: Finished implementing the filetree module
Mar 10, 2025
8b3a0ef
- feat: 다시 첨부터;; 작업을 잘못하고 있었음;
Mar 10, 2025
020513e
feat: Separate common utility functions into utils.py module
Mar 10, 2025
e366ff5
feat: Separate file tree structure management into filetree.py module
Mar 10, 2025
465d347
feat: Separate file selection UI functionality into selector.py module
Mar 10, 2025
8fa5718
refactor: Improving your codebase with a modular structure
Mar 10, 2025
ddfc257
feat: Englishised pydoc, updated documentation
Mar 11, 2025
da379fd
fix: Changing the task doc folder structure
Mar 11, 2025
5c498b9
add: Add a diagram
Mar 11, 2025
ba7dd1a
feat: Adds Vim-style search and navigation
Mar 11, 2025
14c8d44
refactor: Separating selector.py modules for separation of concerns
Mar 12, 2025
0b463d8
feat: Add .gitignore handling and related tests
Mar 12, 2025
830b1c7
Merge branch 'feat/read-gitignore'
Mar 12, 2025
507718f
fix: Update tests to correctly account for important.log and adjust e…
Mar 12, 2025
cb20714
- fix: Update English documentation
Mar 12, 2025
ab37f89
feat: update docs
Mar 12, 2025
43453ab
feat: Update install script: add fish shell support, remove module di…
Mar 12, 2025
3eb8cd7
feat: 설치 깃헙 URL 변경
Jun 9, 2025
3b1fde7
feat: Implement multi-pattern search in file selector (#4)
oodmumc3 Jun 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
repomix-output.txt
__pycache__/
codeselect.llm
codemcp.toml
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div align="center">

![CodeSelect Logo](https://img.shields.io/badge/CodeSelect-1.0.0-blue)
![CodeSelect Logo](https://img.shields.io/badge/CodeSelect-1.1.0-blue)

**Easily select and share code with AI assistants**

Expand All @@ -20,6 +20,7 @@ curl -sSL https://raw.githubusercontent.com/maynetee/codeselect/main/install.sh
## ✨ Features

- **Visual File Selection**: Interactive UI to easily select files with checkboxes
- **Vim-style Navigation & Search**: Use `/` to search files and j/k/h/l for navigation
- **Intelligent Code Analysis**: Automatically detects imports and relationships between files
- **Multi-language Support**: Works with Python, C/C++, JavaScript, Java, Go, Ruby, PHP, Rust, Swift and more
- **Zero Dependencies**: Works with standard Python libraries only
Expand All @@ -45,14 +46,17 @@ codeselect --help

## 🖥️ Interface Controls

- **↑/↓**: Navigate between files
- **↑/↓** or **j/k**: Navigate between files
- **Space**: Toggle selection of file/directory
- **←/→**: Collapse/expand directories
- **←/→** or **h/l**: Collapse/expand directories
- **/**: Enter search mode (supports regex patterns)
- **^**: Toggle case sensitivity in search mode
- **ESC**: Exit search mode or clear search results
- **A**: Select all files
- **N**: Deselect all files
- **C**: Toggle clipboard copy
- **D** or **Enter**: Complete selection and export
- **X** or **Esc**: Exit without saving
- **X**: Exit without saving

## 📄 Output Formats

Expand All @@ -75,7 +79,7 @@ codeselect --format llm
```
usage: codeselect [-h] [-o OUTPUT] [--format {txt,md,llm}] [--skip-selection] [--no-clipboard] [--version] [directory]

CodeSelect v1.0.0 - Select files to share with AI assistants
CodeSelect v1.1.0 - Select files to share with AI assistants

positional arguments:
directory Directory to scan (default: current directory)
Expand Down Expand Up @@ -112,3 +116,4 @@ To remove CodeSelect from your system:
```bash
# One-line uninstallation
curl -sSL https://raw.githubusercontent.com/maynetee/codeselect/main/uninstall.sh | bash
```
155 changes: 155 additions & 0 deletions cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CodeSelect - CLI module

명령행 인터페이스(CLI) 관련 기능을 담당하는 모듈입니다.
사용자의 명령행 인수를 처리하고 적절한 함수를 호출합니다.
"""

import os
import sys
import argparse

# 다른 모듈 임포트
import utils
import filetree
import selector
import output
import dependency

__version__ = "1.0.0"

def parse_arguments():
"""
Parses command-line arguments.

Returns:
argparse.Namespace: the parsed command line arguments.
"""
parser = argparse.ArgumentParser(
description=f"CodeSelect v{__version__} - Select files to share with AI assistants"
)
parser.add_argument(
"directory",
nargs="?",
default=".",
help="Directory to scan (default: current directory)"
)
parser.add_argument(
"-o", "--output",
help="Output file path (default: based on directory name)"
)
parser.add_argument(
"--format",
choices=["txt", "md", "llm"],
default="llm",
help="Output format (default: llm - optimized for LLMs)"
)
parser.add_argument(
"--skip-selection",
action="store_true",
help="Skip the selection interface and include all files"
)
parser.add_argument(
"--no-clipboard",
action="store_true",
help="Disable automatic copy to clipboard"
)
parser.add_argument(
"--version",
action="store_true",
help="Show version information"
)

return parser.parse_args()

def main():
"""
Main Function - The entry point for the CodeSelect program.

Returns:
int: the programme exit code (0: normal exit, 1: error).
"""
args = parse_arguments()

# 버전 정보 표시
if args.version:
print(f"CodeSelect v{__version__}")
return 0

# 디렉토리 경로 확인
root_path = os.path.abspath(args.directory)
if not os.path.isdir(root_path):
print(f"Error: {root_path} is not a valid directory")
return 1

# 출력 파일 이름 생성
if not args.output:
args.output = utils.generate_output_filename(root_path, args.format)

# 디렉토리 스캔
print(f"Scanning directory: {root_path}")
root_node = filetree.build_file_tree(root_path)

# 파일 선택 처리
proceed = True
if not args.skip_selection:
# 대화형 선택 인터페이스 실행
try:
proceed = selector.interactive_selection(root_node)
if not proceed:
print("Selection cancelled. Exiting without saving.")
return 0
except Exception as e:
print(f"Error in selection interface: {e}")
return 1

# 선택된 파일 수 확인
selected_count = filetree.count_selected_files(root_node)
print(f"\nSelected files: {selected_count}")

# 선택된 파일이 없으면 종료
if selected_count == 0:
print("No files selected. Exiting.")
return 0

# 선택된 파일 내용 수집
file_contents = filetree.collect_selected_content(root_node, root_path)
print(f"Collected content from {len(file_contents)} files.")

# 의존성 분석 (LLM 형식인 경우)
if args.format == 'llm':
print("Analyzing file relationships...")
all_files = filetree.collect_all_content(root_node, root_path)
dependencies = dependency.analyze_dependencies(root_path, all_files)

# 의존성 정보와 함께 출력 작성
output_path = output.write_output_file(
args.output, root_path, root_node, file_contents, args.format, dependencies
)
else:
# 의존성 정보 없이 출력 작성
output_path = output.write_output_file(
args.output, root_path, root_node, file_contents, args.format
)

print(f"\nOutput written to: {output_path}")

# 클립보드 복사 (활성화된 경우)
if not args.no_clipboard:
try:
with open(output_path, 'r', encoding='utf-8') as f:
content = f.read()

if utils.try_copy_to_clipboard(content):
print("Content copied to clipboard.")
else:
print("Could not copy to clipboard (missing dependencies).")
except Exception as e:
print(f"Error copying to clipboard: {e}")

return 0

if __name__ == "__main__":
sys.exit(main())
Loading