All source listed below is under MIT license if no LICENSE file stating different is available.

Mr. Issue

This document explains in detail how the project name is matched from the user's prompt and how the issue titles and descriptions are extracted, formatted as JSON, and used to create issues via the Gitea API in the app.py FastAPI application.

Project Name Matching

  1. User Prompt Input:

    • The user sends a prompt through a WebSocket connection.
  2. Fetching User Repositories:

    • The application fetches all repositories of the authenticated user from Gitea using the user_repos API endpoint.
    • It collects repository names into a list repo_names.
  3. AI-Assisted Project Name Extraction:

    • The application sends a message to the OpenAI API with the system role instructing the AI to extract project names from user prompts.
    • The user prompt and the list of available repositories are included in the message.
    • The AI is asked to respond with the exact or closest matching repository name, returning only the literal name.
  4. Matching Logic:

    • The AI's response is stripped and compared against the repository names fetched earlier.
    • The matching is case-insensitive and also checks if the AI's suggested name is a substring of any repository name.
    • If a match is found, that repository is selected for issue creation.
    • If no match is found, an error is sent back to the user.

Issue Title and Description Extraction

  1. AI-Assisted Issue List Generation:

    • The application sends another message to the OpenAI API with instructions to create a structured list of issues based on the user prompt.
    • The system role instructs the AI to return ONLY a valid JSON array with objects containing title and description fields.
    • The user prompt is included in the message.
  2. Parsing AI Response:

    • The AI's response is expected to be a JSON array string.
    • The code attempts to clean the response by removing any markdown code block delimiters like json or .
    • The cleaned string is parsed using json.loads to convert it into a Python list of dictionaries.
  3. Issue Creation via API:

    • For each issue object in the list, the application calls the Gitea API create_issue endpoint.
    • It passes the issue title and description as the body of the request.
    • The API response status is checked to confirm successful creation.

Summary

  • The project name is extracted by leveraging AI to analyze the user prompt and match it against the user's repositories.
  • Issues are generated by AI in a structured JSON format containing titles and descriptions.
  • These issues are then created in the matched repository using the Gitea API.

This approach combines AI natural language understanding with API interactions to automate issue creation based on user input prompts.

.gitignore
app.py
index.html
README.md