Fszontagh 37c52fbd75 feat: rewrite issue handler with TypeScript and Claude Agent SDK il y a 9 mois
..
src 37c52fbd75 feat: rewrite issue handler with TypeScript and Claude Agent SDK il y a 9 mois
.gitignore 37c52fbd75 feat: rewrite issue handler with TypeScript and Claude Agent SDK il y a 9 mois
README.md 37c52fbd75 feat: rewrite issue handler with TypeScript and Claude Agent SDK il y a 9 mois
package-lock.json 37c52fbd75 feat: rewrite issue handler with TypeScript and Claude Agent SDK il y a 9 mois
package.json 37c52fbd75 feat: rewrite issue handler with TypeScript and Claude Agent SDK il y a 9 mois
tsconfig.json 37c52fbd75 feat: rewrite issue handler with TypeScript and Claude Agent SDK il y a 9 mois

README.md

Agent Manager Client

TypeScript-based Claude Agent SDK client for automated issue handling in Gogs repositories.

Overview

This client uses the @anthropic-ai/claude-agent-sdk to provide AI-powered issue automation. It replaces the previous bash-based Claude Code implementation with a more robust, type-safe TypeScript solution.

Features

  • TypeScript Implementation: Fully typed code with compile-time safety
  • MCP Integration: Connects to gogs-mcp server for Gogs API operations
  • Issue Automation: Automatically handles issues assigned to Claude
  • Comment Processing: Responds to issue comments and updates
  • Environment-Specific Configuration: Supports different gogs-mcp paths via environment variables

Architecture

client/
├── src/
│   ├── claude-client.ts    # Main Claude Agent SDK client
│   ├── config.ts            # Configuration management
│   ├── types.ts             # TypeScript type definitions
│   └── index.ts             # CLI entry point
├── dist/                    # Compiled JavaScript (generated)
├── package.json             # Dependencies and scripts
└── tsconfig.json            # TypeScript configuration

Installation

cd client
npm install

Building

npm run build

This compiles TypeScript to JavaScript in the dist/ directory.

Usage

Programmatic API

import { ClaudeClient } from './client/dist/index.js';

const client = new ClaudeClient({
  workingDirectory: '/path/to/repo',
  mcpConfigPath: '/path/to/repo/.mcp-gogs.json',
  allowedTools: ['mcp__gogs__get_issue', 'mcp__gogs__create_issue_comment', 'Read', 'Write'],
  dangerouslySkipPermissions: true
});

const result = await client.handleIssue({
  owner: 'username',
  repo: 'repo-name',
  number: 42,
  title: 'Issue title',
  body: 'Issue description',
  action: 'opened',
  pusher: 'username',
  assignee: 'claude'
});

console.log(result);

Command Line

node dist/index.js <owner> <repo> <pusher> <issue_number> <issue_title> <issue_body> <issue_action> [comment_body] [assignee]

Webhook Integration

The client is integrated with the webhook server via scripts/handle-issue-ts.sh, which is called from commands.json for issue and issue_comment events.

Configuration

The client reads configuration from the repository's .env file:

GOGS_MCP_PATH=/data/gogs-mcp/dist/index.js

MCP Tools

The client has access to all gogs MCP tools:

User Tools:

  • mcp__gogs__get_current_user
  • mcp__gogs__get_user
  • mcp__gogs__search_users

Repository Tools:

  • mcp__gogs__list_user_repositories
  • mcp__gogs__search_repositories
  • mcp__gogs__get_repository
  • mcp__gogs__create_repository
  • mcp__gogs__delete_repository

Content Tools:

  • mcp__gogs__get_contents
  • mcp__gogs__get_raw_content
  • mcp__gogs__list_branches
  • mcp__gogs__get_commits

Issue Tools:

  • mcp__gogs__list_issues
  • mcp__gogs__get_issue
  • mcp__gogs__create_issue
  • mcp__gogs__update_issue
  • mcp__gogs__list_issue_comments
  • mcp__gogs__create_issue_comment
  • mcp__gogs__update_issue_comment

File Tools:

  • Read, Write, Edit, Bash, Grep, Glob, TodoWrite

Development

Watch Mode

npm run watch

Clean Build

npm run clean
npm run build

Requirements

  • Node.js >= 18.0.0
  • TypeScript >= 5.3.0
  • @anthropic-ai/claude-agent-sdk >= 0.1.28

License

ISC