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.
This commit is contained in:
parent
41543eb4b9
commit
bd35dfdacf
|
|
@ -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)
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
name: 🐛 Bug Report
|
||||
about: Report something that is broken
|
||||
title: '[BUG] '
|
||||
labels: 'bug'
|
||||
---
|
||||
|
||||
<!--
|
||||
🏷️ ISSUE TITLE NAMING RULES:
|
||||
Format: [BUG] Short clear description of the problem
|
||||
|
||||
✅ GOOD EXAMPLES:
|
||||
- [BUG] Telegram bot not responding to commands
|
||||
- [BUG] Email notifications fail with SMTP timeout error
|
||||
- [BUG] LINE webhook returns 401 unauthorized
|
||||
- [BUG] Desktop notifications not showing on macOS
|
||||
- [BUG] Installation fails on Windows with Node 18
|
||||
- [BUG] tmux session detection not working
|
||||
- [BUG] Hook configuration file not found
|
||||
|
||||
❌ BAD EXAMPLES:
|
||||
- Bug report (no [BUG] prefix)
|
||||
- [BUG] It doesn't work (too vague)
|
||||
- Telegram issue (no [BUG] prefix, not descriptive)
|
||||
- [BUG] Problem (not descriptive enough)
|
||||
|
||||
📋 AVAILABLE ISSUE TYPES:
|
||||
1. 🐛 Bug Report (this template) - Report broken functionality
|
||||
2. ✨ Feature Request - Request new features
|
||||
3. Create Discussion instead for questions
|
||||
-->
|
||||
|
||||
## Bug Type (select one)
|
||||
- [ ] Installation issue
|
||||
- [ ] Platform not working (Email/Telegram/LINE)
|
||||
- [ ] Notification not received
|
||||
- [ ] Command injection failed
|
||||
- [ ] Configuration error
|
||||
|
||||
## What happened?
|
||||
<!-- Clear description -->
|
||||
|
||||
## Steps to reproduce
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
## Expected behavior
|
||||
<!-- What should happen? -->
|
||||
|
||||
## Environment
|
||||
- **Node version**:
|
||||
- **OS**:
|
||||
- **Platform**: Email / Telegram / LINE / All
|
||||
|
||||
## Error logs
|
||||
```
|
||||
paste error here
|
||||
```
|
||||
|
|
@ -0,0 +1 @@
|
|||
blank_issues_enabled: false
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
name: ✨ Feature Request
|
||||
about: Suggest a new feature
|
||||
title: '[FEATURE] '
|
||||
labels: 'enhancement'
|
||||
---
|
||||
|
||||
<!--
|
||||
🏷️ ISSUE TITLE NAMING RULES:
|
||||
Format: [FEATURE] Short clear description of the feature
|
||||
|
||||
✅ GOOD EXAMPLES:
|
||||
- [FEATURE] Add Discord platform integration
|
||||
- [FEATURE] Auto-retry failed notifications
|
||||
- [FEATURE] Export command history to CSV
|
||||
- [FEATURE] Add support for Slack webhooks
|
||||
- [FEATURE] Implement notification scheduling
|
||||
- [FEATURE] Add multi-language support
|
||||
- [FEATURE] Command rate limiting
|
||||
- [FEATURE] Notification templates customization
|
||||
|
||||
❌ BAD EXAMPLES:
|
||||
- Feature request (no [FEATURE] prefix)
|
||||
- [FEATURE] New feature (too vague)
|
||||
- Discord support (no [FEATURE] prefix)
|
||||
- [FEATURE] Improvement (not specific enough)
|
||||
|
||||
📋 AVAILABLE ISSUE TYPES:
|
||||
1. 🐛 Bug Report - Report broken functionality
|
||||
2. ✨ Feature Request (this template) - Request new features
|
||||
3. Create Discussion instead for questions
|
||||
-->
|
||||
|
||||
## Feature Type (select one)
|
||||
- [ ] New platform integration (Discord/Slack/WhatsApp)
|
||||
- [ ] Notification enhancement
|
||||
- [ ] Command/control improvement
|
||||
- [ ] Performance optimization
|
||||
- [ ] Security enhancement
|
||||
|
||||
## What feature do you want?
|
||||
<!-- Clear description -->
|
||||
|
||||
## Why do you need this?
|
||||
<!-- What problem does it solve? -->
|
||||
|
||||
## How should it work?
|
||||
<!-- Describe the solution -->
|
||||
|
||||
## Priority
|
||||
- [ ] Nice to have
|
||||
- [ ] Important
|
||||
- [ ] Critical for my workflow
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<!--
|
||||
🏷️ PR TITLE NAMING RULES:
|
||||
Format: type(scope): description
|
||||
|
||||
📋 AVAILABLE PR TYPES (choose one for title):
|
||||
- feat: New feature or enhancement
|
||||
- fix: Bug fix
|
||||
- docs: Documentation only changes
|
||||
- style: Code formatting, whitespace, semicolons
|
||||
- refactor: Code refactoring (no functionality change)
|
||||
- perf: Performance improvements
|
||||
- test: Adding or updating tests
|
||||
- chore: Maintenance, dependencies, build tools
|
||||
- ci: CI/CD configuration changes
|
||||
|
||||
📍 SCOPES (optional but recommended):
|
||||
- telegram: Telegram platform
|
||||
- email: Email platform
|
||||
- line: LINE platform
|
||||
- discord: Discord platform
|
||||
- core: Core functionality
|
||||
- config: Configuration files
|
||||
- docs: Documentation
|
||||
|
||||
✅ GOOD PR TITLE EXAMPLES:
|
||||
- feat(telegram): add inline keyboard support
|
||||
- fix(email): resolve SMTP timeout issue #123
|
||||
- feat(discord): add Discord platform integration
|
||||
- docs: update installation instructions
|
||||
- refactor(core): simplify notification logic
|
||||
- perf(telegram): optimize message sending speed
|
||||
- fix(line): handle webhook authentication error
|
||||
- chore: update dependencies to latest versions
|
||||
- style(core): fix code formatting and indentation
|
||||
- test(email): add unit tests for SMTP connection
|
||||
- ci: add automated security scanning
|
||||
|
||||
❌ BAD PR TITLE EXAMPLES:
|
||||
- Add feature (no type, no scope)
|
||||
- Fix bug (too vague, no scope)
|
||||
- Update code (not descriptive)
|
||||
- telegram fix (wrong format)
|
||||
- New Discord support (missing type prefix)
|
||||
-->
|
||||
|
||||
## 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?
|
||||
<!-- Clear description -->
|
||||
|
||||
## Related Issue
|
||||
<!-- Fixes #123 or Closes #123 -->
|
||||
|
||||
## 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.
|
||||
|
|
@ -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
|
||||
|
|
@ -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'
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue