소스 검색

chore: Remove temporary issue management script #4

claude 9 달 전
부모
커밋
e8526bc3bf
4개의 변경된 파일305개의 추가작업 그리고 256개의 파일을 삭제
  1. 12 0
      .mcp-gogs.json
  2. 125 0
      CHANGELOG_LABELS.md
  3. 168 0
      LABEL_IMPLEMENTATION_SUMMARY.md
  4. 0 256
      manage-issue-4.js

+ 12 - 0
.mcp-gogs.json

@@ -0,0 +1,12 @@
+{
+  "mcpServers": {
+    "gogs": {
+      "type": "stdio",
+      "command": "node",
+      "args": [
+        ""
+      ],
+      "env": {}
+    }
+  }
+}

+ 125 - 0
CHANGELOG_LABELS.md

@@ -0,0 +1,125 @@
+# Changelog - Label Management Feature
+
+## [Unreleased] - 2025-10-29
+
+### Added
+
+#### Core Functionality
+- **10 new label management methods** in `GogsClient` class (src/gogs-client.ts):
+  - `listLabels(owner, repo)` - List all labels in a repository
+  - `getLabel(owner, repo, labelId)` - Get a specific label by ID
+  - `createLabel(owner, repo, data)` - Create a new label with name and color
+  - `updateLabel(owner, repo, labelId, data)` - Update an existing label
+  - `deleteLabel(owner, repo, labelId)` - Delete a label from a repository
+  - `listIssueLabels(owner, repo, issueNumber)` - List labels on a specific issue
+  - `addIssueLabels(owner, repo, issueNumber, labelIds)` - Add labels to an issue
+  - `removeIssueLabel(owner, repo, issueNumber, labelId)` - Remove a label from an issue
+  - `replaceIssueLabels(owner, repo, issueNumber, labelIds)` - Replace all labels on an issue
+  - `removeAllIssueLabels(owner, repo, issueNumber)` - Remove all labels from an issue
+
+#### MCP Server Integration
+- **10 new Zod validation schemas** in server.ts:
+  - `ListLabelsSchema` - Validates list labels request
+  - `GetLabelSchema` - Validates get single label request
+  - `CreateLabelSchema` - Validates create label request with required name and color
+  - `UpdateLabelSchema` - Validates update label request with optional fields
+  - `DeleteLabelSchema` - Validates delete label request
+  - `ListIssueLabelsSchema` - Validates list issue labels request
+  - `AddIssueLabelsSchema` - Validates add labels to issue request
+  - `RemoveIssueLabelSchema` - Validates remove label from issue request
+  - `ReplaceIssueLabelsSchema` - Validates replace issue labels request
+  - `RemoveAllIssueLabelsSchema` - Validates remove all labels request
+
+- **10 new MCP tools** registered in server.ts:
+  - `list_labels` - MCP tool to list repository labels
+  - `get_label` - MCP tool to get single label
+  - `create_label` - MCP tool to create new label
+  - `update_label` - MCP tool to update existing label
+  - `delete_label` - MCP tool to delete label
+  - `list_issue_labels` - MCP tool to list issue labels
+  - `add_issue_labels` - MCP tool to add labels to issue
+  - `remove_issue_label` - MCP tool to remove label from issue
+  - `replace_issue_labels` - MCP tool to replace all issue labels
+  - `remove_all_issue_labels` - MCP tool to remove all issue labels
+
+- **10 new handler cases** in server.ts for processing label tool requests
+
+#### Documentation
+- **README.md**:
+  - Added "Label Management" section to Features overview
+  - Added "Label Management Tools" section with comprehensive documentation
+  - Documented all 10 label management tools with parameters and descriptions
+  - Added color format specification (#rrggbb hex codes)
+
+- **USAGE_EXAMPLES.md**:
+  - Added "Label Management" section with practical examples
+  - Provided natural language usage examples for all 10 operations
+  - Demonstrated repository-level label operations
+  - Demonstrated issue-level label operations
+  - Showed examples of CRUD operations on labels
+
+#### Type System
+- Imported `GogsLabel` type in gogs-client.ts for type safety
+- All methods properly typed with TypeScript
+- Return types specified for all label operations
+
+### Changed
+- Updated import statement in gogs-client.ts to include `GogsLabel` type
+- Enhanced MCP server tool list with 10 new label management tools
+- Extended switch statement in server.ts with 10 new case handlers
+
+### Technical Details
+
+#### API Endpoints Utilized
+- `GET /repos/:owner/:repo/labels` - List repository labels
+- `GET /repos/:owner/:repo/labels/:id` - Get single label
+- `POST /repos/:owner/:repo/labels` - Create label
+- `PATCH /repos/:owner/:repo/labels/:id` - Update label
+- `DELETE /repos/:owner/:repo/labels/:id` - Delete label
+- `GET /repos/:owner/:repo/issues/:index/labels` - List issue labels
+- `POST /repos/:owner/:repo/issues/:index/labels` - Add labels to issue
+- `DELETE /repos/:owner/:repo/issues/:index/labels/:id` - Remove label from issue
+- `PUT /repos/:owner/:repo/issues/:index/labels` - Replace issue labels
+- `DELETE /repos/:owner/:repo/issues/:index/labels` - Remove all issue labels
+
+#### Code Statistics
+- Total lines added: **706**
+- Files modified: **4**
+  - src/gogs-client.ts: +126 lines
+  - src/server.ts: +441 lines
+  - README.md: +79 lines
+  - USAGE_EXAMPLES.md: +60 lines
+
+#### Build Status
+- ✅ TypeScript compilation successful
+- ✅ No type errors
+- ✅ All methods compiled to JavaScript
+- ✅ Source maps generated
+- ✅ Type definitions (.d.ts) generated
+
+### Testing
+- Verified successful TypeScript compilation
+- Confirmed all methods present in compiled output
+- Validated tool registration in MCP server
+- Checked handler implementation for all tools
+
+### Breaking Changes
+None - This is a purely additive feature
+
+### Deprecations
+None
+
+### Security
+- All label operations require appropriate Gogs server permissions
+- Access token permissions respected
+- No additional security concerns introduced
+
+### Performance
+- Label operations use standard HTTP requests to Gogs API
+- No impact on existing functionality
+- Efficient implementation with no unnecessary API calls
+
+## References
+- Issue: #3 - feat: gogs labels
+- Gogs API Documentation: docs-api/Issues/Labels.md
+- Commit: 72483e2 - feat: implement Gogs label management

+ 168 - 0
LABEL_IMPLEMENTATION_SUMMARY.md

@@ -0,0 +1,168 @@
+# Label Management Implementation Summary
+
+## Overview
+Successfully implemented comprehensive label management functionality for the Gogs MCP server, resolving issue #3.
+
+## Implementation Details
+
+### 1. Core Client Methods (src/gogs-client.ts)
+Added 10 new methods to the `GogsClient` class:
+
+#### Repository Label Management
+- **listLabels(owner, repo)**: List all labels in a repository
+- **getLabel(owner, repo, labelId)**: Get a specific label by ID
+- **createLabel(owner, repo, {name, color})**: Create a new label
+- **updateLabel(owner, repo, labelId, {name?, color?})**: Update an existing label
+- **deleteLabel(owner, repo, labelId)**: Delete a label
+
+#### Issue Label Management
+- **listIssueLabels(owner, repo, issueNumber)**: List labels on a specific issue
+- **addIssueLabels(owner, repo, issueNumber, labelIds[])**: Add labels to an issue
+- **removeIssueLabel(owner, repo, issueNumber, labelId)**: Remove a specific label from an issue
+- **replaceIssueLabels(owner, repo, issueNumber, labelIds[])**: Replace all labels on an issue
+- **removeAllIssueLabels(owner, repo, issueNumber)**: Remove all labels from an issue
+
+### 2. MCP Server Integration (src/server.ts)
+
+#### Schemas Added
+- ListLabelsSchema
+- GetLabelSchema
+- CreateLabelSchema
+- UpdateLabelSchema
+- DeleteLabelSchema
+- ListIssueLabelsSchema
+- AddIssueLabelsSchema
+- RemoveIssueLabelSchema
+- ReplaceIssueLabelsSchema
+- RemoveAllIssueLabelsSchema
+
+#### MCP Tools Registered
+All 10 label management operations are now available as MCP tools with proper:
+- Input validation using Zod schemas
+- Parameter descriptions
+- Required/optional field specifications
+- Error handling
+
+### 3. Documentation Updates
+
+#### README.md
+- Added "Label Management" section to Features
+- Documented all 10 label management tools
+- Provided parameter descriptions and requirements
+- Included examples of color format (#rrggbb)
+
+#### USAGE_EXAMPLES.md
+- Added comprehensive "Label Management" section
+- Provided natural language usage examples for all operations
+- Demonstrated both repository-level and issue-level label operations
+- Included examples of adding, removing, and replacing labels
+
+### 4. API Endpoints Implemented
+
+#### Repository Labels
+- `GET /repos/:owner/:repo/labels` - List all labels
+- `GET /repos/:owner/:repo/labels/:id` - Get single label
+- `POST /repos/:owner/:repo/labels` - Create label
+- `PATCH /repos/:owner/:repo/labels/:id` - Update label
+- `DELETE /repos/:owner/:repo/labels/:id` - Delete label
+
+#### Issue Labels
+- `GET /repos/:owner/:repo/issues/:number/labels` - List issue labels
+- `POST /repos/:owner/:repo/issues/:number/labels` - Add labels to issue
+- `DELETE /repos/:owner/:repo/issues/:number/labels/:id` - Remove label from issue
+- `PUT /repos/:owner/:repo/issues/:number/labels` - Replace all issue labels
+- `DELETE /repos/:owner/:repo/issues/:number/labels` - Remove all issue labels
+
+## Statistics
+
+- **Files Modified**: 4
+- **Lines Added**: 706
+- **New Methods**: 10
+- **New MCP Tools**: 10
+- **New Schemas**: 10
+- **API Endpoints**: 10
+
+## Testing
+
+✅ TypeScript compilation successful
+✅ All methods properly compiled to JavaScript
+✅ Type definitions generated correctly
+✅ No compilation errors
+✅ All tools registered in MCP server
+
+## Usage Examples
+
+### Creating a Label
+```typescript
+// Natural language with Claude
+"Create a new label called 'bug' with red color (#ff0000) in owner/repo"
+
+// Direct tool call
+{
+  "tool": "create_label",
+  "arguments": {
+    "owner": "owner",
+    "repo": "repo",
+    "name": "bug",
+    "color": "#ff0000"
+  }
+}
+```
+
+### Adding Labels to an Issue
+```typescript
+// Natural language with Claude
+"Add labels 3 and 5 to issue #7 in owner/repo"
+
+// Direct tool call
+{
+  "tool": "add_issue_labels",
+  "arguments": {
+    "owner": "owner",
+    "repo": "repo",
+    "number": 7,
+    "labels": [3, 5]
+  }
+}
+```
+
+### Managing Issue Labels
+```typescript
+// Replace all labels
+"Replace all labels on issue #7 with labels 4 and 6"
+
+// Remove all labels
+"Remove all labels from issue #7 in owner/repo"
+
+// Remove specific label
+"Remove label ID 3 from issue #7 in owner/repo"
+```
+
+## Design Decisions
+
+1. **Consistent Naming**: All tools use snake_case naming convention (e.g., `list_labels`, `add_issue_labels`)
+2. **Type Safety**: All methods use TypeScript types from `types.ts` (GogsLabel interface)
+3. **Error Handling**: All API calls properly propagate errors to MCP error handling
+4. **Documentation**: Comprehensive documentation for both users and developers
+5. **RESTful API**: All methods follow Gogs API conventions and endpoints
+
+## Integration with Existing Features
+
+The label management implementation integrates seamlessly with existing issue management:
+- Labels can be assigned when creating issues (existing feature)
+- Labels can be updated when modifying issues (existing feature)
+- New dedicated label tools provide more granular control
+- Label IDs are used consistently across all operations
+
+## Next Steps (Optional Enhancements)
+
+Potential future improvements:
+1. Add label color validation (ensure proper hex format)
+2. Add bulk label operations
+3. Add label search/filter functionality
+4. Add label templates
+5. Add label usage statistics
+
+## Conclusion
+
+The label management feature is now fully implemented and ready for use. All 10 Gogs label API endpoints are available through the MCP server with comprehensive documentation and examples.

+ 0 - 256
manage-issue-4.js

@@ -1,256 +0,0 @@
-#!/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();