{"id":29204698,"url":"https://github.com/thiswillbeyourgithub/github_discussion_parser","last_synced_at":"2025-07-02T15:06:36.121Z","repository":{"id":293089866,"uuid":"976627384","full_name":"thiswillbeyourgithub/github_discussion_parser","owner":"thiswillbeyourgithub","description":"Fetch and parse GitHub Discussions into LLM-friendly structured Markdown files.","archived":false,"fork":false,"pushed_at":"2025-05-13T16:30:02.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-13T16:48:08.861Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thiswillbeyourgithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-02T13:00:40.000Z","updated_at":"2025-05-13T16:30:06.000Z","dependencies_parsed_at":"2025-05-14T21:48:34.199Z","dependency_job_id":null,"html_url":"https://github.com/thiswillbeyourgithub/github_discussion_parser","commit_stats":null,"previous_names":["thiswillbeyourgithub/github_discussion_parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thiswillbeyourgithub/github_discussion_parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fgithub_discussion_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fgithub_discussion_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fgithub_discussion_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fgithub_discussion_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thiswillbeyourgithub","download_url":"https://codeload.github.com/thiswillbeyourgithub/github_discussion_parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiswillbeyourgithub%2Fgithub_discussion_parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263163163,"owners_count":23423495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-02T15:06:35.500Z","updated_at":"2025-07-02T15:06:36.109Z","avatar_url":"https://github.com/thiswillbeyourgithub.png","language":"Python","readme":"# GitHub Discussion Parser for LLMs\n\nThis project provides a Python script (`discussion_parser.py`) to fetch discussions from a GitHub repository and format them into individual XML-like Markdown files. The primary goal is to make the entire discussion history of a repository easily accessible and digestible for Large Language Models (LLMs).\n\nEach discussion, along with its comments and replies, is saved as a separate `.md` file. This structured format helps LLMs understand the context and flow of conversations within the repository's discussions.\n\n## Features\n\n*   Fetches all discussions or filters them based on various criteria (update date, involvement of contributors).\n*   Retrieves detailed discussion content, including the main post, comments, and nested replies.\n*   Outputs each discussion into two files by default:\n    *   A `.json` file containing the raw detailed data fetched from the GitHub API.\n    *   A `.md` file formatted with XML-like tags (e.g., `\u003cdiscussion\u003e`, `\u003cpost\u003e`, `\u003ccomment\u003e`, `\u003creply\u003e`) containing the discussion text, suitable for LLM processing.\n*   When LLM-ready Markdown generation is enabled (default), it also creates a single `all_discussions_llm_ready.md` file concatenating all individual discussion `.md` files, sorted by creation date.\n*   Organizes output into timestamped directories (format `YYYYMMDD_HHMMSS`) for easy tracking of runs.\n*   Handles GitHub API pagination and potential errors gracefully.\n*   Uses Loguru for clear logging to both console and a run-specific log file.\n\nThe script primarily uses the GitHub GraphQL API. For more details on querying discussions via GraphQL, refer to the official documentation: [Using the GraphQL API for Discussions](https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions). But also the [REST API](https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28), for which the openapi specifications can be found [here](https://github.com/github/rest-api-description/).\n\n## Prerequisites\n\n*   Python 3.8+\n*   Required Python packages listed in `requirements.txt`. Install them using pip:\n    ```bash\n    pip install -r requirements.txt\n    ```\n*   A GitHub Personal Access Token (PAT) with `repo` scope (or at least `public_repo` for public repositories). You can provide this token via the `--token` argument or by setting the `GITHUB_TOKEN` environment variable.\n\n## Usage\n\nThe main script is `discussion_parser.py`. You run it from the command line, providing the target repository URL and options.\n\n**Basic Usage (Fetch all discussions, generate JSON and LLM-ready Markdown for each, and a concatenated Markdown file):**\n\n```bash\npython discussion_parser.py -r https://github.com/owner/repo\n```\n*(Note: `--llm-ready` is enabled by default)*\n\n**Command-Line Options:**\n\n*   `-r`, `--repository` (Required): The URL of the GitHub repository (e.g., `https://github.com/owner/repo`).\n*   `-o`, `--output-dir` (Optional): Parent directory to save timestamped output subdirectories. Defaults to the current directory (`.`).\n*   `-t`, `--token` (Optional): Your GitHub Personal Access Token. If not provided, the script will look for the `GITHUB_TOKEN` environment variable.\n*   `--since` (Optional): Fetch discussions updated on or after a specific date (YYYY-MM-DD) or relative time (e.g., `7d` for 7 days ago, `2w` for 2 weeks, `1m` for 1 month).\n*   `--only-contributors` (Optional Flag): If set, only fetch discussions involving repository contributors (users who have committed to the repo). Otherwise, fetch all discussions.\n*   `--llm-ready` / `--no-llm-ready` (Optional Flag): Controls the generation of `.md` files with XML-like structure and the final concatenated `all_discussions_llm_ready.md` file. Enabled by default (`--llm-ready`). Use `--no-llm-ready` to disable Markdown generation and only create `.json` files.\n\n**Example: Fetch discussions updated in the last 30 days from a specific repo, generating only JSON:**\n\n```bash\n# Set the token as an environment variable (recommended)\nexport GITHUB_TOKEN=\"your_github_pat_here\"\n\n# Run the script, explicitly disabling LLM-ready output\npython discussion_parser.py \\\n    -r https://github.com/some-owner/some-repo \\\n    --since 30d \\\n    --no-llm-ready \\\n    -o ./output_data\n```\n\n**Example: Fetch only discussions involving contributors, generating both JSON and LLM-ready Markdown (default behavior):**\n\n```bash\npython discussion_parser.py \\\n    -r https://github.com/another-owner/another-repo \\\n    --only-contributors \\\n    -t your_github_pat_here\n```\n*(Note: `--llm-ready` is implied as it's the default)*\n\nOutput files will be saved in a subdirectory named with the timestamp format `YYYYMMDD_HHMMSS` within the specified output directory (or the current directory if `-o` is omitted). This directory will contain individual `.json` and (by default) `.md` files for each discussion (e.g., `discussion_123.json`, `discussion_123.md`), plus a `run.log` file and (by default) the `all_discussions_llm_ready.md` file.\n\n---\n\n*This README was generated with assistance from [aider.chat](https://github.com/Aider-AI/aider/issues).*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiswillbeyourgithub%2Fgithub_discussion_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiswillbeyourgithub%2Fgithub_discussion_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiswillbeyourgithub%2Fgithub_discussion_parser/lists"}