Devin2Discord Botプロジェクトへの貢献を歓迎します!このガイドラインに従って、スムーズで効率的な開発プロセスを実現しましょう。
- 包容性: 全ての貢献者を歓迎し、多様性を尊重します
- 敬意: 建設的で敬意に満ちたコミュニケーションを心がけます
- 協力: チーム開発の精神で、互いに学び合い、助け合います
- 品質: 高品質なコードとドキュメントの維持に努めます
- 個人攻撃や差別的発言
- スパムや宣伝行為
- プロジェクトと無関係な議論
- 機密情報の漏洩
バグを見つけた場合は、以下の手順で報告してください:
## バグ報告テンプレート
**概要**
バグの簡潔な説明
**再現手順**
1. 実行したコマンド
2. 期待される動作
3. 実際の動作
**環境情報**
- OS:
- Node.js バージョン:
- Discord Bot バージョン:
**ログ・エラーメッセージ**関連するログやスクリーンショット
新機能の提案は Issues で行ってください:
## 機能提案テンプレート
**提案の背景**
この機能が必要な理由
**提案内容**
具体的な機能の説明
**期待される効果**
この機能による改善点
**実装の考慮点**
技術的な制約や課題
**代替案**
他の解決方法があれば記載- API仕様書の更新
- 開発者ガイドの改善
- README の拡充
- コメントの追加・改善
- カバレッジの向上
- エッジケースのテスト
- 統合テストの充実
- パフォーマンステスト
# 1. GitHubでリポジトリをフォーク
# 2. フォークしたリポジトリをクローン
git clone https://github.com/your-username/devin2discord.git
cd devin2discord
# 3. アップストリームリモート追加
git remote add upstream https://github.com/original/devin2discord.git# 依存関係インストール
npm install
# 環境設定ファイル作成
cp .env.example .env
# .envファイルを適切に設定
# Redisサーバー起動(Docker使用)
docker run -d --name devin2discord-redis -p 6379:6379 redis:7-alpine
# 開発サーバー起動
npm run dev// .vscode/settings.json
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.preferences.importModuleSpecifier": "relative"
}# pre-commit hook設置
npx husky install
npx husky add .husky/pre-commit "npm run lint && npm test"
npx husky add .husky/commit-msg "npx commitlint --edit $1"# 機能開発ブランチ作成
git checkout -b feature/amazing-new-feature
# バグ修正ブランチ作成
git checkout -b fix/critical-bug-fix
# ドキュメント更新ブランチ
git checkout -b docs/api-documentation-update| タイプ | 接頭辞 | 例 |
|---|---|---|
| 新機能 | feature/ |
feature/session-timeout-management |
| バグ修正 | fix/ |
fix/memory-leak-in-redis-client |
| ドキュメント | docs/ |
docs/deployment-guide-update |
| リファクタリング | refactor/ |
refactor/error-handling-improvement |
| パフォーマンス | perf/ |
perf/optimize-database-queries |
| テスト | test/ |
test/add-integration-test-coverage |
Conventional Commits 形式を使用:
# 形式
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
# 例
feat(commands): add session timeout management
Implement automatic session timeout after 30 minutes of inactivity.
This prevents resource leaks and improves overall system stability.
Closes #123feat: 新機能fix: バグ修正docs: ドキュメントのみ変更style: フォーマット、セミコロン欠落など(機能に影響しない)refactor: リファクタリングperf: パフォーマンス向上test: テスト追加・修正chore: ビルドプロセスやツール変更
# 1. 最新のmainブランチを取得
git checkout main
git pull upstream main
# 2. 機能ブランチ作成
git checkout -b feature/new-awesome-feature
# 3. 開発・テスト
npm run dev
npm test
# 4. コミット
git add .
git commit -m "feat(commands): add new awesome feature"
# 5. プッシュ
git push origin feature/new-awesome-feature
# 6. プルリクエスト作成// ✅ 良い例
interface SessionConfig {
timeout: number;
maxRetries: number;
enableLogging: boolean;
}
class SessionManager {
private readonly config: SessionConfig;
constructor(config: SessionConfig) {
this.config = config;
}
public async createSession(task: string): Promise<Session> {
// 実装
}
}
// ❌ 悪い例
interface sessionConfig {
timeout;
maxRetries;
enableLogging;
}
class sessionManager {
config;
constructor(config) {
this.config = config;
}
createSession(task) {
// 実装
}
}| 要素 | 規則 | 例 |
|---|---|---|
| クラス | PascalCase | SessionManager, CommandHandler |
| 関数・メソッド | camelCase | createSession, validateInput |
| 変数 | camelCase | sessionId, userRoles |
| 定数 | UPPER_SNAKE_CASE | MAX_RETRIES, DEFAULT_TIMEOUT |
| インターフェース | PascalCase | SessionData, CommandResult |
| 列挙型 | PascalCase | SessionStatus, ErrorType |
// ファイル冒頭のimport順序
// 1. Node.js標準ライブラリ
import fs from 'fs';
import path from 'path';
// 2. 外部ライブラリ
import axios from 'axios';
import { Client } from 'discord.js';
// 3. 内部モジュール(相対パス)
import { SessionManager } from './services/session-manager';
import { Logger } from '../utils/logger';
import { SessionData } from '../types';// ✅ 良い例 - 具体的なエラークラス使用
try {
const session = await this.devinClient.createSession(task);
return session;
} catch (error) {
if (error instanceof DevinApiError) {
Logger.warn('Devin API error', { error: error.message, statusCode: error.statusCode });
throw new SessionError(`Failed to create Devin session: ${error.message}`, sessionId);
}
Logger.error('Unexpected error during session creation', { error });
throw error;
}
// ❌ 悪い例 - 汎用的すぎるエラー処理
try {
const session = await this.devinClient.createSession(task);
return session;
} catch (error) {
console.log('Error:', error);
throw new Error('Something went wrong');
}// ✅ 良い例 - 構造化ログ
Logger.info('Session created successfully', {
sessionId: session.id,
userId: context.userId,
guildId: context.guildId,
task: task.substring(0, 50) + (task.length > 50 ? '...' : '')
});
// ❌ 悪い例 - プリミティブログ
console.log(`Session ${session.id} created for user ${context.userId}`);tests/
├── unit/ # 単体テスト
│ ├── commands/
│ ├── services/
│ └── utils/
├── integration/ # 統合テスト
│ ├── full-workflow.test.ts
│ └── api-integration.test.ts
└── mocks/ # モックオブジェクト
├── redis.ts
└── devin.ts
describe('CommandHandler', () => {
let commandHandler: CommandHandler;
let mockConfigHelper: jest.Mocked<ConfigHelper>;
beforeEach(() => {
mockConfigHelper = createMockConfigHelper();
commandHandler = new CommandHandler(mockConfigHelper);
});
describe('parseCommand', () => {
test('should parse run command correctly', () => {
// Arrange
const content = '@devin-bot run Fix authentication bug';
// Act
const result = commandHandler.parseCommand(content);
// Assert
expect(result).toEqual({
command: 'run',
args: ['Fix', 'authentication', 'bug']
});
});
test('should return null for invalid command', () => {
const content = 'regular message';
const result = commandHandler.parseCommand(content);
expect(result).toBeNull();
});
});
});describe('Full Session Lifecycle', () => {
test('should complete session workflow successfully', async () => {
// Given - セットアップ
const context = createTestContext();
const task = 'Fix authentication bug';
// When - 実行
const runResult = await runCommand.execute(context, [task]);
const sessionId = runResult.sessionId!;
// Then - 検証
expect(runResult.success).toBe(true);
const session = await redis.getSession(sessionId);
expect(session).toBeDefined();
expect(session!.taskDescription).toBe(task);
});
});# 全テスト実行
npm test
# 単体テストのみ
npm run test:unit
# 統合テストのみ
npm run test:integration
# カバレッジ付き実行
npm run test:coverage
# 監視モード
npm run test:watch
# 特定テストファイル
npm test -- command-handler.test.ts| メトリック | 最小値 | 推奨値 |
|---|---|---|
| Statements | 80% | 90%+ |
| Branches | 75% | 85%+ |
| Functions | 80% | 90%+ |
| Lines | 80% | 90%+ |
- 全てのテストが通る (
npm test) - ESLintエラーがない (
npm run lint) - TypeScriptビルドが成功 (
npm run build) - 関連ドキュメントを更新
- カバレッジが低下していない
- コミットメッセージがConventional Commits形式
## 概要
この PR の目的と背景を簡潔に説明してください。
## 変更内容
- [ ] 新機能追加
- [ ] バグ修正
- [ ] リファクタリング
- [ ] ドキュメント更新
- [ ] テスト追加・改善
### 主な変更点
1.
2.
3.
## 関連Issue
Closes #(issue number)
## テスト
どのようにテストしたかを説明してください:
- [ ] 単体テスト追加
- [ ] 統合テスト追加
- [ ] 手動テスト実施
## チェックリスト
- [ ] コードは本プロジェクトのスタイルガイドに従っている
- [ ] 自己レビューを実施済み
- [ ] 関連ドキュメントを更新
- [ ] テストを追加し、全て通過している
- [ ] breaking changeがある場合、マイグレーションガイドを追加
## スクリーンショット(該当する場合)
## 追加コメント
レビュアーに特に注意して見てもらいたい点があれば記載してください。- 機能性: 意図した通りに動作するか
- 品質: コードが読みやすく、保守しやすいか
- セキュリティ: セキュリティ上の問題がないか
- パフォーマンス: パフォーマンスに悪影響がないか
- テスト: 十分なテストカバレッジがあるか
# 建設的なフィードバック例
## 👍 良い点
- エラーハンドリングが適切に実装されている
- テストカバレッジが向上している
## 💡 改善提案
- この関数は複雑すぎるので、小さな関数に分割することを検討してください
- ログレベルを考慮して、適切なレベル(info/warn/error)を使用してください
## ❓ 質問
- この実装でメモリリークの可能性はありませんか?
- エラーケース X の処理はどのように考えていますか?
## 🐛 問題
- Line 42: 型アサーションよりも型ガードの使用を推奨します- 最低2名のレビュアーの承認
- 全てのCIチェックが通過
- コンフリクトが解決済み
- 関連ドキュメントが更新済み
---
name: Bug Report
about: バグを報告
title: '[BUG] '
labels: bug
assignees: ''
---
## バグの概要
何が起こっているかを明確で簡潔に説明してください。
## 再現手順
1. ...
2. ...
3. ...
## 期待される動作
何が起こるべきかを明確で簡潔に説明してください。
## 実際の動作
実際に何が起こっているかを明確で簡潔に説明してください。
## 環境情報
- OS: [例: Windows 11]
- Node.js: [例: 20.9.0]
- npm: [例: 10.1.0]
- Bot バージョン: [例: 1.2.3]
## ログ・エラーメッセージ関連するログやエラーメッセージをここに貼り付けてください
## 追加コンテキスト
このバグに関する他の追加情報をここに追加してください。
---
name: Feature Request
about: 新機能を提案
title: '[FEATURE] '
labels: enhancement
assignees: ''
---
## 機能要求の概要
欲しい機能を明確で簡潔に説明してください。
## 解決したい問題
この機能要求が解決する問題を説明してください。例: ~することができなくて困っています [...]
## 提案する解決策
あなたが望む実現方法を明確で簡潔に説明してください。
## 検討した代替案
検討した代替ソリューションや機能があれば明確で簡潔に説明してください。
## 追加コンテキスト
この機能要求に関する他の追加情報やスクリーンショットをここに追加してください。| ラベル | 説明 |
|---|---|
bug |
バグ報告 |
enhancement |
新機能・改善提案 |
documentation |
ドキュメント関連 |
good first issue |
初心者向け |
help wanted |
外部からの協力を求める |
priority: high |
高優先度 |
priority: medium |
中優先度 |
priority: low |
低優先度 |
Semantic Versioning を採用:
MAJOR.MINOR.PATCH
例: 1.2.3
- MAJOR: 破壊的変更
- MINOR: 後方互換性のある新機能
- PATCH: 後方互換性のあるバグ修正
# 1. developブランチから最新コードを取得
git checkout develop
git pull origin develop
# 2. リリースブランチ作成
git checkout -b release/v1.2.0
# 3. バージョン更新
npm version minor # または major, patch
# 4. CHANGELOG.md 更新
# 手動でCHANGELOG.mdを更新
# 5. リリースブランチをプッシュ
git push origin release/v1.2.0
# 6. プルリクエスト作成 (release/v1.2.0 → main)
# 7. レビュー・承認後マージ
# 8. タグ作成・リリース
git checkout main
git pull origin main
git tag v1.2.0
git push origin v1.2.0
# 9. GitHub Releaseを作成# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.2.0] - 2024-XX-XX
### Added
- Session timeout management
- Enhanced error handling with custom error classes
### Changed
- Improved command response formatting
- Updated dependencies to latest versions
### Deprecated
- Old configuration format (will be removed in v2.0.0)
### Removed
- Unused utility functions
### Fixed
- Memory leak in Redis connection handling
- Race condition in session status updates
### Security
- Enhanced input validation for user commands| レベル | 要件 | 特典 |
|---|---|---|
| Contributor | 1+ merged PR | 名前がCONTRIBUTORS.mdに記載 |
| Regular Contributor | 5+ merged PR | README.mdに名前掲載 |
| Core Contributor | 20+ merged PR または重要機能実装 | プロジェクト運営への参加権 |
月次で以下を集計・公開:
- Merged PRs 数
- Code Lines Added/Removed
- Issue Reports
- Code Reviews
- GitHub Discussions: 機能提案・質問
- GitHub Issues: バグ報告・タスク管理
- Discord: リアルタイム相談(開発者サーバー)
A: Dockerが起動していることを確認し、ポート6379が使用中でないかチェックしてください。
A: 環境変数が正しく設定されているか確認してください。特にREDIS_URLとNODE_ENV=test。
A: npm run lint -- --fix で自動修正可能なエラーは自動修正されます。
このガイドラインに従って、素晴らしい貢献をお待ちしています!質問や不明点があれば、遠慮なくIssueやDiscussionで質問してください。 🚀