#!/usr/bin/env node import { GogsClient } from './dist/gogs-client.js'; import dotenv from 'dotenv'; dotenv.config(); const client = new GogsClient({ serverUrl: process.env.GOGS_SERVER_URL, accessToken: process.env.GOGS_ACCESS_TOKEN, }); const owner = 'claude'; const repo = 'gogs-mcp'; const issueNumber = 4; async function main() { try { // Step 1: Fetch issue #4 console.log('Fetching issue #4...'); const issue = await client.getIssue(owner, repo, issueNumber); console.log(`Issue #${issue.number}: ${issue.title}`); console.log(`Body: ${issue.body}`); console.log('---'); // Step 2: Fetch all comments console.log('Fetching comments...'); const comments = await client.listIssueComments(owner, repo, issueNumber); console.log(`Found ${comments.length} comments:`); comments.forEach((comment, idx) => { console.log(`\nComment ${idx + 1} by ${comment.user.login}:`); console.log(comment.body); }); console.log('---'); // Step 3: Get all labels console.log('Fetching available labels...'); const labels = await client.listLabels(owner, repo); console.log(`Found ${labels.length} labels:`); labels.forEach(label => { console.log(`- ${label.name} (ID: ${label.id}, Color: ${label.color})`); }); console.log('---'); // Step 4: Get current user const currentUser = await client.getCurrentUser(); console.log(`Current user: ${currentUser.username}`); console.log('---'); // Step 5: Create new issues based on the requirements const featuresToCreate = [ { title: 'Feature: Milestones support', body: `## Description Add support for Gogs Milestones functionality to the MCP server. ## Why This Feature? Essential for project management - allows grouping issues and tracking progress towards specific goals. ## Requirements - Implement \`list_milestones\` tool - Implement \`get_milestone\` tool - Implement \`create_milestone\` tool - Implement \`update_milestone\` tool - Implement \`delete_milestone\` tool - Add proper TypeScript types for Milestone objects - Update documentation with usage examples ## Related Requested by @fszontagh in #${issueNumber} ## API Reference See Gogs API documentation for milestones endpoints.`, labels: ['enhancement', 'feature'] }, { title: 'Feature: Organizations & Teams support', body: `## Description Add support for Gogs Organizations and Teams functionality to the MCP server. ## Why This Feature? Critical for multi-user workflows - enables proper access control and team collaboration. ## Requirements - Implement \`list_orgs\` tool - Implement \`get_org\` tool - Implement \`create_org\` tool - Implement \`list_teams\` tool - Implement \`get_team\` tool - Implement \`create_team\` tool - Implement \`add_team_member\` tool - Implement \`remove_team_member\` tool - Add proper TypeScript types for Organization and Team objects - Update documentation with usage examples ## Related Requested by @fszontagh in #${issueNumber} ## API Reference See Gogs API documentation for organizations and teams endpoints.`, labels: ['enhancement', 'feature'] }, { title: 'Feature: Webhooks support', body: `## Description Add support for Gogs Webhooks functionality to the MCP server. ## Why This Feature? Important for CI/CD integration - enables automated workflows and external service notifications. ## Requirements - Implement \`list_hooks\` tool - Implement \`get_hook\` tool - Implement \`create_hook\` tool - Implement \`update_hook\` tool - Implement \`delete_hook\` tool - Implement \`test_hook\` tool - Add proper TypeScript types for Webhook objects - Support different webhook event types - Update documentation with usage examples ## Related Requested by @fszontagh in #${issueNumber} ## API Reference See Gogs API documentation for webhooks endpoints.`, labels: ['enhancement', 'feature'] }, { title: 'Feature: Collaborators support', body: `## Description Add support for Gogs Collaborators functionality to the MCP server. ## Why This Feature? Necessary for repository access management - allows managing who can contribute to repositories. ## Requirements - Implement \`list_collaborators\` tool - Implement \`check_collaborator\` tool - Implement \`add_collaborator\` tool - Implement \`remove_collaborator\` tool - Add proper TypeScript types for Collaborator objects - Update documentation with usage examples ## Related Requested by @fszontagh in #${issueNumber} ## API Reference See Gogs API documentation for collaborators endpoints.`, labels: ['enhancement', 'feature'] }, { title: 'Feature: User Followers support', body: `## Description Add support for Gogs User Followers functionality to the MCP server. ## Why This Feature? Useful for social features - enables tracking user relationships and building community features. ## Requirements - Implement \`list_followers\` tool - Implement \`list_following\` tool - Implement \`check_following\` tool - Implement \`follow_user\` tool - Implement \`unfollow_user\` tool - Add proper TypeScript types for Follower relationships - Update documentation with usage examples ## Related Requested by @fszontagh in #${issueNumber} ## API Reference See Gogs API documentation for user followers endpoints.`, labels: ['enhancement', 'feature'] } ]; // Find label IDs const enhancementLabel = labels.find(l => l.name === 'enhancement'); const featureLabel = labels.find(l => l.name === 'feature'); if (!enhancementLabel || !featureLabel) { console.log('Required labels not found. Creating them...'); // Would need to create labels here if they don't exist } console.log('Creating new issues...'); const createdIssues = []; for (const feature of featuresToCreate) { console.log(`Creating issue: ${feature.title}`); const newIssue = await client.createIssue(owner, repo, { title: feature.title, body: feature.body, assignee: currentUser.username, }); console.log(`Created issue #${newIssue.number}: ${newIssue.title}`); createdIssues.push(newIssue); // Add labels if they exist const labelIds = []; if (enhancementLabel) labelIds.push(enhancementLabel.id); if (featureLabel) labelIds.push(featureLabel.id); if (labelIds.length > 0) { await client.addIssueLabels(owner, repo, newIssue.number, labelIds); console.log(`Added labels to issue #${newIssue.number}`); } // Small delay to avoid rate limiting await new Promise(resolve => setTimeout(resolve, 500)); } // Step 6: Post a summary comment to issue #4 const issueLinks = createdIssues.map(i => `- #${i.number}: ${i.title}`).join('\n'); const summaryComment = `āœ… I've created the following issues as requested: ${issueLinks} All issues have been: - Assigned to @${currentUser.username} - Labeled with \`enhancement\` and \`feature\` - Properly documented with requirements and API references - Cross-referenced to this issue (#${issueNumber}) Each issue is ready for implementation. As per your instructions, I'm not closing this issue.`; console.log('\nPosting summary comment to issue #4...'); await client.createIssueComment(owner, repo, issueNumber, summaryComment); console.log('Summary comment posted!'); console.log('\nāœ… All tasks completed successfully!'); } catch (error) { console.error('Error:', error.message); if (error.response) { console.error('Response data:', error.response.data); } // Post error comment to issue try { await client.createIssueComment( owner, repo, issueNumber, `āŒ Encountered an error while processing this issue:\n\n\`\`\`\n${error.message}\n\`\`\`\n\nPlease check the logs for more details.` ); } catch (commentError) { console.error('Failed to post error comment:', commentError.message); } process.exit(1); } } main();