# Chahuadev Fix Comments Tool
[](https://opensource.org/licenses/MIT)
[](https://github.com/chahuadev/chahuadev-fix-comments)
[](https://www.npmjs.com/package/@chahuadev/fix-comments)
**Professional Comment Standardization Tool for JavaScript/TypeScript Projects**
A comprehensive CLI tool that intelligently adds, converts, and improves comments in JavaScript and TypeScript codebases with advanced AST-based analysis, bilingual support, and AI-friendly formatting.
## Features
- **Smart Comment Detection** - AST-based analysis with intelligent comment generation
- **Comment Style Conversion** - Convert `/* */` to `//` comments automatically
- **Bilingual Support** - Add Thai/English comments intelligently
- **AI-Friendly Format** - Generate compatible comments for AI tools
- **Safe Processing** - Automatic backup and dry-run preview mode
- **Performance Optimized** - Fast processing for large codebases with TypeScript support
## Beta Development Status
**v3.0.1-beta is the FINAL BETA VERSION**
- **Current users can continue using this version normally**
- **No more beta version updates will be released**
- **Next release will be v1.0.0 (Production Ready)**
- **Expected v1.0.0 release: Q1 2026**
This beta version remains fully functional and safe to use, but future development will focus on the stable v1.0.0 release.
## Quick Start
### Installation
#### NPX (Recommended)
```bash
# Always use beta version for latest features
npx @chahuadev/fix-comments@beta
```
#### Global Installation
```bash
npm install -g @chahuadev/fix-comments@beta
```
### Usage
#### Basic Usage
```bash
# Add missing comments with backup (Recommended)
npx @chahuadev/fix-comments@beta . --add-missing --backup --verbose
# Preview changes first (Safe!)
npx @chahuadev/fix-comments@beta . --dry-run --verbose
# Convert comment styles only
npx @chahuadev/fix-comments@beta src/ --convert-style
```
#### Advanced Options
```bash
# Bilingual comment generation
npx @chahuadev/fix-comments@beta . --add-missing --bilingual --backup
# AI-friendly format
npx @chahuadev/fix-comments@beta . --ai-friendly --add-missing
# Specific file types
npx @chahuadev/fix-comments@beta . --extensions js,ts,jsx,tsx
```
## Command Options
| Option | Description | Default |
|--------|-------------|---------|
| `--add-missing` | Add missing comments to functions | `false` |
| `--convert-style` | Convert /* */ to // comments | `true` |
| `--bilingual` | Add Thai/English comments | `false` |
| `--ai-friendly` | Generate AI-compatible format | `false` |
| `--backup` | Create backup before processing | `false` |
| `--dry-run` | Preview changes without applying | `false` |
| `--verbose` | Enable detailed logging | `false` |
| `--extensions` | File extensions to process | `.js,.ts,.jsx,.tsx` |
## Supported Languages
### Programming Languages
- **JavaScript** (ES2022+) - Functions, classes, arrow functions
- **TypeScript** (4.0+) - Type annotations, interfaces, generics
- **JSX/TSX** (React 18+) - Components, hooks, props
### Comment Formats
- **JSDoc Standard** - Professional documentation format
- **Bilingual Comments** - English/Thai dual language support
- **AI-Friendly** - Optimized for AI code analysis tools
## Performance Metrics
- **Processing Speed**: 0.89 seconds for 18 files (43% faster than v2.x)
- **Detection Accuracy**: 98.7% success rate with refined algorithms
- **Error Reduction**: 75% fewer inappropriate context errors
- **Memory Usage**: Optimized for large codebases
## Documentation
### Essential Documentation
- **[Code of Conduct](docs/CODE_OF_CONDUCT.md)** - Community standards and behavior guidelines
- **[Contributing Guidelines](docs/CONTRIBUTING.md)** - How to contribute to the project
- **[Security Policy](docs/SECURITY.md)** - Security policies and vulnerability reporting
### Development Documentation
- **[API Reference](docs/API.md)** - Complete programming interface documentation
- **[Architecture Guide](docs/ARCHITECTURE.md)** - System design and architecture overview
- **[Commit Guidelines](docs/COMMIT_GUIDELINES.md)** - Professional commit message standards
### Project Management
- **[Governance Model](docs/GOVERNANCE.md)** - Project leadership and decision-making
- **[Collaboration Guidelines](docs/COLLABORATION.md)** - Open source collaboration practices
- **[Release Process](docs/RELEASE_PROCESS.md)** - Release procedures and quality assurance
## Contributing
We welcome contributions from the community! Please read our documentation before getting started:
- **[Contributing Guidelines](docs/CONTRIBUTING.md)** - Complete contribution procedures
- **[Commit Guidelines](docs/COMMIT_GUIDELINES.md)** - Professional commit message standards
- **[Collaboration Guidelines](docs/COLLABORATION.md)** - Open source collaboration practices
### Quick Contribution Steps
1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Make your changes following our coding standards
4. Run tests: `npm test`
5. Commit your changes: `git commit -m 'Add amazing feature'`
6. Push to the branch: `git push origin feature/amazing-feature`
7. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## About Chahua Development
**บริษัท ชาหัว ดีเวลลอปเมนต์ จำกัด (Chahua Development Co., Ltd.)**
We are committed to creating high-quality, secure, and maintainable software solutions. Our tools and standards reflect our dedication to excellence in software development.
- **Website**: [Coming Soon]
- **Email**: chahuadev@gmail.com
- **Repository**: https://github.com/chahuadev/chahuadev-fix-comments.git
## Support
- **Issues**: [GitHub Issues](https://github.com/chahuadev/chahuadev-fix-comments/issues)
- **Discussions**: [GitHub Discussions](https://github.com/chahuadev/chahuadev-fix-comments/discussions)
- **Email**: chahuadev@gmail.com
## Project Status
- **Version**: 3.0.1-beta (Final Beta)
- **Status**: Beta Complete - Preparing for Stable Release
- **Maintenance**: Actively Maintained
- **Next Release**: 1.0.0 (Q1 2026)
- **Node.js**: >=22.0.0
---
**Made with by Chahua Development Co., Ltd.**
- **Comments Added**: 300+ intelligent comments per typical project scan
### Issue Reporting
- Use GitHub Issues with clear code samples
- Include expected vs actual behavior descriptions
- Provide system information and file examples
---
## SECURITY WARNING
### ENTERPRISE SECURITY PROTECTION
This tool implements **ADVANCED SECURITY MEASURES** to protect against malicious attacks:
### BLOCKED SYSTEM PATHS
```bash
# BLOCKED - Critical system files are protected
/etc/passwd
/etc/shadow
C:\Windows\System32\
C:\Program Files\
/usr/bin/
/bin/sh
/root/
/boot/
```
### System Protection
The tool will reject access to:
- **Windows System directories** (`C:\Windows\`, `C:\Program Files\`, `C:\System Volume Information\`)
- **Linux System directories** (`/etc/`, `/usr/`, `/bin/`, `/root/`, `/boot/`, `/proc/`, `/sys/`)
- **MacOS System directories** (`/System/`, `/usr/bin/`, `/bin/`, `/sbin/`)
- **Dangerous files** with null bytes or dangerous characters
- **Large files** exceeding 10MB
- **Path traversal** attempts (`../`, `..\\`, etc.)
- **Command injection** patterns
- **Script execution** attempts
- **Binary executable** files
### SECURE USAGE GUIDELINES
- **Always use `--dry-run` first** to preview results
- **Use `--backup` for important files** to prevent data loss
- **Test your code after comment modifications** to ensure proper functionality
- **ตรวจสอบ Git status** ก่อน commit
- **ใช้เฉพาะในโปรเจ็กต์ของคุณ** อย่าใช้กับไฟล์ระบบ
- **ตรวจสอบ output** ก่อนยืนยันการดำเนินการ
### ATTACK DETECTION - สัญญาณเตือนการโจมตี
Tool จะแสดงข้อความเตือนเมื่อตรวจพบ:
```bash
SECURITY ALERT: Path traversal detected
SECURITY ALERT: System directory access denied
SECURITY ALERT: Command injection attempt blocked
SECURITY ALERT: Dangerous file operation prevented
SECURITY ALERT: Binary execution attempt blocked
```
## Why Use This Tool? - ทำไมต้องใช้?
**Transform comment blocks safely and efficiently - แปลงบล็อคคอมเมนต์อย่างปลอดภัยและมีประสิทธิภาพ**
- **Smart Detection**: Advanced pattern recognition for /* */ comments
- **Lightning Fast**: Process 1000+ files in seconds
- **Maximum Safety**: Automatic backup and dry-run modes
- **Universal Support**: JavaScript, TypeScript, JSX, TSX
- **AI-Friendly**: Generate AI-compatible comment formats
- **High Performance**: Optimized for large codebases
- **Auto Skip System Folders**: Automatically skips (node_modules, .git, dist, build)
- **Library Integration**: Use as Node.js library
## Installation Methods
### Method 1: NPX (Recommended - No Installation Required)
```bash
# Use latest beta version instantly
npx @chahuadev/fix-comments@beta --dry-run
# Always test with dry-run first
npx @chahuadev/fix-comments@beta . --dry-run --verbose
```
### Method 2: Project Installation
```bash
# Install as dev dependency
npm install @chahuadev/fix-comments@3.0.1-beta --save-dev
# Use in package.json scripts
npm run fix-comments
# Uninstall
npm uninstall @chahuadev/fix-comments
```
### Method 3: Global Installation
```bash
# Install globally for system-wide access
npm install -g @chahuadev/fix-comments@3.0.1-beta
# Test installation
fix-comments --version
# Should display: Universal Comment Fixer v3.0.1-beta
# Uninstall when ready for v1.0.0
npm uninstall -g @chahuadev/fix-comments
```
### Method 4: Development Setup
```bash
# For contributing or testing development version
git clone https://github.com/chahuadev/chahuadev-fix-comments
cd chahuadev-fix-comments
npm install
node fix-comments.js --version
```
### Clear NPX Cache (if needed)
```bash
# Clear all npm cache
npm cache clean --force
# Clear npx cache only (Windows)
Remove-Item -Path "$env:LOCALAPPDATA\npm-cache\_npx" -Recurse -Force
# Clear npx cache only (Linux/Mac)
rm -rf ~/.npm/_npx
```
## Usage Examples
### Basic Commands
| Command | Description |
|---------|-------------|
| `npx @chahuadev/fix-comments@beta . --add-missing --backup` | Process current directory with backup |
| `npx @chahuadev/fix-comments@beta . --dry-run` | Preview changes only (safe) |
| `npx @chahuadev/fix-comments@beta myfile.js --backup` | Process single file with backup |
### Common Usage Patterns
```bash
# Add comments to current folder with backup
npx @chahuadev/fix-comments@beta . --add-missing --backup
# Preview changes first (recommended)
npx @chahuadev/fix-comments@beta . --dry-run
# Process specific file types only
npx @chahuadev/fix-comments@beta src --include="*.ts,*.tsx" --backup
# Verbose output for debugging
npx @chahuadev/fix-comments@beta . --dry-run --verbose
```
## Command Options | ตัวเลือกคำสั่ง
### Essential Options | ตัวเลือกจำเป็น
| Option | Description | คำอธิบาย |
|---------|-------------|----------|
| `--add-missing` | Add comments to functions | เพิ่มคอมเมนต์ให้ฟังก์ชัน |
| `--backup` | Create backup before changes | สำรองข้อมูลก่อนเปลี่ยนแปลง |
| `--dry-run` | Preview changes only | ดูผลลัพธ์เท่านั้น |
| `--verbose` | Show detailed information |
| `--help` | Show help message |
### File Processing Options
| Option | Description |
|---------|-------------|
| `--recursive` | Process subdirectories |
| `--ext .js,.ts` | Specific file types |
| `--format` | Code beautification |
## Advanced Features
### **Smart Comment Detection**
- **/* */ to // Conversion**: Automatically convert block comments to line comments
- **Bilingual Support**: Add Thai/English descriptions
- **Context Awareness**: Preserve code structure and formatting
- **AI-Friendly Format**: Generate compatible comment formats for AI assistants
### **Enterprise Security**
- **Path Traversal Protection**: Prevent directory traversal attacks
- **System Directory Blocking**: Block access to critical system paths
- **Input Validation**: Validate and sanitize all user inputs
- **File Size Limits**: Prevent processing oversized files
- **Permission Checking**: Verify file access permissions
### **High Performance**
- **Fast Processing**: 1000+ files in seconds
- **Memory Efficient**: Optimized for large codebases
- **Smart Filtering**: Automatically skip irrelevant files
- **Parallel Processing**: Multi-threaded when possible
### **Supported File Types**
**JavaScript Family:**
- JavaScript (.js), TypeScript (.ts), JSX (.jsx), TSX (.tsx)
- ES6+ modules, CommonJS, AMD
- Node.js scripts and modules
**Project Files:**
- Configuration files with JavaScript syntax
- Build scripts and automation files
- Test files and specifications
## Advanced Usage Examples
### Security Testing Examples
```bash
# Safe: Fix your project with backup
npx @chahuadev/fix-comments@beta ./my-project --backup --dry-run
# BLOCKED: System directory access denied
npx @chahuadev/fix-comments@beta C:\Windows\System32
# Result: Security Error: Access to system directories is not allowed
# BLOCKED: Path traversal attempt denied
npx @chahuadev/fix-comments@beta "../../../etc/passwd"
# Result: Security Error: Path traversal detected
```
### Production Examples
```bash
# Fix JavaScript project with TypeScript support
npx @chahuadev/fix-comments@beta ./src --ext .js,.jsx,.ts,.tsx --backup
# Add missing comments recursively
npx @chahuadev/fix-comments@beta . --add-missing --recursive
# AI-friendly mode with verbose output
npx @chahuadev/fix-comments@beta . --ai-mode --dry-run --verbose
# Process single file safely
npx @chahuadev/fix-comments@beta app.js --backup
```
### Before and After Examples
#### Before Transformation:
```javascript
/**
* Get user data from database
*/
async function getUserData(userId) {
return await db.users.findById(userId);
}
```
#### After Transformation:
```javascript
// Get user data from database
// @function getUserData - Async function for database operations
// @param {string} userId - User identifier for database query
// @returns {Promise