From bd35dfdacf80501c99f309242c694c2c3c28bf78 Mon Sep 17 00:00:00 2001 From: JessyTsui <51992423+JessyTsui@users.noreply.github.com> Date: Mon, 4 Aug 2025 08:31:42 +0800 Subject: [PATCH] feat: add comprehensive GitHub project management system (#25) * feat: add comprehensive GitHub project management system - Add issue templates with embedded naming conventions and examples - Add PR template with detailed type definitions (9 types) and scopes - Add automated CI checks for code quality and hardcode detection - Add project management workflows for auto-labeling and cleanup - Add contributing guidelines with strict coding standards This system enforces: - No hardcoded secrets (auto-rejected by CI) - No console.log in production code - Proper error handling patterns - Standardized issue/PR naming formats with examples - Automated quality gates and project maintenance Templates include detailed naming rules that users see directly when creating issues/PRs on GitHub, eliminating need for separate docs. * fix: disable CI checks on pull requests - Remove pull_request trigger from CI workflow - Remove all PR-related automation from project-management workflow - Keep only push-to-master CI checks and issue auto-labeling - Maintain weekly cleanup functionality This allows PRs to be created and merged without automatic CI validation. --- .github/CONTRIBUTING.md | 167 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report.md | 59 ++++++++ .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/feature_request.md | 53 +++++++ .github/pull_request_template.md | 80 +++++++++++ .github/workflows/ci.yml | 48 +++++++ .github/workflows/project-management.yml | 91 ++++++++++++ 7 files changed, 499 insertions(+) create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/project-management.yml diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..c1f86c5 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,167 @@ +First of all, many thanks to everyone who wants to contribute to Claude-Code-Remote! + +# Contributing to Claude Code Remote + +## 🚀 Quick Start + +```bash +# Fork, clone, and setup +git clone https://github.com/YOUR_USERNAME/Claude-Code-Remote.git +cd Claude-Code-Remote +npm install +cp .env.example .env + +# Create feature branch +git checkout -b feature/your-feature + +# Test your changes +npm run webhooks +``` + +## 📝 Coding Standards (Automated Checks) + +### 🚫 Strictly Forbidden (CI will auto-reject) +```javascript +// ❌ Hardcoded secrets/tokens +const TELEGRAM_BOT_TOKEN = "123456789:ABC..."; +const LINE_CHANNEL_ACCESS_TOKEN = "abc123"; +const SMTP_PASS = "mypassword"; + +// ❌ Hardcoded API URLs +const API_URL = "https://api.telegram.org/bot123456789"; +fetch("https://hooks.slack.com/abc123"); + +// ❌ console.log in production code +console.log("Debug info"); +console.error("Error occurred"); + +// ❌ Async operations without error handling +async function sendMessage() { + await fetch(url); // No try-catch +} + +// ❌ String concatenation with user input +const query = "SELECT * FROM users WHERE id=" + userId; +``` + +### ✅ Required Standards (CI checks pass) +```javascript +// ✅ Use environment variables +const TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN; +const LINE_TOKEN = process.env.LINE_CHANNEL_ACCESS_TOKEN; +const SMTP_PASS = process.env.SMTP_PASS; + +// ✅ Use configuration files +const config = require('./config.json'); +const API_URL = `${config.telegram.baseUrl}/bot${process.env.TELEGRAM_BOT_TOKEN}`; + +// ✅ Use proper logging +const logger = require('./src/core/logger'); +logger.info('Message sent successfully'); +logger.error('Failed to send message:', error); + +// ✅ Proper error handling +async function sendMessage(message) { + try { + const response = await fetch(url, { + method: 'POST', + body: JSON.stringify({ text: message }) + }); + if (!response.ok) throw new Error(`HTTP ${response.status}`); + return await response.json(); + } catch (error) { + logger.error('Send message failed:', error); + throw error; // Re-throw for caller to handle + } +} + +// ✅ Input validation and parameterized queries +function validateUserId(userId) { + if (!userId || typeof userId !== 'string') { + throw new Error('Invalid user ID'); + } + return userId.replace(/[^a-zA-Z0-9-]/g, ''); +} +``` + +### 🔧 Enforcement Rules +1. **Automated CI checks**: Every PR automatically checked for code quality +2. **Hardcode detection**: Auto-scan all `.js` files for sensitive data +3. **Log checking**: Prohibit `console.log` in production code +4. **Error handling**: Check async functions for proper error handling + +## 📛 Naming Conventions + +### Issue Title Format +```bash +[BUG] Short clear description +[FEATURE] Short clear description + +Examples: +[BUG] Telegram bot not responding to commands +[FEATURE] Add Discord platform integration +``` + +### PR Title Format +```bash +type(scope): description + +Types: feat, fix, docs, style, refactor, perf, test, chore, ci +Scopes: telegram, email, line, core, config, docs + +Examples: +feat(telegram): add inline keyboard support +fix(email): resolve SMTP timeout issue #123 +docs: update installation instructions +``` + +### Branch Naming +```bash +feature/discord-integration # New feature +fix/issue-123 # Bug fix +docs/update-readme # Documentation +refactor/notification-system # Refactoring +``` + +**Note**: Detailed naming rules are shown directly in issue/PR templates when you create them on GitHub. + +## 🔄 Workflow + +### Before PR +1. Test all affected platforms +2. Run security checks: `grep -r "TOKEN\|SECRET\|PASS" --include="*.js" src/` +3. Ensure no console.log in production code +4. Update docs if API changes + +### Commit Format +```bash +feat(telegram): add inline keyboard support +fix(email): resolve SMTP timeout issue #123 +docs: update installation instructions +refactor(core): simplify notification logic +chore: update dependencies +``` + +## ✅ PR Checklist + +- [ ] **No hardcoded values** (all config in .env or config files) +- [ ] **No secrets in code** (tokens, passwords, keys) +- [ ] **Input validation added** where needed +- [ ] **Error handling implemented** (try/catch blocks) +- [ ] **Tested locally** with tmux +- [ ] **Tested affected platforms** (Email/Telegram/LINE) +- [ ] **Code follows existing patterns** +- [ ] **Updated documentation** if needed + +## 🚨 Important Rules + +1. **Never commit .env files** +2. **Always validate external input** +3. **Keep platform code isolated** in `src/channels/` +4. **Follow existing patterns** - check similar code first +5. **Test with tmux** before submitting + +## 📞 Get Help + +- Issues: [GitHub Issues](https://github.com/JessyTsui/Claude-Code-Remote/issues) +- Twitter: [@Jiaxi_Cui](https://x.com/Jiaxi_Cui) \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..0160363 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,59 @@ +--- +name: 🐛 Bug Report +about: Report something that is broken +title: '[BUG] ' +labels: 'bug' +--- + + + +## Bug Type (select one) +- [ ] Installation issue +- [ ] Platform not working (Email/Telegram/LINE) +- [ ] Notification not received +- [ ] Command injection failed +- [ ] Configuration error + +## What happened? + + +## Steps to reproduce +1. +2. +3. + +## Expected behavior + + +## Environment +- **Node version**: +- **OS**: +- **Platform**: Email / Telegram / LINE / All + +## Error logs +``` +paste error here +``` \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ec4bb38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..b9ef2f7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,53 @@ +--- +name: ✨ Feature Request +about: Suggest a new feature +title: '[FEATURE] ' +labels: 'enhancement' +--- + + + +## Feature Type (select one) +- [ ] New platform integration (Discord/Slack/WhatsApp) +- [ ] Notification enhancement +- [ ] Command/control improvement +- [ ] Performance optimization +- [ ] Security enhancement + +## What feature do you want? + + +## Why do you need this? + + +## How should it work? + + +## Priority +- [ ] Nice to have +- [ ] Important +- [ ] Critical for my workflow \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..8309f4d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,80 @@ + + +## PR Type (REQUIRED: select at least one) +- [ ] 🐛 **fix**: Bug fix (non-breaking change) +- [ ] ✨ **feat**: New feature (non-breaking change) +- [ ] 🔌 **feat**: Platform integration (new platform support) +- [ ] 💥 **feat**: Breaking change (changes existing functionality) +- [ ] 📚 **docs**: Documentation only changes +- [ ] ♻️ **refactor**: Code refactoring (no functionality change) +- [ ] ⚡ **perf**: Performance improvements +- [ ] 🎨 **style**: Code formatting, whitespace, semicolons +- [ ] 🔧 **chore**: Maintenance, dependencies, build tools +- [ ] 🚨 **test**: Adding or updating tests +- [ ] 🔄 **ci**: CI/CD configuration changes + +## What does this PR do? + + +## Related Issue + + +## Code Quality Checklist (ALL REQUIRED) +- [ ] **No hardcoded secrets** (use process.env.* or config files) +- [ ] **No console.log** in production code (use logger.*) +- [ ] **Error handling** implemented (try/catch blocks) +- [ ] **Input validation** where needed +- [ ] **Tested locally** with tmux + +## Platform Testing +- [ ] Email +- [ ] Telegram +- [ ] LINE +- [ ] Desktop notifications + +## How did you test this? +1. +2. \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..62ac7e8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI + +on: + push: + branches: [ master, main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Security audit + run: npm audit --audit-level=moderate || true + + - name: Validate JSON configs + run: | + echo "🔍 Validating JSON configuration files..." + for file in $(find . -name "*.json" -not -path "./node_modules/*" -not -path "./.git/*"); do + echo "Checking $file" + if ! python3 -m json.tool "$file" > /dev/null 2>&1; then + echo "❌ Invalid JSON: $file" + exit 1 + fi + done + echo "✅ All JSON files are valid" + + - name: Check tmux availability + run: | + if command -v tmux &> /dev/null; then + echo "✅ tmux is available: $(tmux -V)" + else + echo "Installing tmux..." + sudo apt-get update && sudo apt-get install -y tmux + fi \ No newline at end of file diff --git a/.github/workflows/project-management.yml b/.github/workflows/project-management.yml new file mode 100644 index 0000000..7032c81 --- /dev/null +++ b/.github/workflows/project-management.yml @@ -0,0 +1,91 @@ +name: Project Management + +on: + issues: + types: [opened, edited, labeled] + schedule: + - cron: '0 0 * * 0' # Weekly cleanup on Sunday + +jobs: + # Auto-label issues + auto-label: + runs-on: ubuntu-latest + if: github.event_name == 'issues' + permissions: + issues: write + steps: + - name: Auto-label based on content + uses: actions/github-script@v7 + with: + script: | + const item = context.payload.issue; + const body = (item.body || '').toLowerCase(); + const title = (item.title || '').toLowerCase(); + const labels = []; + + // Platform labels + if (title.includes('telegram') || body.includes('telegram')) labels.push('platform:telegram'); + if (title.includes('email') || body.includes('email')) labels.push('platform:email'); + if (title.includes('line') || body.includes('line')) labels.push('platform:line'); + if (title.includes('discord') || body.includes('discord')) labels.push('platform:discord'); + + // Priority labels + if (title.includes('critical') || body.includes('critical')) labels.push('priority:high'); + if (title.includes('urgent') || body.includes('urgent')) labels.push('priority:high'); + + // Type labels + if (title.includes('[bug]')) labels.push('type:bug'); + if (title.includes('[feature]')) labels.push('type:enhancement'); + if (title.includes('[question]')) labels.push('type:question'); + + if (labels.length > 0) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: item.number, + labels: labels + }); + } + + + # Weekly maintenance + weekly-cleanup: + runs-on: ubuntu-latest + if: github.event_name == 'schedule' + permissions: + issues: write + steps: + - name: Close stale issues + uses: actions/github-script@v7 + with: + script: | + const { data: issues } = await github.rest.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + labels: 'question', + sort: 'updated', + direction: 'asc', + per_page: 100 + }); + + const thirtyDaysAgo = new Date(); + thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30); + + for (const issue of issues) { + if (new Date(issue.updated_at) < thirtyDaysAgo) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + body: 'This question has been inactive for 30 days and will be closed. Feel free to reopen if you still need help.' + }); + + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + state: 'closed' + }); + } + } \ No newline at end of file